Map fields from custom table to Incident fields from workflow

booher04
Tera Guru

I'm trying to map 4 fields from a custom table to the incident table through a workflow I've created(create task activity) for a catalog item.  As I have it right now, its setting the same value in the Incident fields no matter what I choose from the catalog item form fields(issue_type and sub_type).  I think I'm missing something in my query of the custom table script.

var issueType  = current.variables.issue_type.getDisplayValue();
var subType = current.variables.sub_type.getDisplayValue();

var grIncAssgnt = new GlideRecord('u_loancare_incident_assignment');
grIncAssgnt.addQuery('issueType', 'u_issue_type');
grIncAssgnt.addQuery('subType', 'u_sub_type');
grIncAssgnt.query();

if (grIncAssgnt.next()) {

	task.assignment_group = grIncAssgnt.u_assignment_group;
	task.category = grIncAssgnt.u_category;
	task.subcategory = grIncAssgnt.u_subcategory;
	task.business_service =	grIncAssgnt.u_business_service;
}

It's setting the same assignment group, category, subcategory, and business service no matter what I choose in the issue_type and sub_type lookup select box variables on the catalog item. The values are being set to the first record in my list every time.  The name of the fields on the custom table are correct(u_issue_type, u_sub_type, u_assignment_group, u_category, u_subcategory, u_business_service).  I've also attached a screenshot of the record.

1 ACCEPTED SOLUTION

Abhijit4
Mega Sage

Your script looks wrong at some places(variable name should not be written in quotes), please use below script .

var issueType  = current.variables.issue_type.getDisplayValue();
var subType = current.variables.sub_type.getDisplayValue();

var grIncAssgnt = new GlideRecord('u_loancare_incident_assignment');
grIncAssgnt.addQuery('u_issue_type',issueType);// made required change here
grIncAssgnt.addQuery('u_sub_type',subType );// made required change here
grIncAssgnt.query();

if (grIncAssgnt.next()) {

	task.assignment_group = grIncAssgnt.u_assignment_group;
	task.category = grIncAssgnt.u_category;
	task.subcategory = grIncAssgnt.u_subcategory;
	task.business_service =	grIncAssgnt.u_business_service;
}

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Regards,
Abhijit
Community Rising Star 2022

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

View solution in original post

1 REPLY 1

Abhijit4
Mega Sage

Your script looks wrong at some places(variable name should not be written in quotes), please use below script .

var issueType  = current.variables.issue_type.getDisplayValue();
var subType = current.variables.sub_type.getDisplayValue();

var grIncAssgnt = new GlideRecord('u_loancare_incident_assignment');
grIncAssgnt.addQuery('u_issue_type',issueType);// made required change here
grIncAssgnt.addQuery('u_sub_type',subType );// made required change here
grIncAssgnt.query();

if (grIncAssgnt.next()) {

	task.assignment_group = grIncAssgnt.u_assignment_group;
	task.category = grIncAssgnt.u_category;
	task.subcategory = grIncAssgnt.u_subcategory;
	task.business_service =	grIncAssgnt.u_business_service;
}

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Regards,
Abhijit
Community Rising Star 2022

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP