- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2021 11:48 AM
Hello People,
i am trying to add a dynamic query to sn-record-picker by following script:
HTML
<sn-record-picker field="family" table="'cmdb_ci_business_process'" display-field="'name'" value-field="'sys_id'" multiple = "true" default-query="'sys_idIN{{data.family}}'" search-fields="'name'" page-size="100" ></sn-record-picker>
Server side script:
var utils = new MasterDeclarationsData();
data.family=utils.getPurposeFamily(); (i even tried with hardcoding single sys id like "data.family="3a859fa44f3f07006dfacda28110c7f1"" still not working)
Script Include :
getPurposeFamily: function() {
var purpFamily = [];
var family = new GlideRecord("x_lof_gdpr_processing_activity");
family.addEncodedQuery('type=Global Master Declaration');
family.query();
while (family.next()) {
var localFamily = new GlideRecord("x_lof_gdpr_processing_activity");
localFamily.addEncodedQuery('type=Local Master Declaration');
localFamily.query();
while (localFamily.next()) {
var list = localFamily.data_controllers.toString();
var array = list.split(",");
for (var i = 0; i < array.length; i++) {
var userGr = new GlideRecord('x_lof_gdpr_user');
userGr.addEncodedQuery('role=author^entity=' + array[i] + '^groupDYNAMICd6435e965f510100a9ad2572f2b47744');
}
userGr.query();
while (userGr.next()) {
if(family.family!=''){
purpFamily.push(localFamily.family.toString());
}
}
}
if(family.family!=''){
purpFamily.push(family.family.toString()); }
}
gs.info('shikha is inside : ' + purpFamily);
return purpFamily.toString();
},
This script in returning all sysId's which i need to find in cmdb_ci_business_process table for picker
script works fine in background script and also returns corresponding display values for sysId's
But doesn't work with record picker.
Any suggestions? 🙂
Thanks in advance 🙂
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2021 01:23 PM
Hey
thanks for responding i found the solution
there was an issue with my server script 😞
a if condition was causing the issue 😕
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2024 08:39 PM
I am facing issues with sn-record-picker..
I have added alert of my data.query in client controller it is returning all the sys_ids of users..
But the search of record picker is not showing any results..
Can you please help me on this..
HTML :
<div class="clearfix"></div>
</div>
<div class="panel-body">
<div class="text-center text-italic text-muted" id="watch_list_div">
<sn-record-picker
field="watch_list"
table="'sys_user'"
display-field="'name'"
search-fields="'name'"
value-field="sys_id"
multiple="true"
default-query="'sys_idIN{{data.query}}'"
page-size="1000">
</sn-record-picker>
<p></p>
<button
type="button"
ng-click="updateRecord()"
ng-if="data.canWrite"
class="btn btn-default ng-scope">
Add User to Watchlist
</button>
</div>
</div>
</div>
Client Script :