Dot walking not works for dependant fields ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 06:39 AM
Hi all,
Working on a Helsinki instance.
I have an issue on dependant field, set on a choice list :
My choice list is a custom field on alm_hardware, which contains status. These status depends on the type of another OOB reference field, stockroom.
Let's be more concrete :
If I select a stockroom which has type "Central Warehouse", my list of values contains several status.
If I select another stockroom, with another type, my list of values changes for anothers status, specific for this type of stockroom.
To do this, I set the following :
- Check dependent field to be true
- dependent on field : stockroom type
- specifies a dependant value for one of my choices, with the sys_id of central warehouse type
My tests go wrong, my choice never appears, even if I select a central warehouse stock room.
If I do the same, by specifying my choice list directly dependant on a stockroom (without dot walking), it works...
Does anyone know where I'm wrong ? Is it a known issue in Service Now ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 07:10 AM
Hi Pierre,
I am not sure what is not working.
Can you add a screenshot of your fields? and specify what's not populating and when?
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 07:25 AM
Hi Harel,
Thanks for your help.
Here's the two fields :
The stock room is a reference field to stockrooms (OOB).
The stock status, below, is dependant on selected stockroom type. If I select a stockroom with "central warehouse" type, I have specific stock status. If I select another stockroom, I want to have other stock status populated.
Here's the configuration on dictionnary of my stock status field :
Here's one of my choices configured on my list :
The value set on dependant value is the sys_id of the central warehouse type.
As I said, with all of this, if I select a stock room which has the central warehouse type, my stock status "ACTIF" does not appear.
I've made the test with a dependance on a stockroom, directly (without dot walking to type), and specified the stockroom sys id as a dependant value for my "ACTIF" status, and it works.
Hope it's clearer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 08:50 AM
Yes, it is.
You will need a client script to do that, which checks the type of the type of the stockroom and then adds the relevant option.
If you want to avoid that, I suggest the following:
1. Add a reference field to the page called type. Reference it to stockroom type alm_stockroom_type. You can make it read only and/or hide it using a ui policy if needed.
2. Add the following onChange client script:
Type: onChange
Field name: u_stockroom --> your stockroom field name on the form
Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var stockroom = g_form.getValue('u_stockroom'); //This is your stockroom field on the page
var stockType = new GlideRecord('alm_stockroom'); //this is to query the stockroom table
stockType.addQuery('sys_id', stockroom); //to find the sys_id of the stockroom in the stockroom field on the table
stockType.query();
if(stockType.next()) {
g_form.setValue('u_type', stockType.type); //set the type field that you created earlier with the type field from the stockroom
}
}
3. Populate the choice list "stock status" with the sys_id of the stockroom type.
harel
Please mark as correct or helpful based on impact
Edit:
a shorter script, for fun:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var stockroom = g_form.getValue('u_stockroom');
var stockType = new GlideRecord('alm_stockroom');
if(stockType.get(stockroom)) {
g_form.setValue('u_type', stockType.type);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 12:55 AM
Hi Harel,
Thanks again for your help.
I wanted to avoid using client script, also. Except if I haven't got any others choices.
Do you know if it is a known Service now issue ? Have you, or anyone else, already been exposed to this issue ?