This project is read-only.

Request parameter check for null

Nov 18, 2015 at 3:27 AM
My request parameter returns an Id field that i could use in an update action but what happens when the request parameter doesnt return any results?
Suppose my request parameter is #p11
If in the action condition i check for #p11 == null then i get the error in CRM as: "Unknown identifier '_p11' "

If my condition is set as #p11[0] == null which is of the type Guid then i get a typemismatch error within EasyPlugins itself

How can i check if my request parameter didnt return any results? Or do i have to do it as a Count in the fetchXML?
Nov 18, 2015 at 2:23 PM
Edited Nov 18, 2015 at 2:24 PM
Hi DVora,

a Guid is never null, please try these conditions :
#p11[0] == Guid.Empty
or
#p11[0].ToString() == "00000000-0000-0000-0000-000000000000"
or
Like you said, you can also create a new fetchXml parameter with "count" as aggregate function then use it in condition :
#p12 > 0
Regards,

Amine
Nov 19, 2015 at 4:37 AM
i tried the #p11[0].ToString() == "00000000-0000-0000-0000-000000000000" in the Abort Message action and then set the Message as just a string
But when it gets executed i get the following message:-
"No property or field 'id' exists in type 'Object' "
Nov 19, 2015 at 8:10 AM
Please try again the following expression by pasting it directly on Condition field without validating it
#p11[0] == null 
I just tried it on my environment and it worked.
I will correct the "type mismatch" in the next release.
Please let me know if it works for you.

-Amine
Nov 21, 2015 at 4:04 PM
I think the problem is using a Lookup attribute inside a request parameter. Whenever i use a lookup parameter #p1.Id or #p1.Name in the fetchXml it always returns null
Your suggestion of #p11[0] == null without validation works but the request parameter always return null, i havent been successfully be able to return any fetchxml results when using a lookup attribute inside the fetchxml
Please help
Nov 21, 2015 at 5:14 PM
With further testing i can verify this:
If you are using a Lookup attribute then you cannot directly use it in a request parameter (fetchxml)
You have to either store the Id, Name in a calculated parameter and then use that in the fetchxml to work.

I dont know whether this is how it should work but a good change/update would be that we should be able to use the lookup or optionset attribute directly in the fetchxml by using Id, Name, LogicalName, Code, etc