How do I set a default value for snRecordPicker directive?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2016 08:52 PM
Hi,
I have an sn-record-picker that reference to user table.
I want to set the default value upon onload to the current logged in user.
Please help.
<sn-record-picker field="caller" table="'sys_user'" display-field="'name'" display-fields="'email'"
default-query="'active=true'"
value-field="'sys_id'" search-fields="'name'" page-size="100" >
</sn-record-picker>
Thanks!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2016 12:49 AM
Hi
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];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2017 11:59 AM
I have the following that is not working for me.
HTML ==========
<sn-record-picker
field="c.obo"
table="'sys_user'"
display-fields="'name,email'"
default-query="'active=true^emailISNOTEMPTY^nameISNOTEMPTY'"
value-field="'sys_id'"
search-fields="'name'"
page-size="20">
</sn-record-picker>
Client script =============
c.obo = {
displayValue: $scope.data.obo_gv,
value: $scope.data.obo,
name: 'obo'
}
Server Script ===========
data.obo = gs.getUserID();
data.obo_gv = gs.getUserDisplayName();
Instead of setting the value to a user object, it sets the display field. See the attached image.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2022 03:21 PM
I need to use 2 sn-record-picker fields and based on them need to do a submit action in server side, issue is i am only getting one value from caller at a time. How do i attach a label or ng_model or class to sn-record-picker to get 2 distinct values?
console.log(evt) or (parms) doesnt show any field name, all is caller, i did tried id but left the idea as it might not be reliable? plz advice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2017 07:16 AM
Its because you only have the "display-fields".
You need to add display-field="'name'" as well