Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get value from sn record picker

moulik1
Kilo Guru

Hi,

I have a requirement to select a record and populate two other fields based on the record selected

I have added location table record picker but i am unable to proceed further on how to read the selected record sys id and populate the fields based on the selected value

Below are the changes i added on html and client controller of the widget

HTML:

<sn-record-picker field="location" table="'cmn_location'" display-field="'name'" value-field="'sys_id'" search-fields="'name'" page-size="100" ></sn-record-picker>

Client controller:

$scope.location = {

      displayValue: c.data.loc.name,

      value: c.data.loc.sys_id,

      name: 'location'

};

$scope.$on("field.change", function(evt, parms) {

      if (parms.field.name == 'location')

              c.data.setLocation = parms.newValue;

       

      c.server.update().then(function(response) {          

              spUtil.update($scope);

      })

});

nathanfirth

Please let me know how to read the value and get the two fields populated. Also please confirm if the above process is correct

1 ACCEPTED SOLUTION

nathanfirth
Tera Guru

Moulik,



Please take a look at the example I have posted on serviceportal.io:
https://serviceportal.io/sn-record-picker/



Then you can download the completed example I posted on Share which does exactly this:
https://share.servicenow.com/app.do#/detailV2/86b23f151370e2001d2abbf18144b0aa/overview


View solution in original post

2 REPLIES 2

nathanfirth
Tera Guru

Moulik,



Please take a look at the example I have posted on serviceportal.io:
https://serviceportal.io/sn-record-picker/



Then you can download the completed example I posted on Share which does exactly this:
https://share.servicenow.com/app.do#/detailV2/86b23f151370e2001d2abbf18144b0aa/overview


Hi nathanfirth

At The Same Time I Want To Show Another Table Values Also When I Am Selecting Location , I want to display some another table value also, i have reference field in another table

 

please help me out  nathanfirth

Thanks

Dinesh kumar