Scheduled Import Not working when triggering from BR

shrikant Kahar1
Tera Contributor

Hello Team,

 

I'm facing issue while scheduled import triggering from BR in Global Application.

BR Table : sc_req_item

BR Condition: After Insert

Please find the Business Rule Script Below

 

(function executeRule(current, previous /*null when async*/ ) {
    var attachment = new GlideSysAttachment();
    var attached = attachment.copy('sc_req_item', current.sys_id, 'sys_data_source', '430167151bbca61064e5ed73b24bcb27'); //datasource sysid
    if (attached) {
        gs.info('Attachment copied from: ' + current.number);
        var grImp = new GlideRecord("scheduled_import_set");
        if (grImp.get('f12f0225c3f86a1016f64bcd2b013174')) {
            gs.info('import loaded');
            //schedule data import sysid
            gs.executeNow(grImp);
        }
    }
})(current, previous);
 
Thanks in advanced
Shrikant
11 REPLIES 11

Hello @Ankur Bawiskar ,

 

I tried but It's Not working.

 

Thanks

Shrikant

@shrikant Kahar1 

please share the details for question asked earlier

BR is running on which table and what's your actual requirement?

what debugging did you perform?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hello @Ankur Bawiskar ,

 

BR is running on which table and what's your actual requirement?: 

Table is (requested Item

BR condition: After Insert

Requirement: I'm attaching attachment on catalog item and then copying that Attachment to Data source and then performing Transform on (server) table.

 

what debugging did you perform? I'm using log and checking the import set creation.

 

It's working fine for update but for insert its not working

 

Thanks

@shrikant Kahar1 

Since it's on insert of RITM, I still believe by the time the scheduled import triggers the file is not yet copied to data source and hence it's not working with insert and it works with update

You said it gets inserted with Loaded state?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Robert H
Mega Sage

Hello @shrikant Kahar1 ,

 

gs.executeNow() only works if the Scheduled Import is in the same application scope as your Business Rule.

If that is not the case you can try the following:

SncTriggerSynchronizer.executeNow(grImp);

 

Regards,

Robert