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:50 AM
Hello,
Could you please add a log within the if to see whether it identifies the case?
Also, I don't see you updating any data variable(you are not using dt anywhere).
Please try and provide feedback.
Tudor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 03:56 AM
Hi ,
Please see the updated script .
I added the log and it is showing log corecttly.
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()){
gs.info("the variables sdate is -----: " + grlecase1.variables.employment_start_date);
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:19 AM
I just tried the following code in a PDI and it works like a charm:
- check the logs to see whether there are any errors
- debug all and see what ACLs/BRs are triggered
Tudor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 04:23 AM