Structure is populated but OutSystems thinks it's empty

Hi There,

I have a structure defined which is to be used to send an email via Twilio's SendGrid API. When debugging, I can see the fields are being assigned and populated correctly, but the structure still thinks "empty = true" when it really should be "empty = false". This is causing 2 problems:

1. SendGrid thinks the fields in the data structure is empty so ignores the values

2. If I try to do a JSONSerialize, it also thinks that part of the structure is empty and doesn't return any of the fields.

Any ideas?

Thanks 

Simone

I'll give my take here. Are you assigning the values To.Email and To.Subject or are you adding a new record to that list? If you just assign the value, it will most likely fail.

If you're adding a new record and if it still shows up as empty, then it could be that variable that is not refreshed - that might be a bug or might be a design decision, since - as per my experience - I mostly use to check if a given data retrieval has returned results.

JSONSerialize returning empty data might be due to the first item.

Let me know if this helps.

To clarify what Armando said, when you have a List and you want to add an element to it, you need to use a ListAppend. In Platform version 10, you need to use a Variable of the same type as the List (but without it being a List, so if your List is "List of MyStruct" you need a Variable of type "MyStruct"), assign the right values to the Variable, then use ListAppend. In Platform version 11, you can directly use a ListAppend, and use the new feature of specifying values on the fly.

Also, you should never assign anything to the Current of a List, unless you are going to use the Current as Input to an Action, since what is the Current may change depending on what you do with the List (e.g. looping over it, or Ajax refreshing a Table Records that uses the List). Also never ListAppend the Current of a List to itself, it will fail (i.e. not the right values are appended).

Thanks Armando and Kilian, that has helped and it's working now :)


Great to hear Simone! Could you mark one of our answers as "Solution"? Thanks!