Script Action is not working
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2023 03:12 AM
I have an event triggered from UI action followed by script action, but the script action code is not working.
event and script action both is getting triggered but the script action code is not working. Please find the code below:
Script Action:
var sourceSite = event.parm1;
var destinationSite = event.parm2;
importAll(sourceSite,destinationSite);
function importAll(sourceSite,destinationSite){
var targetTable = new GlideRecord('x_amspi_smdrs_app_olas');
targetTable.addQuery('site',current.source_site);
targetTable.query();
while (targetTable.next()) {
gs.info('Inside the script action second');
var targetTable1 = new GlideRecord('x_amspi_smdrs_app_olas');
targetTable1.addQuery('ola_name', targetTable.ola_name);
targetTable1.addQuery('frequency_ola', targetTable.frequency_ola);
targetTable1.addQuery('function_ola', targetTable.function_ola);
targetTable1.addQuery('sub_function_ola', targetTable.sub_function_ola);
targetTable1.addQuery('formula_ola', targetTable.formula_ola);
targetTable1.addQuery('ola_type', targetTable.ola_type);
// targetTable1.addQuery('status', targetTable.status);
targetTable1.addQuery('role', targetTable.role);
// targetTable1.addQuery('artefacts', targetTable.artefacts);
targetTable1.addQuery('site',current.destination_site);
targetTable1.query();
if (targetTable1.next()) {
gs.info('Inside the script action third');
gs.addErrorMessage('Record already exists in ola table: ' + targetTable1.ola_name);
} else {
gs.info('Inside the script action fourth');
targetTable1.initialize();
targetTable1.ola_name = targetTable.ola_name;
targetTable1.frequency_ola = targetTable.frequency_ola;
targetTable1.function_ola = targetTable.function_ola;
targetTable1.sub_function_ola = targetTable.sub_function_ola;
targetTable1.formula_ola = targetTable.formula_ola;
targetTable1.ola_type = targetTable.ola_type;
targetTable1.status = targetTable.status;
targetTable1.role = targetTable.role;
targetTable1.artefacts = targetTable.artefacts;
targetTable1.site = current.destination_site;
targetTable1.insert();
gs.addInfoMessage('Record Inserted Successfully');
}
}
}
UI Action :
var source = current.getValue('source_site');
var destination = current.getValue('destination_site');
gs.eventQueue("x_amspi_smdrs_app.smdrs.import", null, source, destination);
var destination = current.getValue('destination_site');
gs.eventQueue("x_amspi_smdrs_app.smdrs.import", null, source, destination);
11 REPLIES 11
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2023 04:35 AM
@Aman Kumar S Yes I am sure because I have tried that and also saw many response regarding the same

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 02:24 AM
Check again, I have tried to reproduce this in my instance, and I am able to access current object in the script action.
Best Regards
Aman Kumar
Aman Kumar