How to assign a bushness role to a reference field?

shiz
Tera Contributor

I have a field that is a reference type, how can I assign this value from another table to it?

shiz_0-1731651422704.png

 

6 REPLIES 6

Runjay Patel
Giga Sage

Hi @shiz ,

 

You can not, reference field will accept value only from reference table which you have configured in dictionary.

the value which you will try to set that record sys id has to be present in reference table else it wont set.

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

raj chavan
Tera Guru

Refer this to get idea about this query - Setting value of reference fields using Business Rule

If my answer helped you in any way, then mark i...

Kindly mark it correct and helpful if it is applicable.

Thanks,

Raj

Mark Manders
Mega Patron

So you have a reference field to the 'u_actual_times' table and from there you need the record that has the same 'u_week_starts_on' as on your current record?
What kind of fields are these, because date/time fields can be tricky. Put logging in your BR to make sure the fields are giving the correct values to compare to.

 

var actualTimeWeeklyRecord = current.u_releate_date.getRefRecord();
var actualWeekStartsOn = actualTimeWeeklyRecord.u_week_starts_on;
if(current.u_week_starts_on != actualWeekStartsOn){
   var grActTimes = new GlideRecord('u_actual_times');
   grActTimes.addQuery('u_week_starts_on',current.u_week_starts_on);
   grActTimes.query(;
   while(grActTimes.next()){
      current.u_releate_date = grActTime.getUniqueValue(); 
}

 

u_week_starts_on-field needs to be the display value of the 'u_actual_times' table. Otherwise it won't work. The only solution you have then is to put it as a dotwalked field on the form, getting it from that table.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

@Mark Manders hello

According to the writing style you provided, it seems that it still cannot be assigned a value.

shiz_0-1731655585157.pngshiz_1-1731655632619.png

shiz_2-1731655661899.png

result:

shiz_3-1731655699427.png