Auto-import attached file on RITM using workflow script

dianemiro
Kilo Sage

Hello Everyone,

Does anyone here already done an auto-import from an attached excel file on RITM using workflow script? We are trying to build a Service Catalog Item to automatically add/update/remove locations by auto-importing user's attached excel file. Reason why we want to use RITM so that Data Management team can verify if the data on the attached file is correctly filled out. After closing the catalog task, we want to run the script to auto-import the attached excel file. Thank you in advance.

Diane.

1 ACCEPTED SOLUTION

Hi Diane,

So this is what might be happening; by the time the attachment is getting copied the code to trigger the transform map might be triggering

so either do these

1) copy the attachment in workflow run script first then wait then use run script to trigger

2) or else create after insert business rule on sys_attachment table and condition as table_sys_id is your data source sys id

have the code to trigger the transform map in that BR

var dataSourceSysId = '266fc888dbb9770013c7757a8c961954';
var schedImp = new GlideRecord('scheduled_import_set');
schedImp.addQuery('data_source',dataSourceSysId);
schedImp.query();

if(schedImp.next()){
    gs.executeNow(schedImp);
}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

11 REPLIES 11

Hi Diane,

Is the attachment getting copied properly? check this first.

Also are you executing this in scoped app?

Did you have field map so that you can map the source fields with target fields

Regards

Ankur

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

Hi Ankur,

Yes, the attachments are getting copied correctly to the data source. No, I am not using scoped app. Field maps are also created.

Regards,
Diane

Hi Diane,

So this is what might be happening; by the time the attachment is getting copied the code to trigger the transform map might be triggering

so either do these

1) copy the attachment in workflow run script first then wait then use run script to trigger

2) or else create after insert business rule on sys_attachment table and condition as table_sys_id is your data source sys id

have the code to trigger the transform map in that BR

var dataSourceSysId = '266fc888dbb9770013c7757a8c961954';
var schedImp = new GlideRecord('scheduled_import_set');
schedImp.addQuery('data_source',dataSourceSysId);
schedImp.query();

if(schedImp.next()){
    gs.executeNow(schedImp);
}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Thanks Ankur, that worked perfectly!

Hi Ankur,

Can I get the current RITM number in the transform script. 

I am creating catalog tasks based on number of rows in the attachment. So I want those catalog tasks RITM  to be the one from the worfklow.

 

Mounika