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 04:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 04:23 AM
Can you attach the screenshot in attachments i am not able to see the image
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 04:24 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 03:56 AM
Tried in instance by commenting few lines works well
var grlecase1 = new GlideRecord('sn_hr_core_case');
//grlecase1.addQuery('subject_person.email', 'Alice.Tester@testemail.com');
grlecase1.addQuery('sys_id', '1001e3fd07f70110f1cbf48f7c1ed0cb'); // added for testing 1 record by using sysid
//grlecase1.addQuery('hr_service', 'a83f55e487a811502413b919cebb3577');
grlecase1.setLimit(1);
grlecase1.query();
if(grlecase1.next()){
var dt = new GlideDate();
dt.setDisplayValue('2022-07-11');
grlecase1.short_description = dt;
//grlecase1.variables.employment_start_date = dt; // make sure variable name is correct
grlecase1.setWorkflow(false);
grlecase1.update();
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 05:04 AM
Hi,
BR is on which table?
BR is in which scope?
That variable is in which scope?
try this
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.setValue('2022-07-11');
grlecase1.variables.employment_start_date = dt;
grlecase1.setWorkflow(false);
grlecase1.update();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader