Importing closed request records in .csv into SN requests/ritms

Mike Foreman
Tera Contributor

I have a .csv file from a legacy system that needs to be loaded into SN as requested items. The records in the file are all closed and want to maintain the dates and assignment values. 

I know I can create a BR to map variable values to cart fields but I need to also populate some of those back end fields like date create, assigned_to, closed date, etc. Is the best way to proceed to use a transform map from the import table into a catalog item? or is it better to use a record producer to map all of the fields into a sc_req_item? The concern that I have with that is that although I may get all the legacy data into the RITM i'm not sure how to create a corresponding parent REQ.

 

Any ideas on the best way to bring closed records from a legacy system into SN?

1 ACCEPTED SOLUTION

Slava Savitsky
Giga Sage

We accomplished this for some of our customers in the past by using an import set and transform map to import data into [sc_req_item] table. In the transform map, we added an onAfter script with the following code to create a parent REQ record:

 

if (action == 'insert') {
	var req = new GlideRecord('sc_request');
	req.initialize();
	req.requested_for = target.requested_for;
	target.request = req.insert();
	target.setWorkflow(false);
	target.autoSysFields(false);
	target.update();
}

 

 

View solution in original post

4 REPLIES 4

Slava Savitsky
Giga Sage

We accomplished this for some of our customers in the past by using an import set and transform map to import data into [sc_req_item] table. In the transform map, we added an onAfter script with the following code to create a parent REQ record:

 

if (action == 'insert') {
	var req = new GlideRecord('sc_request');
	req.initialize();
	req.requested_for = target.requested_for;
	target.request = req.insert();
	target.setWorkflow(false);
	target.autoSysFields(false);
	target.update();
}

 

 

Works great - thank you. I'm wondering if I need to make an adjustment to the script, however. I will be running this import repeatedly in DEV to get the import values right. I don't want to create a new REQ each time i reprocess the RITM import. Is there a way to check to see if the RITM already has a parent REQ?

Because of the if (action == 'insert') condition, a REQ record will only be created when a new RITM record is inserted. If your import updates a RITM record that is already present in the system, that condition will not be satisfied, so no new REQ will be generated in that case.

oh, man - that was a brain cramp! you're right; it's the first line of the script😅 thank you for clarifying that!