Script Action is not working
- 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 destination = current.getValue('destination_site');
gs.eventQueue("x_amspi_smdrs_app.smdrs.import", null, source, destination);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2023 03:18 AM
Hello
I think you have used current in your script action function importAll().
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',sourceSite);
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',destinationSite);
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 = destinationSite;
targetTable1.insert();
gs.addInfoMessage('Record Inserted Successfully');
}
}
}
try above, I have removed current and used paramter values directly.
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2023 03:20 AM
@sushantmalsure I tried with parameter values also but still it is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2023 03:32 AM
when you say its not working then what does that mean?
Can you put more logs at multiple places to see execution length and post it here ?
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2023 03:39 AM - edited 05-17-2023 03:40 AM
@sushantmalsure I have given multiple logs. info messages and error messages. find the code below:
The only log I am getting is - Inside the script action second.
By not working what I mean is that if record already exist then I have given a error message which it should show and if doesn't exist then it should show message as record inserted successfully.