How to set value to "sn-reference-picker" in widget?

suraj patil1
Kilo Explorer

Hi Guys,

I came across one scenario, where I want to set value of "sn-reference-picker" from server side in widget.I dont know which attribute need to set .If anyone having any idea or documentation on "sn-reference-picker" will be helpful.

Thanks,

Suraj 

6 REPLIES 6

tchaikin
Giga Expert

Suraj,

I suggest you start on this thread with Nathan's documentation.

https://community.servicenow.com/community?id=community_blog&sys_id=54bde6a9dbd0dbc01dcaf3231f96193f

suraj patil1
Kilo Explorer

I tried with that but I am not getting data when I set default-query , thats why I shifted to sn-reference-picker where I am getting correct data. It keeps searching searching for data when I used sn-record-picker. Please find below code

sn-record-picker = 

<div>
      <sn-record-picker field="deepSearchTable" table="'sys_db_object'" default-query="testquery" display-field="'label'" value-field="'name'" search-fields="'label,name'" page-size="100"></sn-record-picker>
</div>

 

sn-reference-picker = 

HTML Code :

<sn-reference-picker id="cmdb_classes"
sn-options="{placeholder: 'Select CMDB table'}"
ed="descriptor"
field="field" sn-on-change="c.showValue()"
value={{data.newclass}}/>

Client Controller :

$scope.testquery = c.data.query;

$scope.table = "sys_db_object";
$scope.field = {};
$scope.descriptor = {
reference: $scope.table,
attributes: '',
name: '',
searchField: 'label',
qualifier: $scope.testquery
};

Hi i have used this script, but i have to populate the reference field with logged in user details. i am new to widget. can u help me for this?. i want to know whether we should give query or qualifier value to get logged in user values.

suraj patil1
Kilo Explorer

I got the solution. thanks.