Set Default Value to field from Reference

jenn123
Kilo Contributor

Is there a way to set the default value to a dot walked field of a reference field on the same table? See example below on the Change Order table. Would like to set the "Requested for" default value to be the business contact which comes from the Project itself (referenced in Project Number). Is there any way to do this?

find_real_file.png

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hmm...If it's not working this way I would try it in a before insert business rule instead.



current.u_requested_for = current.u_project.u_business_contact;


View solution in original post

11 REPLIES 11

Brad Tilton
ServiceNow Employee
ServiceNow Employee

On the Requested for you can set the default value to be the project business contact. You can right click on the requested for field and choose Configure > Dictionary. In the default value field you would put the following (I guessed at the field names so you would want to validate those):



javascript: current.u_project_number.u_business_contact;


Hi Brad,



Thanks for the information. This doesn't seem to be working for me. I'm actually using a dictionary override for the default value, since I don't want to modify the default value on the task table itself. But I would think that should work the same way? Anyway, I tried what you suggested and the field is still blank. I also tried using a function (see below) to see what it's returning. According to the message that comes up, current.u_project.u_business_contact is null.



javascript:_getID();


function _getID() {
  var name = current.u_project.u_business_contact;
  gs.addInfoMessage('name is ' + name);
  return name;
}



Anything else I can try?


Thank you!


Can you try with an onLoad Client script to set the value of the requested for as per the Project number?



Suraj Chauhan


ITSMgal
ServiceNow Employee
ServiceNow Employee

Hi Jennifer,


What I have seen is when you point directly to the reference field - u_business_contact, it returns a sys_id.


I *think*, and sorry i dont have time to test right now, that if you add " _name" to the reference, it should work..


So you are actually pointing to the field name that contains the name, not the reference object.


I hope that helps.. Let me know if it works!



Emily