Users should not be able to approve their own requests
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 02:20 AM
Hello Team,
Can anyone suggest how to achieve this requirement?
If the approver = created by user(Requested for) then they should not be able to approve the request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 10:23 AM
Hi @nameisnani
For which table you want to write this?
Is it request item or for every table in SN?
Can you please elaborate more?
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 10:55 AM
Hi there @nameisnani
you can use a Business Rule
- Go to System Definition > Business Rules and click on New to create a new Business Rule.
Configure the Business Rule:
if (current.approver == current.requested_for) {
gs.addErrorMessage("You cannot approve your own request.");
current.setAbortAction(true);
}
\This Business Rule runs before the approval is inserted or updated. It checks if the approver is the same as the requested_for user.
If this helps kindly accept the answer thanks much.
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 11:02 AM - edited 05-27-2024 11:03 AM
Hi @nameisnani ,
I tried your problem in my PDI and it works for me
Please create before business rule and add below code
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(current.approver == gs.getUserID()){
if(current.state.changes()){
gs.log("Here");
gs.addErrorMessage("You can nhot approve your request")
current.setAbortAction(true);
}
}
})(current, previous);
Result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak