Dot walking not works for dependant fields ?

bourhoud
Kilo Expert

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 ?

10 REPLIES 10

oharel
Kilo Sage

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


Hi Harel,



Thanks for your help.



Here's the two fields :


Fields.png


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 :


dependant field.png



Here's one of my choices configured on my list :


choice.png



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.


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);


  }


}


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 ?