Issue with the Business rule not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 12:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 12:58 AM
Hi @Pooja Khatri ,
The issue is because of this line. if you are using logical "||" then you need to consider grouping the conditions using "()" brackets. Also, you dont need to use the array for this operation instead you can use a boolean variable with true or false.
if(current.sysapproval.requested_by.sys_id == current.approver.sys_id || current.sysapproval.assigned_to.sys_id == current.approver.sys_id && mbr =='' && mbr2 =='')
If the above line is not an issue as per your requirement, I would like to understand below points.
1. what is the table name for this "Change Request Approval.AG" ?
2. Is it because of the hard coded group sys_id. Are you trying with the same group and user record is part of this group?
Otherwise, we can re-write the code like this.
var changeRequest = new GlideRecord('change_request');
if (changeRequest.get(current.sysapproval.getRefRecord())) {
var changeGroup = changeRequest.assignment_group;
var approver = current.approver;
var approverUser = new GlideUser(approver);
if (approverUser.isMemberOf(changeGroup)) {
gs.addErrorMessage("Approver is part of the assignment group of the change request."); //you can do your approval record update here.
}
}
Please let me know, if you have further questions. Feel free to ask.
Thank you.
Regards,
Karunakaran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 01:07 AM
Hi @Karunakaran - the code which I have mentioned is correct , for line (current.sysapproval.requested_by.sys_id == current.approver.sys_id || current.sysapproval.assigned_to.sys_id == current.approver.sys_id && mbr =='' && mbr2 =='')
the part of code : current.sysapproval.requested_by.sys_id == current.approver.sys_id || current.sysapproval.assigned_to.sys_id == current.approver.sys_id this is checking if the member is apart of first two level of approvals and it is making it as not required in that part
I need to fix the part where mbr =='' && mbr2 =='' this is allowing the requested by or assigned to approve its own change in the third approval from the Change Request.AG approval and fourth one from Change Request Approval.AG approval .
I need to make changes to the existing code , I cannot change the entire logic of the code .. I just need to make sure that the requested by/ assigned to cannot approve their own changes in the third and fourth level of approvals where the above sys_id's are hardcoded too .
I need to fix the code with the existing code , can you please help me to fix it .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 01:24 AM
Hi again,
Okay. I think you need to debug the code to understand its behavior. Please write the logs in each loop with its value to understand your code.
You can use gs.info with all the possible variable values in each loop.
Please let me know.
Regards,
Karunakaran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 01:34 AM
Hi @Karunakaran - I tried with the debugging but it didnt helped much , can you help me in fixing it ?