Record producer: Issues with autopopulate assignment groups, category and subcategory fields

Yamlet8
Giga Expert

Hi so I'm trying to autopopulate the sub category and assignment group as well as the category based on producer subcategory. As i try to define the set value, im being met with error

any help this is for a client script

 

function onSubmit() {
    var gr1 = new GlideRecord('sys_user_group');
    gr1.addQuery('name', <group name>);
<10+ group name queries for gr.1>
    gr1.query();
    if (gr1.next()) {  //hopefully as the producer populates the incident ticket it populates the below information
//need a replacement for specification when setting group instead of set value
  try {
            if (g_form.getValue(producer.problem_subcategory) == '<sub cat name>') {
                g_form.setValue(current.assignment_group, '<group name>');

            }
        } catch (err) {
            g_form.addErrorMessage("A runtime error occured: 2 " + err);
        }
<5+ try/catch to pinpoint the producer sub category and assign group >
5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@Yamlet8 try the following script.

 

function onSubmit() {
    var gr1 = new GlideRecord('sys_user_group');
    gr1.addQuery('name', <group name>);
    gr1.query();
    if (gr1.next()) {  //hopefully as the producer populates the incident ticket it populates the below information
//need a replacement for specification when setting group instead of set value
  try {
            if (g_form.getValue(problem_subcategory) == '<sub cat name>') {
                g_form.setValue(assignment_group, '<group sys_id>'); //Provide sys_id of the group here.

            }
        } catch (err) {
            g_form.addErrorMessage("A runtime error occured: 2 " + err);
        }

Hope this helps.

Yamlet8
Giga Expert

I will give this a try, thanks for the help.

no luck, I am not seeing the setvalue results in the incident record after record producer submission, i will make additions to the list of categories and subcategories in the system definition table and add assignment rules or business rules.

Hello, Are you using record producer? If yes you can do it from record producer script which is server side code rather than client script. Also Best Practice do not use glide record in client script.

Record Producer script:

//get subCategory Value

if(producer.problem_subcategory) == '<sub cat name>') {
current.assignment_group = "grp sysID"; // set group on incident table

}

Regards
Harish