- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2017 10:41 AM
We have a custom application named "Desktop Services". Within that, we have a table named "Desktop Services Table", which is an extension of the Task table.
To the "State" field, we added a custom choice option of "Never Hired". I would like to add a Business Rule that does the following:
When the State field is set to "Never Hired", the following changes should happen to the User record that this Desktop Services task is for:
- Update the Term Date field (u_term_date) to match the value in the Last Hire Date field (u_hire_date)
- Uncheck the "active" checkbox
- Check the "term ticket generated" (u_term_ticket_generated) checkbox
I know how to set the Business Rule to run on the update of the State field in the "Desktop Services" table, but I am unsure how to write the Business Rules script that would then make these three updates to the corresponding User record.
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 10:28 AM
Here you go
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id',current.<user sys id>);// or get user sys_id from desktop service task table
usr.query();
while(usr.next()){
usr.u_term_date = usr.u_hire_date;
usr.active = "false";
usr.u_term_ticket_generated = "true";// provided this is Boolean column
usr.update();
}
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2018 07:44 PM
Can you please mark my answer as correct so that others can benefit?
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 05:19 AM
I really do not want to accept that one because of the error in your code. As I mentioned in my previous post, if you re-post your solution with the correction to the typo so that your code is correct, I would be happy to accept that as the correct answer.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 09:47 AM
Please see corrected code below
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id',current.<user sys id>);// or get user sys_id from desktop service task table
usr.query();
while(usr.next()){
usr.u_term_date = user.u_hire_date;
usr.active = "false";
usr.u_term_ticket_generated = "true";// provided this is Boolean column
usr.update();
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 10:05 AM
Still one typo. Can you fix it?
usr.u_term_date = user.u_hire_date;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 10:28 AM
Here you go
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id',current.<user sys id>);// or get user sys_id from desktop service task table
usr.query();
while(usr.next()){
usr.u_term_date = usr.u_hire_date;
usr.active = "false";
usr.u_term_ticket_generated = "true";// provided this is Boolean column
usr.update();
}
Regards,
Sachin