Need to fix the below script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 06:59 AM
Hi All ,
I have written the below part of a code in a function in a business rule , my requirement is when all the conditions written inside the function are true only then the function should be executed else it should be skipped
The code written in the function is to skip on the notification part which means :: In case all condition true then we should send notification or else we should not send notification
The below part of function is not working in my existing Business rule
How can I fix this logic in the below code :

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 07:05 AM - edited 09-21-2023 07:06 AM
Hi @Pooja Khatri,
I'm not completely sure I understand your use case, but try it like this:
function NC() {
if (current.source_table == 'change_request') {
var changeSysId = current.document_id;
var assignedto = current.approver.sys_id.toString();
var CR = new GlideRecord('change_request');
CR.addEncodedQuery("type=Normal^sys_id=" + changeSysId + "^assigned_to=" + assignedto + "^ORrequested_by=" + assignedto);
CR.setLimit(1);
CR.query();
if (CR.hasNext()) {
return false;
} else {
return true;
}
} else {
return false;
}
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.