Dot walk field

brendanwilson84
Kilo Guru

Hi guys

I have a reference table were I am for walking other field within the table.

I have one field called confidential were if checked won't send emails and acl around it.

A requirement is to have this field be editable which is fine,kind of override it

However,   if I have it listed as confidential true in reference table,   then change it to false on main form, it updates to false in reference table, can I be able to change true false while the actual reference table stays as oringal?  

1 ACCEPTED SOLUTION

Just in case that is what you need, below is a client script to help you:


Type: onChange


field name: your event type field


Script:


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


  if (isLoading || newValue === '') {


          return;


  }



  //Type appropriate comment here, and begin script below


  if(newValue == 'eventValue') { //change this to reflect your event value


  var i = g_form.getValue('parent'); //change this to reflect your parent reference field name, which holds the sys_id to the parent record


  var rec = new GlideRecord('parent_table');//change this to reflect your parent table


  if(rec.get(i)) {


  g_form.setValue('u_confidential', rec.u_confidential); //change the first u_confidential to the name of the field on your form and the rec.u_confidential to the other field, from which you want to take the true/false value.


  }


  }


}



harel


Please mark as correct or helpful based on impact


View solution in original post

8 REPLIES 8

oharel
Kilo Sage

Hi Brendan,


If I understand you correctly, you have a field on one table which you also placed on another table.


Then the answer is no, to the best of my knowledge - because the field you placed on the second table is actually that same field from the original table.


My suggestion: create a similar field on the second table and populate it by querying the original table as needed.



harel


Please mark as correct or helpful based on impact


darius_koohmare
ServiceNow Employee
ServiceNow Employee

No, as when you dot walk you are showing the original column (field) to the user. Changing it on the dot walked is the equivalent of changing the field on the original.



Perhaps you should consider a second field on the other table, and use a business rule to sync it's value from the reference table. That way if you do change it, there is no effect to the referenced value.


brendanwilson84
Kilo Guru

Thanks guys for quick reply,



I can make same field,   business rule to new field same as dot walk field and therefore can change it?



Sounds good and no scripting!    


Yes.


If you add a field to the second table, it will be a separate field.


If you have a parent field (or some other reference field on the form) you can use the Actions tab and dot walk it in a before insert BR.


If not, it should not be a complicated script. It will depend on how you look for the record that hold the corresponding field. For instance:


(function executeRule(current, previous /*null when async*/) {


current.<my_new_field_name> = current.<some_parent>.<original_field_name>


})(current, previous);



Or something a bit more complicated, depends on your needs.


If you need help with scripting, please explain in a bit more detail how the two tables are related.



harel


Please mark as correct or helpful based on impact