How to make default query of reference field based on another reference field service portal widget

Shariq Azim
Kilo Guru

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()

ShariqAzim_0-1678386692905.png

 

Other wise if the user choses the person ,as on behalf of someone

ShariqAzim_1-1678387308760.png

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

 

5 REPLIES 5

No it wont work that way, because the first way I am alredy able to filter based on the first condition otherwise.