How should I get a value from dot walking in a query of the business rule. I need to validate the value of a dot walked field in the query written in my Business Rule

Raju Singh1
Tera Expert

Hi Experts,

Please help

I have written an advance query in my business Rule for user table.

As per my requirement. If a user is a 'Full Time User' and the county code of the location is "United States of America. It should enter the if Statement.

It should query the reference location's country code. If the country code is "United States of America". It should execute if statement. Else, it should go to the else statment.

Here is my query, 

//it works fine when I only put if(current.getValue('u_emplostatus') == 'Full Time')

(function executeRule(current, previous /*null when async*/) {

var user = current.sys_id;
//gs.addInfoMessage("the user name is"+ user);
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('8ff73f67db9bcb40952dff971d961989');

if(current.getValue('u_emplostatus') == 'Full Time' && current.getValue('location.u_country_code') == 'United States of America'){
cart.setVariable(item,'o_adobe_cc',true);
cart.setVariable(item,'o_adobe_dc',true);
cart.setVariable(item,'o_ajera',true);
cart.setVariable(item,'o_arena',true);
cart.setVariable(item,'o_autodesk',true);
cart.setVariable(item,'o_bluebeam',true);
cart.setVariable(item,'o_credit_card',true);
cart.setVariable(item,'o_email',true);
cart.setVariable(item,'o_primavera',true);
cart.setVariable(item,'o_expensify',true);
cart.setVariable(item,'o_sap',true);
cart.setVariable(item,'o_webcatalog',true);
cart.setVariable(item,'o_zoom',true);
cart.setVariable(item,'o_dep_serv_pay',true);
cart.setVariable(item,'o_dep_cell_device',true);
cart.setVariable(item,'o_procore',true);
cart.setVariable(item,'o_sage',true);
cart.setVariable(item,'o_Jira',true);
cart.setVariable(item,'o_employee',user);
cart.setVariable(item,'o_location',current.location);
cart.setVariable(item,'o_termination_date',current.u_termination_date);
cart.setVariable(item,'o_manager',current.manager);
cart.setVariable(item,'o_emp_status',current.u_emplostatus);

//gs.addInfoMessage("Full Time User");
}

else {
gs.addInfoMessage("This is not a Full Time user");
cart.setVariable(item,'o_adobe_cc',true);
cart.setVariable(item,'o_adobe_dc',true);
cart.setVariable(item,'o_ajera',true);
cart.setVariable(item,'o_arena',true);
cart.setVariable(item,'o_autodesk',true);
cart.setVariable(item,'o_bluebeam',true);
cart.setVariable(item,'o_email',true);
cart.setVariable(item,'o_primavera',true);
cart.setVariable(item,'o_sap',true);
cart.setVariable(item,'o_webcatalog',true);
cart.setVariable(item,'o_zoom',true);
cart.setVariable(item,'o_procore',true);
cart.setVariable(item,'o_sage',true);
cart.setVariable(item,'o_Jira',true);
cart.setVariable(item,'o_employee',user);
cart.setVariable(item,'o_location',current.location);
cart.setVariable(item,'o_termination_date',current.u_termination_date);
cart.setVariable(item,'o_manager',current.manager);
cart.setVariable(item,'o_emp_status',current.u_emplostatus);
}

var rc = cart.placeOrder();
gs.addInfoMessage(rc.number);
//}
//else{
//gs.addInfoMessage("This is not a Full Time user");
//}

})(current, previous);

 

Here are the screen shots.

find_real_file.png

1 ACCEPTED SOLUTION

Munender Singh
Mega Sage

Hi,

You have to make a slight change in your condition:

if(current.getValue('u_emplostatus') == 'Full Time' && current.getValue('location.u_country_code') == 'United States of America'

 

i.e. if(current.u_emplostatus.getDisplayValue() == 'Full Time' && current.location.u_country_code.getDisplayValue() == 'United States of America')

 

Regards,

Munender

View solution in original post

2 REPLIES 2

Munender Singh
Mega Sage

Hi,

You have to make a slight change in your condition:

if(current.getValue('u_emplostatus') == 'Full Time' && current.getValue('location.u_country_code') == 'United States of America'

 

i.e. if(current.u_emplostatus.getDisplayValue() == 'Full Time' && current.location.u_country_code.getDisplayValue() == 'United States of America')

 

Regards,

Munender

Raju Singh1
Tera Expert

Hi Munender,

Thank you very much!!

 

It worked!! 🙂

 

Regards,

Raju Singh