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?
do you do null check before insert?
Yes i did but that got failed because i am getting a type cdt from the query entity rule like this for eg. [id=, col1=,...] hence applying rule that checks cdt is null or not on this type of cdt is failing.
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:
length(local!result) < 1
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).
Thanks Peter! I made changes to my query entity rule as per your reply and it worked.
Discussion posts and replies are publicly visible
© 2020 Appian. All rights reserved.