Quesion in Business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2024 03:17 AM
Hello,
How to lock the user Account using business rule script, kinldy Advise.
Thanks
Srini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2024 03:32 AM
Hi @Srini19,
Can you expand on what you mean by 'lock the user account' please and advise the use case?
Are you wanting to make the field read-only and only editable by some users - example Admins only or certain group members for example?
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2024 03:32 AM
Hi,
What do you mean exactly, do you want to set a value on a user account through business rule ?
If so, then it's quite easy.
Example below:
var userGR = new GlideRecord('sys_user');
var userID = 'define the specific user you want to update, it should be a sys ID';
if (userGR.get(userID)){
userGR.setValue('locked_out', true);
userGR.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2024 03:35 AM
hi @Srini19
If you want to deactivate the user then have a look bellow script in your BR (before/after)
// Example condition: Lock account if the user's status is set to 'Inactive'
if (current.active) { // Check if the user is currently active
current.active = false; // Lock the account
current.comments = "Account locked by Business Rule"; // Optional comment
}
i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
rajesh