Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

execute schedule import through business rule

ram11vrnr
Tera Contributor

Hi,

I have created an UI action where it will attach a file in a datasource.  I have created a schedule import as well. 

Now i want to execute the schedule import whenever attachment added in the particular datasource.

 

I have created an Business rule in sys_attachment table and condition mentioned is

 

Tablename is sys_data_source

tablesyid  is " Sysid"

code mentioned is 

(function executeRule(current, previous /*null when async*/ ) {

var rec = new GlideRecord('scheduled_import_set');
rec.get('name', 'upload attachment');
if (typeof SncTriggerSynchronizer != 'undefined')
gs.executeNow(rec);
else
Packages.com.snc.automation.TriggerSynchronizer.executeNow(rec);

})(current, previous);

 

Now i'm getting message like:

Remove Package calls from script

Impact : 4


: Replace the Package call with the appropriate GlideScriptable class.

 

Please let me know how to execute schedule import through Business rule.

 

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

@ram11vrnr please try gs.executeNow(rec) in scope application.

Hope this will help you.

View solution in original post

4 REPLIES 4

Community Alums
Not applicable

@ram11vrnr Try below if it works for you,

Drop all of the prefix terms, leaving only the last. For example,  Packages.com.snc.automation.TriggerSynchronizer.executeNow becomes TriggerSynchronizer.executeNow

 

For more details refer : Package 

Hi Abhay,

Thanks for the update. I'm getting an error message when i'm trying to add attachment. Please let me know how to fix this,

 

SncTriggerSynchronizer is not allowed in scoped applications

Community Alums
Not applicable

@ram11vrnr please try gs.executeNow(rec) in scope application.

Hope this will help you.

Md Saquib Ansar
Giga Guru

Hi @ram11vrnr 

Try this

var importGr = new GlideRecord('scheduled_import_set');
if (importGr.get(ImportSetSysID) {

gs.executeNow(importGr);
}