How to make default query of reference field based on another reference field service portal widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 10:46 AM
Hello All,
First of all, I don't know much about the service portal side so please ignore the obvious mistakes.
I am trying to make the reference qualifier dynamic based on the value of the other reference field.
The below is part of "Online check-in experience" widget that is cloned and customized for walkup.
When i chose Myself as an option, i want to make filter as "requested for" is the gs.getUserID()
Other wise if the user choses the person ,as on behalf of someone
Then i want to set the default query to filter based on the user selected accordingly, that is requested for is the person in that field.
<div class="form-container" ng-show="!c.checkInPanel || !c.data.enableOnlineCheckIn" ng-if="c.data.hasAppointmentBooking">
<div class="apt-msg" ng-show="c.data.showOnBehalfOption">
<p>{{c.data.msgs.aptQuestion}}</p>
<label class="radio-inline"><input type="radio" ng-model="appt_for" name="appt_config" value="for_me" ng-click="c.setOnBehalf(false);"/>{{c.data.msgs.aptOption1}}</label>
<label class="radio-inline"><input type="radio" ng-model="appt_for" name="appt_config" value="on_behalf" ng-click="c.setOnBehalf(true);"/>{{c.data.msgs.aptOption2}}</label>
</div>
<div class="userOnbehalf selectUser" ng-if="appt_for === 'on_behalf'" >
<sn-record-picker name="name-dropdown"
on-change="c.userSelected(val)"
id="name-dropdown"
field="c.data.userName"
table="'sys_user'"
display-field="'name'"
placeholder="{{c.data.msgs.selectUserMsg}}"
value-field="'sys_id'"
search-fields="'name,email'"
display-fields="'email'"
page-size="100"
default-query="'active=true'">
</sn-record-picker>
</div>
<div class="incident_req">
<p>{{c.data.msgs.incidentOrRequest}}</p>
<label class="radio-inline"><input type="radio" ng-model="appt_for_reqInc" name="appt_reqInc" value="request" ng-click="c.showReqInc(request);"/>{{c.data.msgs.request}}</label>
<label class="radio-inline"><input type="radio" ng-model="appt_for_reqInc" name="appt_reqInc" value="incident" ng-click="c.showReqInc(incident);"/>{{c.data.msgs.incident}}</label>
</div>
<div class="reqInc" ng-if="appt_for_reqInc === 'request' && appt_for === 'for_me'">
<sn-record-picker name="req-dropdown"
field="c.data.reqNum"
on-change="c.demo(val)"
id="req-dropdown"
table="'sc_req_item'"
display-field="'number'"
placeholder="{{c.data.msgs.selectRequest}}"
value-field="'sys_id'"
search-fields="'number,short_description'"
display-fields="'short_description'"
page-size="100"
default-query="data.user_query">
</sn-record-picker>
</div>
<div class="reqInc" ng-if="appt_for_reqInc === 'request' && appt_for === 'on_behalf'">
<sn-record-picker name="req-dropdown"
field="c.data.reqNum"
on-change="c.demo(val)"
id="req-dropdown"
table="'sc_req_item'"
display-field="'number'"
placeholder="{{c.data.msgs.selectRequest}}"
value-field="'sys_id'"
search-fields="'number,short_description'"
display-fields="'short_description'"
page-size="100"
default-query="'active=true'">
</sn-record-picker>
</div>
The relevant html part is this.
data.user_query ='u_requested_for='+gs.getUserID();
This is the relevant server part
Feel free to ask any questions if you need more information.
Regards,
Shariq
- Labels:
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 02:26 PM
Hi,
Sorry, your post is a little bit confusing because you already have the data.user_query built...unsure if the real field name is "u_requested_for", but I'll leave that to you. And you're already using ng-if's in the relevant sn-record-picker to then use that data.user_query...so are you saying it's not working?
We can get into the other default-query for the other sn-record-picker, but first and foremost, you know the one path and so lets figure out what's going on since you're talking about it in your post as if it's not working currently?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 02:44 AM
Hello Allen,
The queries only would show the filter based on the first condition that is, whoever is logged in.
But if I change it to another user, it won't work that way.
And I feel the 2nd sn record picker, doesn't show up, it's always the first one. So, even the ng-if is not working.
Regards,
Shariq

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 06:48 AM
Hello,
My apologies, I'm a bit confused by your reply.
Is this section working or not?
<div class="reqInc" ng-if="appt_for_reqInc === 'request' && appt_for === 'for_me'">
<sn-record-picker name="req-dropdown"
field="c.data.reqNum"
on-change="c.demo(val)"
id="req-dropdown"
table="'sc_req_item'"
display-field="'number'"
placeholder="{{c.data.msgs.selectRequest}}"
value-field="'sys_id'"
search-fields="'number,short_description'"
display-fields="'short_description'"
page-size="100"
default-query="data.user_query">
</sn-record-picker>
</div>
My suggestion is to address the first part before moving on to the other. Please clarify what is or is not working here.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 02:07 AM
@Shariq Azim , try after removing double quotations " " from default-query=“data.user_query".
Please mark it correct or helpful it if it works for you.
Thank you,
Vallabh