Unable to update Variable value in the Business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 03:45 AM
Hi All,
I have one after BR where i have need to update the variable on the HR case with a new value .This variable is of type date.
I am trying the below script to update the employment start date variable, but it is not working . Please suggest
var grlecase1 = new GlideRecord('sn_hr_core_case');
grlecase1.addQuery('subject_person.email', 'Alice.Tester@testemail.com');
grlecase1.addQuery('active', 'true');
grlecase1.addQuery('hr_service', 'a83f55e487a811502413b919cebb3577');
grlecase1.setLimit(1);
grlecase1.query();
if(grlecase1.next()){
var dt = new GlideDate();
dt.setDisplayValue('2022-07-11');
grlecase1.variables.employment_start_date = dt;
grlecase1.setWorkflow(false);
grlecase1.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 03:53 AM
Hello,
can you try replacing with below code
var sdt = dt.setDisplayValue('2022-07-11');
grlecase1.employment_start_date =sdt;
please accept the solution if it answers your question
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 03:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 04:03 AM
Try to put logs inside if loop to check whether its going inside loop or not .If the log is not coming then there must be an issue with one of your add query
1) Check if there is a user record with that email id or better try to query with subject person sys_id
grlecase1.addQuery('subject_person', 'sys_id of subject person record');
2)check if its in active state
3) Check if that HR service is present or not in the HR service table
and also replace script with below code
var sdt = dt.setDisplayValue('2022-07-11');
grlecase1.variables.employment_start_date =sdt;
can you please try this and mark helpful it it solves
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 04:07 AM
I tried this but still not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 04:15 AM
I think you cannot update the variables through script as it is coming from MTOM table
can you copy the HR case sys id and go to sc_item_option_mtom table and search withe HR case sys_id in dependant item field and let me know if you find any matching records