- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 11:34 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 03:41 PM - edited 06-14-2024 03:42 PM
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();
}
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 03:41 PM - edited 06-14-2024 03:42 PM
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();
}
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 02:12 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 03:44 PM - edited 07-08-2024 03:44 PM
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.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 04:23 PM
oh, man - that was a brain cramp! you're right; it's the first line of the script😅 thank you for clarifying that!