How to assign a bushness role to a reference field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 10:17 PM
I have a field that is a reference type, how can I assign this value from another table to it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 10:40 PM
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
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 11:12 PM
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...
Thanks,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 11:19 PM
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 as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 11:28 PM
@Mark Manders hello
According to the writing style you provided, it seems that it still cannot be assigned a value.
result: