Hi All,
I have a requirement wherein I need to transfer one dictionary from child interface to parent interface on button click (Please note button is configured inside child interface)
Apart from saving the data into a rule input of type ANY TYPE, is there any other way to transfer a dictionary from child to parent?
Discussion posts and replies are publicly visible
The only way to pass a dictionary in a rule input is to use the type "Any Type". You could also make a CDT for this case if that made sense for your use case. Is there a reason why using Any Type is not sufficient for your use case?
Okay thanks !but any type looks insufficient to my case. Here is my scenario:
I've a button labelled 'Add New Data' in parent interface. Whenever i hit this button, it displays my child interface. On clicking 'Done' button in the child interface, brings the data to parent interface.
Now when I click 'Add new data' button again and it calls the child interface for the second time (looped) , now when i hit 'Done', i need to append both dictionaries. For this i've written below code in 'Done' button (child interface).
a!buttonwidget(
label:"Done",
saveInto:
{
if(rule!apn_isempty(ri!data),
a!save( ri!data, local!data ),
a!save(ri!data,append(ri!data,local!data)
)
}
Appending two ANY TYPE value fails . Could you please suggest some other way to do this?
We cannot append to a "Dictionary".
But we can append to a type "List Of Dictionary"
Correct you cannot append a dictionary to a dictionary. You need ri!data to be a List of Dictionary. You should be able to replace your if statement with just:
This will create a list of dictionary on the first save and then append new values to that list on subsequent saves.