Query Entity rule is returning type() cdt when the result is Null for single type cdt.

Certified Senior Developer

I have observed that when query entity rule returning "no data" is mapped to single type of CDT then that cdt stores typed cdt rather than null. This is causing write to data store entity to insert a null row in the table because the null check is failing for this cdt.

Note: All The fields in my cdt can store null except the primary key field. How can i handlle this type of situation?

  Discussion posts and replies are publicly visible

Parents
  • In Appian an empty list doesn't behave the same way as a null. If your query doesn't return data, it isn't returning a true null - it's actually returning an empty list. If you try to cast this result to a list of CDT, it works fine. But if you try to cast to a single CDT, there isn't a true representation of an empty list, so it approximates it as a CDT with no field values defined.

    If you want it to behave like a null, you should do a null / empty check with the result and make sure it returns null and not an empty list. You can try something like this:

    if(
      or(
        isnull(local!result),
        length(local!result) < 1
      ),
      null,
      local!result
    )

    Of course, you may need to change this depending on your use case too (for example, you wouldn't want "null" as an input to your write to data store entity node; you should use a gateway to go around it instead).

  • 0
    Certified Senior Developer
    in reply to Peter Lewis

    Thanks Peter! I made changes to my query entity rule as per your reply and it worked.

Reply Children
No Data