Interface Error dealing with an array inside a CDT

Briefly, the situation is as follows:
-My Data Type of a FIR_BusinessPartner, has an array of Contacts, of data type FIR_Contacts.

-In my FIR_AddBusinessPartnerForm, at least 1 contact info is required.

-Although I am passing a BusinessPartner as a RI, which includes an array of FIR_Contacts, it still won’t let me access that array properly.

 

Question/Issue:

1- For example, in FirstName text box, I can’t “Save Input to” “ri!businessPartner.contacts.firstName” naturally, I have to type that as an expression, is that normal?

2- It is not allowing me to “Display Data” with the same expression above, gives me an error of the following.

Please advise.

Thank you.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    If you're acting upon an unpopulated ri!businessPartner, then the error you're seeing would be expected as far as I know.  "ri!businessPartner.contacts" would refer to an empty set, and the further ".firstName" property would not exist within that empty set, directly leading to the error message you've posted. 

    If you're adding a new Business Partner, i'm thinking you'll want to have a control on the form where the user clicks to add the first Contact, and that click would add an empty FIR_Contact entry to the first entry of ri!businessPartner.contacts; at this point you could directly address that new instance and save data into it.  This might be a good use case for an editable grid (even if it just has one or two fields per row) as it implicitly handles arrays like this when configured properly.

  • 0
    Certified Lead Developer

    In short your error message means that you didn't handle "null" properly.  Appian frequently interprets null of an unknown type as null Text type.  So when it receives null from your CDT, where a sub-CDT should be, it has nothing to grab the structure from.  So it doesn't know anything at all about the structure, which is why it can't find the 'firstName' property of the nothing.

    Check to make sure the FIRContactList has a length greater than 0 before attempting to grab values from it. 

    You may also want to consider, if your user is supposed to input the first entry, to make all the components a separate local variable that you can then save into the larger CDT's contactList.  For instance, local!startingFIRContact.  Then your text inputs can save into that, and a button can save that into the larger CDT.  And if your query does get valid values for it in the beginning, you can overwrite the local variable with the contents from the query, otherwise it will still have a structure and won't crash.