Multiple choice picks in order?
Ninox Profile

@Mconneen, Have you worked out the logic yet? ;)

Ninox Profile

@Sean... Other than learning the number.. numbers .. chosen.. functions..  I have not really put much more thought into it.   I suspect a hidden choice table could be created .. and then an after update trigger could figure out which item was added / removed .. and manipulate the table..   or you could use a single choice box.. with and add/remove button and build the choice table... or..... pull the choices out to checkboxes / switches and have an after update trigger call a common function that adds / remove to the choice table... then use the concatenate to display them in the order checked..... or ... just build an inner choice table and let them use the out of the box functionality.. or..... ;)

Ninox Profile

@Mconneen, Hmmm, I guess I'm not seeing the single Choice solution unless you have one Choice field for every Multiple Choice option. I tried using a separate table to store the Multiple Choice options and that seemed like a lot of unnecessary work. This is what I came up with...

 

let curChosen := OPChosen;
let newChosen := chosen(MC);
let myContains := true;
let mcCount := count(numbers(MC));
let x := 0;
while myContains and x < mcCount do 
if contains(curChosen, item(newChosen, x)) then
x := x + 1
else
myContains := false
end
end
;
if OPChosen > "" then
OPChosen := curChosen + "," + item(newChosen, x)
else
OPChosen := item(newChosen, x)
end

 

OPChosen is just a Text field that I store the result in. I use a Formula field to display it with more formatting options. This does not test for removed items so that will break it.

Ninox Profile

Ooops, forgot to mention that the code goes in the "Trigger after update" for the Multiple Choice field.

Ninox Profile

@gsechi, I don't know if you are interested, but here is a solution that works for selection and deselection. It requires a Text field to store the ordered Multiple Choice selection/deselection and the result can be displayed in a Formula field. Here is a screenshot...

 

Screen Shot 2019-04-14 at 8.49.39 PM

 

The OPChosen field can be hidden or be used instead of the Formula field. I'm not completely happy with the code, but it works. The following code goes in "Trigger after update" for the Multiple Choice field...

 

let curChosenText := OPChosen;
let curChosenArray := split(replace(OPChosen, ", ", ","), ",");
let curCount := count(curChosenArray);
let newChosenText := replace(concat(chosen(MC)), ", ", ",");
let newChosenArray := chosen(MC);
let newCount := count(newChosenArray);
let myContains := true;
let x := 0;
if newCount > curCount then
while myContains and x < newCount do 
if contains(curChosenText, item(newChosenArray, x)) then
x := x + 1
else
myContains := false
end
end
;
if OPChosen > "" then
OPChosen := curChosenText + "," + item(newChosenArray, x)
else
OPChosen := item(newChosenArray, x)
end
else
while myContains and x < curCount do 
if contains(newChosenText, item(curChosenArray, x)) then
x := x + 1
else
myContains := false
end
end
;
var tmpArray := for idx from 0 to curCount do
if idx != x then
item(curChosenArray, idx)
end
end;
OPChosen := replace(concat(tmpArray), ", ", ",")
end

 

The Formula field code...

 

replace(OPChosen, ",", "
")

 

The "," is replaced by alt+enter or option+return.

Ninox Profile

@Mconneen, The separate table approach would be pretty handy if someone wanted to timestamp the different picks.

G

@Sean. Thanks. Not much time spent on this in the last couple of days, but I'll try your solution and I'll get back as soon as I can. Thank you for your time.

Gianluca

Ninox Profile

For anyone that is interested this is a version that I'm a little happier with...

 

"// Initialize variables";
let curChosenText := OPChosen;
let curChosenArray := split(OPChosen, "|");
let curCount := count(curChosenArray);
let newChosenText := replace(concat(chosen(MC)), ", ", "|");
let newChosenArray := chosen(MC);
let newCount := count(newChosenArray);
let myContains := true;
let x := 0;
"//";
"// Update OPChosen if an item is selected";
if newCount > curCount then
while myContains and x < newCount do 
if contains(curChosenText, item(newChosenArray, x)) then
x := x + 1
else
myContains := false
end
end
;
if OPChosen > "" then
OPChosen := curChosenText + "|" + item(newChosenArray, x)
else
OPChosen := item(newChosenArray, x)
end;
"//";
"// Update OPChosen if an item is deselected"
else
while myContains and x < curCount do 
if contains(newChosenText, item(curChosenArray, x)) then
x := x + 1
else
myContains := false
end
end
;
curChosenArray := unique(slice(curChosenArray, 0, x), slice(curChosenArray, x + 1, count(curChosenArray)));
curChosenText := "";
"//";
"// Custom concatenating loop";
for i in range(0, count(curChosenArray)) do
curChosenText := curChosenText + item(curChosenArray, i) + "|"
end;
OPChosen := curChosenText
end

 

This is what I do when shippers take a long time to load the trailer. 😁

1 2
Reply