Hello, I have a "little" problem.
I have an array that I want to modify using a! save, inside my foreach. Everything works fine on the interface.
a!sideBySideItem( item: a!buttonArrayLayout( buttons: { a!buttonWidget( label: "", icon: "trash-o", size: "SMALL", width: "MINIMIZE", style: "DESTRUCTIVE", loadingIndicator: true, saveInto: { a!save( target: ri!moneyAccounts[fv!index].isDeleted, value: true() ), } ), a!buttonWidget( label: "", icon: "pencil-square-o", size: "SMALL", width: "MINIMIZE", style: "PRIMARY" ) }, align: "START" ), width: "MINIMIZE" )
But when I want to use it on the site I get this error. Please help
Discussion posts and replies are publicly visible
Can you share some more detail around how you're calling this interface from the site and/or parent interface? In particular, how the value being passed in for ri!moneyAccounts is initially being established prior to being passed into the interface in question. As the error message indicates, you're probably using an indvalid method of doing such, though it's hard to guess at exactly what.
HI brayanm0001,
Can you also describe how is this interface rendered on your site
Is it through a parent interface / process model ?
I believe you are using a parent interface and inside that you have not declared this rule parameter as a local variable.
Eg. lets say your above code is in a rule say, rule!ABC which has a rule input ri!moneyAccounts
then in your parent interface, you must declare a local variable for this rule input as well
so, make sure you are calling this rule ABC in the parent interface something as
rule!ABC(
moneyAccounts: local!moneyAccounts
)
Of course The interface I have on my site calls another interface where I pass the moneyAccount to it.contents: a!columnsLayout( columns: { a!columnLayout( contents: { rule!BMC_ListMoneyAccounts( moneyAccounts: rule!BMC_GetMoneyAccounts( uuidUser: user(loggedInUser(), "uuid") ).data ) }, width: "AUTO" ) }, stackWhen: { "PHONE", "TABLET_PORTRAIT", "TABLET_LANDSCAPE", "DESKTOP_NARROW" } ),
contents: a!columnsLayout( columns: { a!columnLayout( contents: { rule!BMC_ListMoneyAccounts( moneyAccounts: rule!BMC_GetMoneyAccounts( uuidUser: user(loggedInUser(), "uuid") ).data ) }, width: "AUTO" ) }, stackWhen: { "PHONE", "TABLET_PORTRAIT", "TABLET_LANDSCAPE", "DESKTOP_NARROW" } ),
Yes, of course, this is my code on my site, I call this interface that I mentioned where I have the list of money accounts and I pass the moneyAccount parameter through an expression.a!columnsLayout( columns: { a!columnLayout( contents: { rule!BMC_ListMoneyAccounts( moneyAccounts: rule!BMC_GetMoneyAccounts( uuidUser: user(loggedInUser(), "uuid") ).data ) }, width: "AUTO" ) }, stackWhen: { "PHONE", "TABLET_PORTRAIT", "TABLET_LANDSCAPE", "DESKTOP_NARROW" } ),
a!columnsLayout( columns: { a!columnLayout( contents: { rule!BMC_ListMoneyAccounts( moneyAccounts: rule!BMC_GetMoneyAccounts( uuidUser: user(loggedInUser(), "uuid") ).data ) }, width: "AUTO" ) }, stackWhen: { "PHONE", "TABLET_PORTRAIT", "TABLET_LANDSCAPE", "DESKTOP_NARROW" } ),
This explains what you see in your error message. From this parent contxt, you're passing the direct result of a query into the rule input, but then in the sub-interface, you're trying to save a new value into it. The issue is that the new value does not have a proper location to save "up" into (such as a local variable).
Also I would caution you that even if you provide a local variable for it to save up into, this change will only be transient and will not affect the DB value unless you take specific steps to also save the new value into the DB.
Thanks.
well, if you see the moneyAccounts parameter value is not set to a rule input / local variable / process variable and that's the reason it is giving you an error.
So, if you do something like the below, it will work.
a!localVariables( local!accounts: rule!BMC_GetMoneyAccounts(uuidUser: user(loggedInUser(), "uuid")).data, a!columnsLayout( columns: { a!columnLayout( contents: { rule!BMC_ListMoneyAccounts(moneyAccounts: local!accounts) }, width: "AUTO" ) }, stackWhen: { "PHONE", "TABLET_PORTRAIT", "TABLET_LANDSCAPE", "DESKTOP_NARROW" } ) )
Done, it worked correctly many thanks to you and Mike Schmitt for your answers.