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
As an aside, please note this was posted twice (i assume by accident). I suggest editing the post content of the other one and directing people here instead.
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
sure Mike Schmitt
That isn't how the value parameter is intended to work, though. What you've written will break, for the specific reason I noted. If you want users to be unable to select certain values depending on background conditions, I suggest you handle that within a Validation, instead of messing with the choices or the current value.
Also, you're executing a whole lot of logic in the saveInto of your multiple dropdown - these will all run every single time the selected value is changed. I would strongly suggest that you move this logic into a button click or link, to be run only after the user's selections might be finalized.
if i do how you suggested the end-user cannot see the newly selected and newly deleted value as soon as the end user performing some action on that multi-drop field until i click that button right
There's a fundamental issue here with the notion that deselecting items on your list instantly makes them "deleted", i think. This level of complexity is essentially setting yourself up for failure.
I'm not really even clear what your use case is, but as always my underlying suggestion is to simplify to something that works, and then gradually add back some complexity if and only if needed.
yes when i am deselecting the particular value it is getting inActive and when i am selecting, the status will become active so i want to display only the pets with the active status
Thanks, Mike Schmitt sure I will try this
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.