How to specify contains in client script for multi-value list field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 10:13 AM
Hi guys, we are introducing a multi-select 'Impacted regions' field to our INC form (on a Major Incident tab).
Currently we have a script that sets e-mail recipients based on the Priority and a Customer field 'Member field' (which is a one value field).
We will want to update this client script off of the Impacted regions field (also on the INC form) instead of Customer Member firm so my question is how can we update it e.g. how can I specify 'contains' in the below example instead of == where the Newvalue could be up to 5 values and not just one?
if((newValue == 'TESTMEMBERFIRM') && (priority == 7)){
g_form.setValue('u_to', 'test@test.com');
}
In other words how could I say newValue contains 'USA' and 'Canada' - I'm not sure how the values in a multi-select list field are parsed.
Many thanks in advance,
DS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 03:25 AM
Hi Michael, unfortunately I'm having a bit of difficulty. I've updated the script to the below for now - please confirm if anything is wrong?
The onChange field name has been changed to the right field i.e. 'Impacted regions' - which is the multi-select field. This is a reference field to Location, does this mean it is expecting the sys ID instead of e.g. 'Australia' below?!
Also if we wanted to send an e-mail if all regions are present how could we send to one 'global' e-mail address but not send to all the other 'regional'. E.g. is there a way to say if length of all regions is over x amount of characters?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var pr = g_form.getValue('priority');
var priority = parseInt(pr);
if((newValue.indexOf('Australia') >-1) && (priority == 1)){
g_form.setValue('u_to', 'test@test.com');
}
Many thanks,
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 07:03 AM
Daniel,
Ah yes you are correct, lists store the SysID's of the referenced records. So instead of looking for the name Australia you will have to use the SysID of that record instead.
Regarding the question about emailing the regions, I am not following you on that question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 07:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 07:59 AM
Yes indexOf() will still work with SysIDs as well. Just change the name to the location SysID.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 08:24 AM
Hi - I've updated it to the sys ID (for Region/Location Australia) as per below but still can't get the recipients to show as expected unfortunately... oh man. Does it make a difference that the field 'Impacted regions' is on a different tab/section i.e. does that section have to be referenced/named in the script perhaps?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var pr = g_form.getValue('priority');
var priority = parseInt(pr);
if((newValue.indexOf("f69521b437d0200044e0bfc8bcbe5d6e") >-1) && (priority == 1)){
g_form.setValue('u_to', test@test.com');
}