How do you map a record producers Name, Requester and Category to specific Case fields?

Daniel R2
Kilo Sage

Hi, I am working on a CSM Project and would like to map the below from when a record producer is used, directly into the fields of a case.

 

Mapping required:

1. Name (Record producer) -> Short Description (Case)

If a certain record producer is used it automatically maps to the short description of the case

 

2. Requester (Submitter) - > Internal User (Case)

The Requesters name also populates in the internal use field of the case.

 

3. Categories - > Case Type 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Hi Daniel,

You can use a script like this in the Script field on the Record Producer definition to populate these fields on the resulting Case record from data that is on the Catalog Item/Record Producer:

var rpsysid = RP.getParameterValue('sysparm_id');

var catitem = new GlideRecord('sc_cat_item');
if (catitem.get(rpsysid)) {
	current.short_description = catitem.name;
}

current.internal_user = current.opened_by;
var catArr = [];
var cats = new GlideRecord('sc_cat_item_category');
cats.addQuery('sc_cat_item', rpsysid);
cats.query();
while (cats.next()) {
	catArr.push(cats.sc_category.title);
}
current.u_case_type = catArr.join(', ');

View solution in original post

6 REPLIES 6

johnfeist
Mega Sage
Mega Sage

HI Daniel,

If you are creating the record producer via the New button on Service Catalog | Catalog Definitions |Record producers, you should see a check box in the variable definition Map to Field.  Checking that box exposes the two other fields that you need, what field and what table.  What table is read only because you need to identify the table when defining the record producer.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Brad Bowman
Kilo Patron
Kilo Patron

Hi Daniel,

You can use a script like this in the Script field on the Record Producer definition to populate these fields on the resulting Case record from data that is on the Catalog Item/Record Producer:

var rpsysid = RP.getParameterValue('sysparm_id');

var catitem = new GlideRecord('sc_cat_item');
if (catitem.get(rpsysid)) {
	current.short_description = catitem.name;
}

current.internal_user = current.opened_by;
var catArr = [];
var cats = new GlideRecord('sc_cat_item_category');
cats.addQuery('sc_cat_item', rpsysid);
cats.query();
while (cats.next()) {
	catArr.push(cats.sc_category.title);
}
current.u_case_type = catArr.join(', ');

@Brad Bowman  - This is exactly what I needed. Thanks for your help Brad, It is much appreciated!

You are welcome!