How can we map the sc task to specific assignmnet group pick the data from cutom table?

raj99918
Tera Contributor

Hi,

 

I have requirement like after the submitting the catalog form it should create a SC task and map to specific group which mentioned in the one of the cutom table called "u_new_table" (Columns like Assignment group, Region, Company and Location) example: If users location on the form is "India" then it should map to group called "Group1" and this record has been creeated in the custom table u_new_table but How can I map this automatically from script include please help me with the script.

 

Thanks

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@raj99918 

are you using workflow or flow to create the catalog task?

You can lookup on that custom table and bring the group and then set it on Catalog task.

Should be an easy solution. where are you stuck?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar We are using the Flow for this sc mapping and in that calling the script include function here to get this mapping but in that script include I need help how to get the location field value (Example India) of this custom table to get this mapping 

@raj99918 

when you set the field value for Assignment group you can use the inline script and call the script include and handle the logic

what did you try so far share screenshots and what debugging you did?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar  below is my script include:

 

MappingAG: function(regionparam, country, location, company, task, configtype) {
        gs.log("Smith0 :");
 
        var configloc = '';
        var grLocname = new GlideRecord('cmn_location');
        if (grLocname.get(location)) {
 
            location = grLocname.name.toLowerCase();
            var countryLower = grLocname.country.toLowerCase();
            var countryexact = grLocname.country;
 
            gs.log("Smith1 :" + location);
            gs.log("Smith1.1 :" + countryLower);
gs.log("Smith14351 sys_id: " + locationsys_id);
gs.log("Smith14351 name: " + locationname);
 
        }
        var grLocationkey = new GlideRecord('u_new_table');
        grLocationkey.addActiveQuery();
        grLocationkey.addQuery('u_c_t', 'Loca k');
        grLocationkey.query();
        while (grLocationkey.next()) {
 
 
            if (location.indexOf(grLocationkey.u_location.toLowerCase()) >= 0 || countryLower.indexOf(grLocationkey.u_location.toLowerCase()) >= 0) {
 
 
                configloc = grLocationkey.u_location;
            
 
                break;
            }
        }
        
 
        if (regionparam != '') {
 
            gs.log("Smith5 formparameter :" + regionparam);
            region = regionparam;
            gs.log("Smith60 region mapped to parm :" + region);
 
        }
 
else{
 
            gs.log("Smith6 :");
            var region = '';
            var grCountryregion = new GlideRecord('u_new_table');
            grCountryregion.addActiveQuery();
            grCountryregion.addQuery('u_c_t'', 'C Region');
            grCountryregion.addQuery('u_country', country);
            grCountryregion.query();
            if (grCountryregion.next()) {
 
                region = grCountryregion.u_region;
 
                gs.log("Smith7 table region :" + region);
 
            }
}
        }
 
      var grConfig = new GlideRecord("u_new_table");
        grConfig.addQuery('u_catalog_item', 'test form');
 
 
if ((company == 'ABC'|| company == 'PQR') && configtype == 'Task' && ((locationname1 == 'India')  {
 
    gs.log("Smith61:" + locationname1);
    gs.log("Smith9");
grConfig.addEncodedQuery('u_locationINIndia');
 
 
}
 
 if ((company == 'ABC' || (company == 'PQR' && regionparam != '')) && configtype == 'Task') {
gs.log("Smith91: ");
 
if(configloc != 'India'){
 
gs.log("Smith90907: ");
 
   grConfig.addQuery("u_region", region);
  
}
 
}
 
 
 
grConfig.addQuery('u_c_t', configtype);
        grConfig.addQuery("u_company", company);
        grConfig.addQuery("u_catalog_task", task);
        grConfig.addActiveQuery();
        grConfig.query();
        if (grConfig.next()) {
 
            var grp = grConfig.u_assignment_group;
             return grConfig.u_assignment_group.toString();
 
        }
    },

Here my main query is How can I get that location from that catalog form to this script include so that I can use that condition