- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 10:49 AM
So, we need to add a few new options to the State field in the Requested Items (sc_req_item) table. However, we ONLY want these options to appear for Requested Items where the cat_item field is equal to "Telecom Request". I thought we could use Dependent values to get this to work, but I cannot figure out how to make it work. I have searched around and looked at past articles and videos, but most seem to address old versions of ServiceNow (we are on Helsinki).
I can see how to add the Dependent Value to each choice, but I do not see how to actually make the field itself Dependent on another field (if understand it correctly, there are two parts:
1. What field is it dependent on? This would be the "cat_item" field.
2. What value is it dependent on? The would be "Telecom Request".
So, where/how do I set that first part?
Or am I going about this wrong and need to take a different approach?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 12:09 PM
You can write an Display Business Rule to get the current Catalog Item, instead of using sys_id in Client Script. Please find the details below:
1) Configure On Display Business Rule on Requested Item Table as shown below:
2) Modify your client script as below:
Hope this helps. Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 11:31 AM
Hi,
You can write an On Load Client Script on Requested Item table as below:
function onLoad() {
//Type appropriate comment here, and begin script below
var request = g_form.getValue('cat_item');
if(request == 'ff70f4f0db017a00eb7fd740cf961917') // sys_id of the Catalog Item for which you want the new Choice
{
g_form.addOption('state','6','choice1');
}
}
Below is the syntax for add option:
g_form.addOption(fieldName, choiceValue, choiceLabel)
Hope this helps. Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 11:50 AM
I don't think I can hard code sys_id fields, because this code will need to be copied/pushed to other environments, so it needs to be more dynamic than that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 12:09 PM
You can write an Display Business Rule to get the current Catalog Item, instead of using sys_id in Client Script. Please find the details below:
1) Configure On Display Business Rule on Requested Item Table as shown below:
2) Modify your client script as below:
Hope this helps. Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2017 12:25 PM
Hmm... Doesn't seem to be working. Do I need to set any values on the "When to Run" tab of the Business Rule?
Here is my exact script. Just to test, I commented everything out except for the two "g_form.addOption" statements, and confirmed that works. Just cannot get it to work on the condition.
Seems a little odd to me that we can call "cat" out of the blue with no reference.