I am trying to construct a Web API that queries a data entity and compares a fie

Certified Senior Developer
I am trying to construct a Web API that queries a data entity and compares a field in that data entity with an array of values that I've stored in a local variable (created from another a!queryEntity). I've hardcoded the value in my first query so I know what results I should get in the second one. Both queries work individually, but I get this expression evaluation error when I combine them. Any suggestions on what I'm missing? I'm pretty sure that once I get this working, I'll also have to add something to account for null values in the first query....but that's another issue. See the attached file for the code.

Expression evaluation error at function a!queryEntity [line 33]: Cannot apply operator [IN] to field [checkid] when comparing to value [TypedValue[it=197,v={TypedValue[it=1,v=621],TypedValue[it=1,v=622],TypedValue[it=1,v=623]}]].

NestedQueryForWebAPI.txt

OriginalPostID-200061

OriginalPostID-200061

  Discussion posts and replies are publicly visible

  • @judym An other way of doing it is to prevent the queryEntity call in case if there are null values. This way you can be much clear with empty checks such as rule!APN_isEmpty(local!checkIds) or rule!APN_isEmpty(local!entities) and further we can also prevent the interface from querying the cons!ABC_AMOUNT_DS incase if local!checkIds has got null values.

    Attached the code snippet for the same in case if you want to take a look.
  • 0
    Certified Senior Developer
    @sikhivahans - I actually tried several 'if' statements using that rule to check for null values and couldn't get them to work. I just tested this alternative and got the same expression error I was getting before. "Expression evaluation error at function a!toJson [line 63]: The value parameter of a!toJson() must not be null." I understand the logic here but it appears as if the a!toJson() function is different from others in that you can't have 'null' values. It must need a value even if it's '{0}' as in the version I previously uploaded. Thanks again for your help!
  • @judym If you are sure that '0' doesn't have any significance at any point of time, you might proceed with using {0}. Also it might be worth adding the comments in code stating why {0} is added rather than doing null checks, as few might not be able to understand this.

    At the same time, if you come across the records with a value '0', then this might fail and in this case null handling will be beneficial which will be like attached code snippet.