Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
3 replies
Subscribers
9 subscribers
Views
1884 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Is there a way to prevent Appian from sorting an integer array when it is autosa
aswinb
over 10 years ago
Is there a way to prevent Appian from sorting an integer array when it is autosaving. Basically this happens in a multiple checkbox field. the choiceValues are 1 thru 12 and I am saving that to a local list array. I want to get the value of the last item that is checked in this checkbox field. The problem arises when there are many options selected randomly and then this saveInto sorts the values that are getting saved into this local variable and so the last value that is checked gets sorted and pushed to somewhere else in the array. The best I could do was to get the last item that is either checked or unchecked but I could not get the one that got checked before I unchecked something. This is the code below:
load(
local!lastValue,
local!tempValues:{},
local!compareValues:{},
local!multipleChoices:{},
with(
....formlayout and all that stuff .......
a!checkboxField(
label:"checkbox",
choiceLabels:index(local!display, "VALUE", {}]),
chioiceValues:...
OriginalPostID-144185
OriginalPostID-144185
Discussion posts and replies are publicly visible
Parents
0
Conor Cahill
Certified Lead Developer
over 10 years ago
It looks like you're on the right path with having an intermediary save (local!multipleChoices). After that you need to null check it (which you do). Now you just see if an item was added or removed by checking the length of local!multipleChoices and local!compareValues. The thing I would change is save your lastValue as an array of lasts, with the final value in the array being your last selected value.
If local!multipleChoices is longer, that means you added an element, and so you'll find that element by doing difference(local!multipleChoices, local!compareValues). Simply append that value to your lasts array.
if local!compareValues is longer, then you removed an element, so you'll need to also remove an element from your lasts array. To do that use the following: remove(local!lasts, wherecontains(difference(local!compareValues, local!multipleChoices), local!lasts))
You may need to add some null checks for edge cases, but that should be your general strategy.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Conor Cahill
Certified Lead Developer
over 10 years ago
It looks like you're on the right path with having an intermediary save (local!multipleChoices). After that you need to null check it (which you do). Now you just see if an item was added or removed by checking the length of local!multipleChoices and local!compareValues. The thing I would change is save your lastValue as an array of lasts, with the final value in the array being your last selected value.
If local!multipleChoices is longer, that means you added an element, and so you'll find that element by doing difference(local!multipleChoices, local!compareValues). Simply append that value to your lasts array.
if local!compareValues is longer, then you removed an element, so you'll need to also remove an element from your lasts array. To do that use the following: remove(local!lasts, wherecontains(difference(local!compareValues, local!multipleChoices), local!lasts))
You may need to add some null checks for edge cases, but that should be your general strategy.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data