How to create a dependency between Caller and Channel in the incident form?

Alt30
Tera Contributor

Hello, I hope someone can help with the client script.

I am trying to test this in my PDI before working on the customers' dev instance but so far, all options I tried fail to create the auto population of the filed I am after.

In the incident form, I need the field Channel to be auto-populated with one of the dropdown options (say 'Email' as in PDI) if for example 'Abraham Lincoln' is selected in the Caller field. Is it possible and if yes, what script would work to achieve this? Thanks in advance for any useful suggestions!

 

1 ACCEPTED SOLUTION

swathisarang98
Giga Sage
Giga Sage

Hi @Alt30 ,

 

Contact type or channel is set based on how the end user raised the incident still if you want to make the changes or link between caller and channel you can create on change client script on Caller field and set the channel value,

swathisarang98_0-1717077198719.png

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

  var caller = g_form.getReference('caller_id', currentUser1);

}
function currentUser1(caller){
	if(caller.name == 'Jerrod Bennett'){
		g_form.setValue('contact_type','email');
	}
}

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

View solution in original post

6 REPLIES 6

Thanks, Swathi, your script indeed worked!👍

I also added a line to reset Channel field back to --None-- if a different caller is added.

 else {
        // clear Channel field if Caller is not 'Abraham Lincoln'
        g_form.setValue('contact_type','');

Hi Swathi,

I was wondering if you could help to go one step further in adding a script to clear the Channel field back to --None-- if 'Abraham Lincoln' is removed from field. Currently, I used the following based on the script you kindly offered:

function onChange(control, oldValue, newValue, isLoading, isTemplate) { 

   if (isLoading || newValue === '') { 

      return; 

   } 

 

  var caller = g_form.getReference('caller_id', currentUser1); 

 

} 

function currentUser1(caller){ 

    if(caller.name == 'Abraham Lincoln'){ 

        g_form.setValue('contact_type','email'); 

    } 

    else { 

        // clear Channel field if Caller is not 'Abraham Lincoln' 

        g_form.setValue('contact_type',''); 

    } 

} 

It only clears the Channel field to --None-- if another Caller is selected but if I remove Abraham Lincoln, selected 'Email' remains.

Is that smth that can be achieved additionally?