How to call sn-record-picker in client control and server script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2020 05:10 AM
Hi All,
I would like to add 2 columns in my modal window but one column i have added and client and server actions are working fine . But i am not sure how to add one more column in the same window. can anyone help me on this. i would like to call the "sn-record-picker" selected values into client controller modal and update the selected value into server side.
HTML :
<span class="label-text">Add users</span>
<sn-record-picker field="selectedField" table="'sys_user'"
display-field="'label'"
multiple="true"
value-field="'name'"
display-fields="'name'"
search-fields="'label,name'" page-size="100" on-change="c.onChange()" ></sn-record-picker>
Server Side :
data.sys_id = input.item_sys_id || $sp.getParameter("sys_id");
var action = input.action;
var comments=input.value;
var adduser= input.user;
if (action =="moreInformation"){
// Valid GlideRecord
gr = new GlideRecord("sysapproval_approver");
if (!gr.isValid())
return;
// Valid sys_id
if (!gr.get(data.sys_id))
return;
if (input && input.action) {
gs.log("k:inside approve if condition");
if(action == 'moreInformation') {
gr.comments=input.value; //User entered value in model
gr.u_add_user=input.user;
gr.setValue('state', 'more_info_required');
gr.setValue('updated_by', gs.getUserID());
gr.update();
}
}
}
Client Controller :
c.moreInformation=function(action,item_sys_id,value,user) {
spModal.open({title: 'Commetns are Mandatory to reject',
label: 'Comments',
input: true,
value:c.value,
user:c.user
}).then(function(value,user) {
if(value){
c.data.action = action;
c.data.item_sys_id = item_sys_id;
c.data.value = value;
c.data.user = user;
c.server.update().then(function() {
c.data.action = undefined;
})
}
else{
console.log('Comment mandatory');
}
})
c.onChange = function(user) {
c.data.field = c.selectedField.value;
c.server.update().then(function() {
c.data.field = undefined;
})
}
};
I have wrote code in Data Table widget after clone.
Current Window :
I wants to include that "Add User" field below comments column into the modal window. I have written HTML but not sure how to invoke the values to modal as well as server side. Can anyone give me some clue .it will be great help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2020 06:36 AM
Hi keerthi,
Can you share the code of this above comment model window.
Because there is no relation with CC or SS you just have to put that sn-record-picker html code into this above comment model window's HTML Template/part.
Like here is example:
If the above code helps then please mark my answer Correct and Helpful.
Thanks and Regards:
Siddhnath Pandey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 03:12 AM
Hi @Siddhnath Pande can you help on this post please ?
Post:
https://www.servicenow.com/community/developer-forum/how-do-i-call-a-lt-sn-record-picker-gt-in-a-spm...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2020 08:07 AM
Hi Siddhnath,
I am not using html to open model window. The model window is in CC. If you see above code you can get the model widow. Actually I am doing this in Data Table widget . When user right click the each record they should "More Information" as one of the option as same as OOB "Filter Out" and "Show Matching" .Those OOB context menus called using Link. So same way i tried to add "more information" option as well its working as expected but what ever value they given in the model window that should be passed to back end table(sysapproval.approver) table. So i wants to send the selected user to back end table and send notification to those users. So i am not sure how to add it here.
Below is the Link which i am calling in CC.By using CC the model window opens. There i wants to add one more column. basically i wants to enable list field. The record picker is giving result as expected but i don't know how to use it here in my case. Please suggest.
CC:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2020 09:02 AM
I tried to find something but i didn't get the suitable answer for you. I am sorry.
However whatever I have found in search I am sharing with you may be you get some help.
The spModal class provides an alternative way to show alerts, prompts, and confirmation dialog. spModel.open takes few specific parameter so we can not add extra like add user.
So I don't think you can enter some value like add user with in this way
If you haven't checked the spModel doc. please check this below link
But there is one way I thought this might work that was emending another custom widget in that window & create that two filed comment & add user on that custom widget. but I don't know much about it. 😞