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.

sn record picker default value to current session user

maryc
Tera Contributor

Hello,

 

How do I set the sn record picker default value to current loggedin user in a model on service portal?

I have another sn record picker field which shows location entries. How do I pass the value of the default user and location over to client controller to call a script include?

 

Thanks

2 REPLIES 2

Ranjit Nimbalka
Mega Sage

Hi @maryc 

 

for 1st requirement:-

 

The sn-record picker is bound to an object in the data model. eg. field = "c.caller".



In the client script you define this object



c.caller = {

 

displayValue: c.data.caller_dv,

 

value: c.caller,

 

name: 'caller'

 

};



Then in your server script, you simply specify the default values - you could get them from the widget options or hardcode them or whatever.



data.caller_dv = [user sys_id];

 

data.caller = [user display name];

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Ranjit

maryc
Tera Contributor

How will the sn record picker in html look?