- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2019 01:10 AM
How can we pass reference field columns to $sp.getRecordDisplayValues?
I tried with below code but doesn't work.
var obj = {};
var columnsToGet = 'number,agency.number,agency.name';
$sp.getRecordDisplayValues(obj, gliderecord, columnsToGet);
where agency is a reference field. Number is populating since it is part of current table but other fields are not populating. Please advise.
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2019 02:09 AM
Thanks for your support. But, I somehow made it work through the existing code itself.
Instead of item.agency.name,I used item["agency.name"]. My bad, we can not directly fetch values of keys with such names abc.xyz by simply dot-walking. Instead, we need to fetch the same by passing it as a key.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2019 01:36 AM
this way you wont get the value of reference field.
try now.
i am adding example here.
Server side code:
var locSysId = "";
if (input.setLocation)
locSysId = input.setLocation;
else
locSysId = gs.getUser().getRecord().getValue('location');
var locGR = GlideRecord('cmn_location');
locGR.get(locSysId);
data.loc = {};
data.loc.parent = locGR.getDisplayValue('parent');
$sp.getRecordDisplayValues(data.loc, locGR, 'sys_id,name,street,city,state,zip');
html:
<div class="form-group">
<label class="col-sm-2 control-label">Country</label>
<div class="col-sm-10">
<input type="text" placeholder="{{data.loc.parent}}" class="form-control" readonly>
</div>
</div>
if my answer helped you, kindly mark it as correct and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2019 01:44 AM
Hi Harshvardhan,
Thank you for your response.
After debugging, I found that value is getting set with whatever code I have written. I found below in logs:
{"number":"TICKET0002645","agency.number":"ACCT0010001","agency.name":"DMV - ACCOUNT0001001"}
But, the issue is with the html code
<tr ng-repeat="item in c.data.items">
<td>{{item.number}}</td>
<td>{{item.agency.number}}</td>
<td>{{item.agency.name}</td>
</tr>
I am not able to get the value here. Can you please advise here?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2019 01:48 AM
it will not work this way. because it is not doing dot walk here inside the function. that's why i passed another variable to fetch reference value.
eg:
data.loc.parent = locGR.yourField.dotWalkfield.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2019 02:09 AM
Thanks for your support. But, I somehow made it work through the existing code itself.
Instead of item.agency.name,I used item["agency.name"]. My bad, we can not directly fetch values of keys with such names abc.xyz by simply dot-walking. Instead, we need to fetch the same by passing it as a key.