- 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
01-23-2021 12:49 PM
Try setting a string in the client controller that has everything and then use that whole string for your "default-query"
//Client controler script
c.data.default_query = "sys_idIN" + c.data.family.toString();
//HTML
<sn-record-picker field="family" table="'cmdb_ci_business_process'" display-field="'name'" value-field="'sys_id'" multiple = "true" default-query="c.data.default_query" search-fields="'name'" page-size="100" ></sn-record-picker>
//It may need to be
<sn-record-picker field="family" table="'cmdb_ci_business_process'" display-field="'name'" value-field="'sys_id'" multiple = "true" default-query="{{c.data.default_query}}" search-fields="'name'" page-size="100" ></sn-record-picker>
//I forget which
You can then add an alert or something to actually see what you are using for the query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2021 01:02 PM
hey,
i tried this
server
data.family = "3a859fa44f3f07006dfacda28110c7f1"; //static sysid
Client
c.data.default_query = "sys_idIN" + c.data.family;
alert(c.data.default_query);
alert is "sysidInUndefined"
if i try with tostring()
alert never appears 😞
- 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
01-23-2021 03:31 PM
The reason you do not see the alert is because you cannot call toString on something that is undefined. If you had checked the console you would have seen an error there.