Hi team,
When I am choosing multiple options at one particular time I am getting this error. Please help me to solve this error.
Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 42]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!multipleDropdownField [line 199]: Invalid index (5) for list: valid range is 1..4
a!localVariables( local!pets:rule!SHA_refPets(), local!selectedValue:index(ri!pets, "petsIdFk", null()), local!originalArray: a!refreshVariable( value: local!selectedValue, refreshOnReferencedVarChange: false ), local!delete, local!insert, local!update, local!deleteCDT, local!insertCDT, local!updateCDT, local!mappingId:index(local!mappingKey,fv!index,null), { a!multipleDropdownField( label: "Pets" , placeholder: "select a value", choiceLabels: index(local!pets, "petsNm", null()), choiceValues: index(local!pets, "petsId", null()), value: local!selectedValue[wherecontains(true(),ri!pets.isActive)], saveInto: { local!selectedValue, a!save( local!update, intersection( tointeger(local!selectedValue), tointeger(local!originalArray) ) ),/*getting updated item*/ a!save( local!delete, difference( tointeger(local!originalArray), tointeger(local!selectedValue), ) ),/*getting deleted item*/ a!save( local!insert, difference( tointeger(local!selectedValue), tointeger(local!originalArray), ) ),/*getting new item*/ a!save( local!insertCDT, a!forEach( items: local!insert, expression: 'type!{urn:com:appian:types:SHA}SHA_newPets'( petsId: null, listingIdFk: index(ri!pets.listingIdFk, 1, null), petsIdFk: fv!item, mappingKey: null, isActive: true ) ) ),/*Creating CDT for new item*/ a!save( local!deleteCDT, index( ri!pets, wherecontains( tointeger(local!delete), tointeger(ri!pets.petsIdFk) ) ) ),/*getting deleted index item*/ a!save( local!deleteCDT, a!forEach( items: local!deleteCDT, expression: 'type!{urn:com:appian:types:SHA}SHA_newPets'( petsId: fv!item.petsId, listingIdFk: fv!item.listingIdFk, petsIdFk: fv!item.petsIdFk, mappingKey: fv!item.mappingKey, isActive: false, createdBy: fv!item.createdBy ) ) ),/*CDT Creation for Deleted item*/ a!save( local!updateCDT, index( ri!pets, wherecontains( tointeger(local!update), tointeger(ri!pets.petsIdFk) ) ) ),/*getting updated item index*/ a!save( ri!pets, reject( fn!isnull, append( local!updateCDT, local!deleteCDT, local!insertCDT ) ) )/*Final*/ } ) }
Discussion posts and replies are publicly visible
Why are you doing this?
value: local!selectedValue[wherecontains(true(),ri!pets.isActive)],
I would actually expect this to not work - the whereContains() statement wil return all indices of ri!pets where isActive is true, which is *not* relevant to the length of or current selections in local!selectedValue.
Instead, you should probably start out with the standard simple version,
value: local!selectedValue
because deleted and inserted both are getting displayed in the multi-dropdown field.So I want to show(display) only the inserted value which contains isActive =true
I would recommend redesigning this approach altogether. Trying to update the available choices for a Multi Dropdown in real-time to remove any choices that have been de-selected is asking for trouble just in terms of overall complexity, scalability and future maintenance; and aside from that, it will be disastrously confusing to users who might de-select the wrong item and then find themselves unable to re-select it.
while deselecting the item, the item will not be deleted from the drop down only it will disappear from the value field and the respective pet status become inactive but it is still there in the drop-down so that you can select and make the status active
mamathak0001 said:will not be deleted from the drop down only it will disappear from the value field
What "value field" are you referring to?
the below one:
a!multipleDropdownField( value:)
But the only thing needed for that is to deselect it from the dropdown value. No special extra saves or data filtering on the values variable is needed.
sorry wrongly highlighted
This appears to be a picture of the (collapsed) multiple dropdown field - what I said above still applies. The only thing needed to "remove" values from this is to deselect them as normal.
no i want to store the deselected values also with status as inactive (active=false)
that's fine - the logic you're doing in the saveInto field appears to be handling this (assuming it works), but my point is that you do *not* need to do manipulation on the "value" parameter like you're currently doing. The "value" parameter should simply point at the "selected values" array.
I tried with "selected values" also, the problem I am facing is "it is displaying the items with status(active=false) so I need a condition which will display only items with status(active=true)
1. To get the items with status(active=true) i have written the condition wherecontains(true,ri!pets.isActive) but it is failing
when you say "displaying the items", do you mean as choices or as selected values? If de-selecting them causes them to get an active status of "false", i'm not sure what's happening. Again I must point to my points of advice above and strongly recommend you simplify down to something you understand (and that works), and build up from there.
"displaying the items" means the choices which i am selecting in multidrop down
Mike Schmitt thanks a lot for your replies, sure i will try your suggestions