Help with where statement

Hello,
I am a newbie in Mikrotik scritpting and just learning the ropes right now. I have a script that works correctly but I need to put a where statement in this script to not run where it detects an agent remote id field.
the current script is :

/ip dhcp-server lease
 :foreach dhcplease in=[find] do={
 :local dhcpip [get $dhcplease address]
 :local dhcpmac [get $dhcplease mac-address]
 :put $dhcpmac
 :put $dhcpip
 :do { /tool fetch url="https://$url/api/v1/network/ipam/dynamic_ip_assignment?ip_address=$dhcpip&mac_address=$dhcpmac" mode=https keep-result=yes user=$username password=$password } on-error={} ;
		}

I would like to put where statement on this script to not run when it detects the agent-remote-id is not Null. But I am not sure where to put this where statement at..
Thanks

I would like to put where statement on this script to not run when it detects the agent-remote-id is not Null

I would like to put where statement on this script to not run when it detects the agent-remote-id is not Null.


/ip dhcp-server lease
:foreach dhcplease in=[find] do={
    :local dhcpip [get $dhcplease address]
    :local dhcpmac [get $dhcplease mac-address]
    :local dhcprid [get $dhcplease agent-remote-id]
    :if ([:typeof $dhcprid] = "nil") do={
        :do {
            /tool fetch user=$username password=$password \
            url="https://$url/api/v1/network/ipam/dynamic_ip_assignment?ip_address=$dhcpip&mac_address=$dhcpmac"
        } on-error={ }
    }
}

Thank you . I will run this.
I need to learn Mikrotik Scripting. Does anyone offer any scripting courses or something or any video tutorials? I feel like I don't know how any of this works.

You sure?
Did you notice that I have changed very few things?
Your script was almost all written correctly…
Often other scripts that I correct are monstrous…

You are on your way.
I didn’t take any courses, I learned easily because I had already programmed in the past on other languages​…
Unfortunately I don’t know what to recommend…