- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 12:11 PM
Hello Community,
There is a maintain item named as 'Purchase Requisition Request (IT Use Only)' with 2 variables one variable is is_this_for_software_hardware_or_labor with dropdown options as software, hardware, GBS, services and another variable(check box) is is_software_included_in_this_purchase , here if user selects hardware , GBS, services then this software included variable should get populated , I have done these in UI policies and actions and tested it its working fine . Now if user selects other than software and checked the box of software included purchase variable then it should take yes part in workflow in that way we should write logic in if condition . please help me with this
Thank you.
Solved! Go to Solution.
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 02:34 AM
Hi,
are you sure you are comparing correct value for software
Update as this
answer = ifScript(); // add this line if you have not added
function ifScript() {
if (current.variables.is_this_for_software_hardware_or_labor == 'software') {
return 'yes';
}
if (current.variables.is_this_for_software_hardware_or_labor != "software" && current.variables.is_software_included_in_this_purchase.toString() == 'true')
return 'yes';
else
return 'no';
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 12:22 PM
Hello There!
You can write like below
if(current.variables.is_this_for_software_hardware_or_labor!="Software" && (current.variables.is_software_included_in_this_purchase==true ||current.variables.is_software_included_in_this_purchase=='true' ))
{
return 'yes'
}
else
{
return 'no'
}
Please mark my answer correct if it helped you in anyway
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 08:34 PM
remember if activity always require answer variable to be set as yes or no
so update as this
answer = ifScript();
function ifScript(){
if(current.variables.is_this_for_software_hardware_or_labor != "software" && current.variables.is_software_included_in_this_purchase.toString() == 'true')
return 'yes';
else
return 'no';
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 01:04 AM
Hello Ankur ,
Even if they selects software also it should take yea part, After 1st condition in IF condition we should write the logic like if they selects other than software and checked the box of software include variable . please say the logic . Can we write like these:
Script:
function ifScript() {
if (current.variables.is_this_for_software_hardware_or_labor == 'Software') {
return 'yes';
}
if (current.variables.is_this_for_software_hardware_or_labor != "software" && current.variables.is_software_included_in_this_purchase.toString() == 'true')
return 'yes';
else
return 'no';
}
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 01:15 AM
Hello
Then you can check with only one condition because they can select any thing(software, hardware, GBS, services) so no need to check this.You can check only if the check box is true and the other variable is not empty.
function ifScript() {
if (current.variables.is_this_for_software_hardware_or_labor!=''&& current.variables.is_software_included_in_this_purchase.toString() == 'true')
return 'yes';
else
return 'no';
}