How to pass javascript function into query Business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2017 05:14 AM
Hi,
Thanks in adv,
I have an issue regarding Query business rule, while i am trying to do query business rule to query the records its not retrieving.
here i am using below script include to retrieve the array of sysids.
I am calling this script iclude in a query business rule as shown below to query the records.
current.addEncodedQuery("sys_id=javascript:AssetAccess()");
but its not working,Please help me out where i am missing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2017 05:39 AM
Hi
You need to run the function within the business rule instead
current.addEncodedQuery('sys_id=' + AssetAccess());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2017 11:36 PM
Thank you for the response Lars,
I tried the same but no luck
current.addEncodedQuery('sys_id=' + AssetAccess());
if possible can u provide the code which is working.
Thank you,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2017 05:40 AM
Hi Swathi,
I noticed a few things that need changing... first, when you are in the while loop, use gr.getValue('sys_id'),
var arr = [];
// do you query
while (gr.next()) {
arr.push(gr.getValue('sys_id'));
}
// return the comma separated values
return arr.join(',');
Then in your query BR,
var queryStr = 'sys_idIN' + AssetAccess();
current.addEncodedQuery(queryStr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2017 11:33 PM
HI Thomasi,
Thank you for the response.
If we use the below code it will work fine for limited sysids.
var queryStr = 'sys_idIN' + AssetAccess();
current.addEncodedQuery(queryStr);
For example if we are querying 1000 sysids and retrieving 1000 records then we are getting error (URL limitation exceeds) because this encodedquery stitch the sysids and pass it to the URL.
Due to this we are trying to pass all sysids as a java script function to overcome URL Limitation error.So can u help me out how to pass the javascript function in a Encodedquery.