hi team.
I have a requirement as:
I have to create data using some dropdown values and after creation of that data user can delete that data from where that drop data is coming and once data is deleted from frontend then
when user tries to edit that created data then error throws as:
since value of that dropdown is deleted by the user then while editing how to handle this error
please suggest any answer
Mike Schmitt Soma
Discussion posts and replies are publicly visible
I solve such situations by checking that all the values are contained in the list of choiceValues before assigning them to the field.
can you please elaborate ?
actually while selecting from dropdown data exist that is why data is visible in dropdown but once user delete the drop down data then when editing this dropdown error throws as that dropdown is deleted
upon initially loading the form, you need to check whether any of the pre-filled dropdown items have a current value that violates the available choices for the dropdown. that's as simple as checking the local variable that will hold the dropdown choices to see whether it contains the selected value or not. then if the pre-loaded value setting is observed to contain a value not among the valid choices, you can either null it out, or force that value into the dropdown selections and have the dropdown component show an error validation.
can you please suggest by coding how can I do it that you mentioned to null it out or show an error validation:
" you can either null it out, or force that value into the dropdown selections and have the dropdown component show an error validation. "
appian.user said:can you please suggest by coding
I don't have time to assemble a working example at the moment (but if i get a chance i can look into it soon) - but in short, you need to learn to write manual code that prepares the necessary on-form local variables to allow you to do this. For instance, you would query the default choices into an initial local variable. Then you would declare another local variable that you will use to actually populate the choices, except in that local variable you check whether or not the existing options include all current selections (including any that may have been deleted), and if so, append those values to the set.
Something simple could be this:
a!localVariables( local!availableValues: {1,2,4,5}, local!selectedValues: {3,5,6}, local!finalValues: filter( contains(local!availableValues, _), local!selectedValues ), a!multipleDropdownField( choiceValues: local!availableValues, choiceLabels: local!availableValues, value: local!finalValues ) )
appian.user
Sample code for you reference:
a!localVariables( /*Query the selected Ids saved*/ local!selectedValues: { 1, 2, 3, 4 }, local!allStatusList: { a!queryRecordType( recordType: 'recordType!{c7aaff95-ce56-464f-8cee-382355601ed8}CSCM Lookup', filters: a!queryLogicalExpression( operator: "AND", ignoreFiltersWithEmptyValues: true(), filters: { a!queryFilter( field: 'recordType!{c7aaff95-ce56-464f-8cee-382355601ed8}CSCM Lookup.fields.{16b61379-08fe-4d34-a71f-54c7366c94e4}lookupType', operator: "=", value: cons!CSCM_TXT_LOOKUP_TYPE_SERVICE_TYPE ) } ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: cons!CSCM_INT_BATCH_SIZE_EXTRA_SMALL, sort: a!sortInfo( field: 'recordType!{c7aaff95-ce56-464f-8cee-382355601ed8}CSCM Lookup.fields.{c43d180d-159f-47b2-9e59-5487550b9bed}id', ascending: true ) ) ).data }, local!activeStatusList: index( local!allStatusList, wherecontains( true(), toboolean( index( local!allStatusList, 'recordType!{c7aaff95-ce56-464f-8cee-382355601ed8}CSCM Lookup.fields.{2bc67ffb-5c05-4e04-9d61-55fa46bc27a9}isActive', null ) ) ), null ), local!activeStatusListIds: index( local!activeStatusList, 'recordType!{c7aaff95-ce56-464f-8cee-382355601ed8}CSCM Lookup.fields.{c43d180d-159f-47b2-9e59-5487550b9bed}id', null ), local!deletedIdsFromList: difference( tointeger(local!selectedValues), tointeger(local!activeStatusListIds) ), local!currentlyActiveSelectValues: difference( local!selectedValues, local!deletedIdsFromList ), { a!multipleDropdownField( label: "Status", placeholder: "--Select a value--", choiceLabels: index( local!activeStatusList, 'recordType!{c7aaff95-ce56-464f-8cee-382355601ed8}CSCM Lookup.fields.{2bfd5d5e-b8b3-4cb8-aa22-f72c594b2c63}lookupValue', null ), choiceValues: index( local!activeStatusList, 'recordType!{c7aaff95-ce56-464f-8cee-382355601ed8}CSCM Lookup.fields.{c43d180d-159f-47b2-9e59-5487550b9bed}id', null ), value: local!currentlyActiveSelectValues, saveInto: local!currentlyActiveSelectValues ), a!richTextDisplayField( showWhen: a!isNotNullOrEmpty(local!deletedIdsFromList), value: a!richTextItem( color: "NEGATIVE", text: "Attention: The below values which are selected are not currently active now -" & index( index( local!allStatusList, wherecontains( tointeger(local!deletedIdsFromList), tointeger( index( local!allStatusList, 'recordType!{c7aaff95-ce56-464f-8cee-382355601ed8}CSCM Lookup.fields.{c43d180d-159f-47b2-9e59-5487550b9bed}id', null ) ) ), null ), 'recordType!{c7aaff95-ce56-464f-8cee-382355601ed8}CSCM Lookup.fields.{2bfd5d5e-b8b3-4cb8-aa22-f72c594b2c63}lookupValue', null ) ) ) } )