Coping an attachment from RITM to Data source
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-28-2018 06:05 AM
Hi Folks ,
I have a requirement like ----> When a user uploads attachment from catalog form with asset details . I have fetch the data and add the information to asset table . I followed below steps
1. Create a data source for that attachment --> Created a data source
2. Load data using related link --> 1st time i loaded data manually
3. Create Transform map and field mappings. --> Done with transform map and field mappings
4. Create a scheduled import of type 'On Demand' --> Created one scheduled import for the data source which we created earlier in step 1 . But the attachment which was uploaded by user via catalog form is not attaching to data source . Below is the BR which I wrote to copy the attachment automatically to data source by using scheduled import .
Table : sys_attachment
When to run : After insert
Script :
(function executeRule(current, previous /*null when async*/) {
gs.info("===== BR running =====");
var rec = new GlideRecord('scheduled_import_set');
rec.get('name', 'Scheduled Data Import for this data source');
SncTriggerSynchronizer.executeNow(rec);
})(current, previous);
Please let me know where exactly I am mistaken , Thanks in advance .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-28-2018 06:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-28-2018 06:18 AM
Thanks Saikiran for sharing the info , But I already saw these post but didnt worked for me . š

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-28-2018 06:31 AM
Hi,
1) Have business rule after insert on RITM table which runs only for that particular CatalogItem.
2) Have a data source, transform map and field map created as usual. coalesce etc will bepresent
3) Have scheduled import created with this data source with active= false, run as administratorsince it will be triggered from script. In left nav type Scheduled Imports and create new
4) in the business rule condition check whether the RITM has attachment then only run the business rule and have following script
Business rule condition:
current.hasAttachments()
//extra check you can have is whether it is csv or xls based on data source attachment file typeBusiness rule
script:
var dataSourceSysId = ''; // sys_id of the data source you created in step 2
var schImp_GR = new GlideRecord('scheduled_import_set');
schImp_GR.addQuery('data_source',dataSourceSysId);
schImp_GR.query();
if(schImp_GR.next()){
gs.executeNow(schImp_GR);
// use this if it is in scoped app //SncTriggerSynchronizer.executeNow(schImp_GR);
// if in non-scope app i.e. global// the above 2 lines will start the import process, etc automatically
}
Thanks,
Saikiran Guduri (NOW)
Associate Certificate Engineer | ServiceNow Store Apps
(Please mark the answer as correct answer/helpful/accept the solution if it helps)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-28-2018 06:34 AM
If you are not developing any scoped app use this :
gs.executeNow(schImp_GR);
in place of
SncTriggerSynchronizer.executeNow(schImp_GR);