The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Unable to update Variable value in the Business rule

Mrman
Tera Guru

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();
}

@Ankur Bawiskar 

14 REPLIES 14

Mohith Devatte
Tera Sage
Tera Sage

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

@Mohith Devatte  This is not working as the employment_start_date is not a direct field in the form, it is the record producer variable showing on the case.

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

I tried this but still not working.

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