- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 06:29 AM
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.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 07:14 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 07:14 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2018 03:59 AM
Hi Munender,
Thank you very much!!
It worked!! 🙂
Regards,
Raju Singh