Checking for a list collector selection

Cirrus
Kilo Sage

Afternoon,

I am hoping someone can help me finish this off.

We have an order guide with 10 catalog items. The user selects which items they want to order using a list collector variable. 9 of the items follow the standard ritm/task workflow route, but item 10 isnt ordered, they can collect it form reception. As it's part of the 'portfolio', we still want to show it as an option. However, what we would like is if the user selects this item then an alert pops up to tell them to go to reception, and ideally it doesnt get added to the right bucket. The script below manages the alert, but when you click on the item, and ok the alert, the item is still added to the right bucket, and if they dont remove it then any additional item the user adds says its collected from reception as well. Is there anything I can add after the alert to clear the value from the right bucket??

 

function onChange(control, oldValue, newValue, isLoading) {
var flg= 'false';
var str= newValue.toString();
var arr= str.split(',');
for(var i=0; i<arr.length; i++ ){
if(arr[i] == '3e1093661b105914ce1564a2b24bcb7d'){  //sys id of item 10
flg=   'true';

break;
}
}
if(flg == 'true'){

alert('This item is available for collection from Reception.');
}
}

 

1 ACCEPTED SOLUTION

You can modify your code:

if(flg == 'true'){

    alert('This item is available for collection from Reception.');

    var ind = arr.indexOf('3e1093661b105914ce1564a2b24bcb7d');
    arr.splice(ind,1);
    g_form.setValue('your list field name',arr.join(','));

}

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

 

Best Regards
Aman Kumar

View solution in original post

9 REPLIES 9

I notice that if you select say items 1 and 2 (which require orders) and then item 10, then click ok on the alert message, the oldValue command removes item1 and item 2 as well. Is there any way of stopping this behaviour so that only item 10 is removed? 

You can modify your code:

if(flg == 'true'){

    alert('This item is available for collection from Reception.');

    var ind = arr.indexOf('3e1093661b105914ce1564a2b24bcb7d');
    arr.splice(ind,1);
    g_form.setValue('your list field name',arr.join(','));

}

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

 

Best Regards
Aman Kumar

Perfect, thanks Aman

Hey @Cirrus ,

I think you marked your own response as correct.

DO you mind marking my response as correct, if this worked for you.

Thanks

Best Regards
Aman Kumar

@Cirrus  i think you marked your answer as correct 

Please mark the one of the appropriate answers given by me or Aman