Client script to Assign Group automatically

lexdiaz
Giga Contributor

Hi community

I want to auto-assign automatically the Assignment Group(Hardware Group) based on the Business Service( hardware) that is selected when a user submit a new incident from the Service Portal

I have another Business Service( software) that when a Incident is submitted, they are assigned automatically to "Software Group", it works fine, but I don't know which script handles this.

So, I created this Client Script I found in the community, but something keeps setting all Incidents to "Software Group", I don't know if I am doing something wrong.

find_real_file.png

function onSubmit() {

    //Type appropriate comment here, and begin script below

    var bs= g_form.getReference('Hardware', setAssignmentgroup);

function setAssignmentgroup() {

    if (bs)

            g_form.setValue('Hardware group', bs.assignment_group);

}

}

9 REPLIES 9

harishdasari
Tera Guru

Hi Lex,



Instead of On-Submit, use the On-Change client script




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


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


          return;


var bs= g_form.getReference('business_service', setAssignmentgroup);   // Here it is not hardware.. you have to give the field name



function setAssignmentgroup() {


    if (bs)


            g_form.setValue('assignment_group', bs.assignment_group);   // hardware is value not field so I am replacing the value with field name


}


}


}




Thank you.


Rashmi Bansal
Mega Guru

Hi Lex,



Please try below client script..



find_real_file.png


find_real_file.png



Please mark my answer correct or helpful if it helps you.


Thanks,


Rashmi


thanks for your help, I tried this script with no luck. Can you share the code, not a screen shot?


thank you


Hi Lex,



You need to replace your sysids in the code provided and this is the onchange script on the business service field. Please try and let me know



Thanks,


Rashmi