- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 05:46 AM
condition = current.table_name == "incident"
When to run : After Insert/Update
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord("incident");
gr.addQuery("sys_id", current.table_sys_id);
gr.query();
gs.log("===>record exists", gr.next());
while(gr.next()) {
gs.log("===>record glide", gr);
//fi = gr.getElement('isAttachmentUpdated');
gr.setValue('isAttachmentUpdated', 'Updated'); //custom field isAttachmentUpdated
gr.update();
}
// Add your code here
})(current, previous);
Note: I'm able to receive the "record exists" debug as "true" but not able to get the log inside while loop. Please help me understand what is the issue fix as the custom field (isAttachmentUpdated) on incident is also not getting updated.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2020 11:00 PM
Hello
If this has answered your question, kindly mark the comment as a correct answer so that the question is moved to solved list.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 05:47 AM
double check the field name it might be u_isattachmentppdated
also change
gs.log("===>record glide", gr);
to
gs.print("===>record glide", gr.number);
var gr = new GlideRecord("incident");
gr.addQuery("sys_id", current.table_sys_id);
gr.query();
if (gr.next()) {
gs.print("===>record glide", gr.number);
gr.setValue('isAttachmentUpdated', 'Updated'); //custom field isAttachmentUpdated
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 05:53 AM
We can not use gs.log() in scoped applications, We can use gs.info() , gs.warn() ,gs.error(), gs.debug() in scoped applications for logging at different levels.
The reason why gs.log() cannot be used for logging in scoped applications is it is restricted to the global scope and not accessible from a private scope. When you are in a scoped application , your scope is bound in private to that application but gs.log() has been restricted to be accessible only at a global level kind of public but not at a private application level
You can use alternate logging methods for using in scoped applications and that doesnot make much difference
Log level | Description
error (gs.error) | Logs events that might still allow the application to continue running. Setting the log level for an application to error generates error messages only, but does not generate warn, info, or debug messages.
warn (gs.warn) | Logs potentially harmful events. Setting the log level for an application to warn generates error and warn messages, but does not generate info or debug messages.
info (gs.info) | Logs informational messages that describe the progress of the application. Setting the log level for an application to info generates info, warn, and error messages, but does not generate debug messages.
debug (gs.debug) | Logs informational events that are useful for debugging an application. Setting the log level for an application to debug generates info, warn, error, and debug messages.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 05:53 AM
Hi
you are using gr.next() twice bcoz of which the issue might be. Check like this.
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord("incident");
gr.addQuery("sys_id", current.table_sys_id);
gr.query();
// gs.log("===>record exists", gr.next());
while(gr.next()) {
gs.log("===>record glide", gr);
//fi = gr.getElement('isAttachmentUpdated');
gr.setValue('isAttachmentUpdated', 'Updated'); //custom field isAttachmentUpdated
gr.update();
}
// Add your code here
})(current, previous);
Mark the comment as a correct answer and helpful if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 05:55 AM
Also use gs.info if you are in scoped application and cross verify the column name. if its custom column, check if its starting with u_.