- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 01:20 AM
I want to have updated by as system user when update transaction is happening via Business Rule.
When BR is executed it is taking user who initiated the transaction in updated by field I want to change it to system or some other user.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 01:39 AM
var currentUser = gs.getUserID(); // store currently logged in user to end the impersonation
var impUser = new GlideImpersonate();
impUser.impersonate(gs.getProperty("ib.sysAdminUserSysId")); // property holds value of system user sysid
/*
Your Code --
*/
/** end impersonation */
impUser.impersonate(currentUser);
Please mark this as solution and helpful.
Thanks
Akshay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 01:29 AM
you need to add following code in your BR:
// Store the current user
var originalUser = gs.getUserID();
// Set the session to the system user (or a specific user)
gs.getSession().impersonate('system'); // Use 'system' for the system user or replace with a specific user ID
// Perform the updates
current.short_description = "Updated by Business Rule as System User"; // Example update
current.update(); // Perform any other updates as needed
// Revert back to the original user
gs.getSession().impersonate(originalUser);
I hope my answer helps you to resolve your issue if yes, mark my answer helpful & correct.
THANK YOU
rajesh chopade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 01:39 AM
var currentUser = gs.getUserID(); // store currently logged in user to end the impersonation
var impUser = new GlideImpersonate();
impUser.impersonate(gs.getProperty("ib.sysAdminUserSysId")); // property holds value of system user sysid
/*
Your Code --
*/
/** end impersonation */
impUser.impersonate(currentUser);
Please mark this as solution and helpful.
Thanks
Akshay