- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2022 01:43 AM
Hi There,
I have placed a slush bucket for license table in catalog item. It shows some records from table in left bucket. My requirement is to get few records from left bucket to and get selected in right slush bucket automatically from client script.
I have written a client script for that and i am calling Script include method through glide ajax to get some some records sys_ids and those records are from License table. Through DOM manipulation They are getting selected automatically but the issue here is only few records get selected from left slush bucket to right, not all. I am not getting the root cause of it.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2022 02:01 AM - edited ‎12-22-2022 03:33 AM
Hey,
It would be helpful if you could share more information on script which you are using. I believe you might be using the logic of left and right slush bucket which is available on community.
The Root cause of this issue is -
The Left slush bucket only shows the 100 records from the table, if you didn't notice just scroll down the records in left slush bucket. You'll get to know it only contains 100 records.
And if you search those records in search field of left slush bucket which are not getting pushed to right slush bucket. It'll show those records in dropdown list.
So, for you the records getting pushed into right slush bucket by client script are from those 100 records of left slush bucket. And this is moved immediately. Now for other records, slush bucket takes few secs to search those unavailable records and move them to right slush bucket.
I would recommend you to iterate on record sys_ids and check in right slush bucket if all are moved. If all are moved then break the iteration.
To make the better user experience - you can make the slush bucket container or section hidden till the time this movement happens. You can use client side methods for this.
Hope you got the root cause.
Regards,
Kartik Choudhary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2023 06:39 PM - edited ‎01-03-2023 06:46 PM
Hey ,
PFB logic which I have written in PDI for catalog item. I believe the same you must have written.
slushbucket-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
clearValues();
} else {
clearValues();
var left, right, l_o;
var ga = new GlideAjax('apiRCA');
ga.addParam('sysparm_name', 'getOpportunityRecords');
ga.addParam('sysparm_opportunityGroup', g_form.getValue('u_opportunity_group'));
ga.getXML(getOpportunity);
function getOpportunity(response) {
var data = response.responseXML.documentElement.getAttribute("answer");
var ids = data.split(',');
setSlushBucket('u_opportunity', 'sys_idIN' + ids.toString());
g_form.setDisplay('u_opportunity', false);
setCollectorFilter();
function setCollectorFilter() {
//get the current showing list from 'available' and 'selected' slush bucket
left = gel('u_opportunity' + '_select_0');
right = gel('u_opportunity' + '_select_1');
l_o = left.options;
//condition to check - available slush bucket should have the records according to new filter set.
if (l_o.length != ids.length) {
setTimeout(setCollectorFilter, 100); // setting timeout untill the available slush bucket get refreshed.
return;
} else { // when 'available' slush bucket is refreshed - control will come to else block where we are setting the necessary records in 'selected'/right slush bucket
g_form.setValue('u_opportunity', ids.toString());
setSlushBucket('u_opportunity', 'contract_model=10f2246fdb11909064cb5eea4b96194b'); //reset the fiter to reset the available slush bucket
g_form.setDisplay('u_opportunity', true);
}
}
}
}
}
function clearValues() {
g_form.setValue('u_opportunity', '');
}
//Below function will set the filter of the list collectors account to the query passed in the param
function setSlushBucket(collectorName, sqlQuery) {
window[collectorName + 'g_filter'].reset();
window[collectorName + 'g_filter'].setQuery(sqlQuery);
window[collectorName + 'acRequest'](null);
}
Regards,
Kartik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2022 02:01 AM - edited ‎12-22-2022 03:33 AM
Hey,
It would be helpful if you could share more information on script which you are using. I believe you might be using the logic of left and right slush bucket which is available on community.
The Root cause of this issue is -
The Left slush bucket only shows the 100 records from the table, if you didn't notice just scroll down the records in left slush bucket. You'll get to know it only contains 100 records.
And if you search those records in search field of left slush bucket which are not getting pushed to right slush bucket. It'll show those records in dropdown list.
So, for you the records getting pushed into right slush bucket by client script are from those 100 records of left slush bucket. And this is moved immediately. Now for other records, slush bucket takes few secs to search those unavailable records and move them to right slush bucket.
I would recommend you to iterate on record sys_ids and check in right slush bucket if all are moved. If all are moved then break the iteration.
To make the better user experience - you can make the slush bucket container or section hidden till the time this movement happens. You can use client side methods for this.
Hope you got the root cause.
Regards,
Kartik Choudhary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2022 02:56 AM
Hi
I have checked it's true that it shows 100 records and and when i try to search, it shows the missing records. I'll try the approach mentioned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2022 05:56 PM
I have tried putting if condition, it worked.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2023 06:39 PM - edited ‎01-03-2023 06:46 PM
Hey ,
PFB logic which I have written in PDI for catalog item. I believe the same you must have written.
slushbucket-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
clearValues();
} else {
clearValues();
var left, right, l_o;
var ga = new GlideAjax('apiRCA');
ga.addParam('sysparm_name', 'getOpportunityRecords');
ga.addParam('sysparm_opportunityGroup', g_form.getValue('u_opportunity_group'));
ga.getXML(getOpportunity);
function getOpportunity(response) {
var data = response.responseXML.documentElement.getAttribute("answer");
var ids = data.split(',');
setSlushBucket('u_opportunity', 'sys_idIN' + ids.toString());
g_form.setDisplay('u_opportunity', false);
setCollectorFilter();
function setCollectorFilter() {
//get the current showing list from 'available' and 'selected' slush bucket
left = gel('u_opportunity' + '_select_0');
right = gel('u_opportunity' + '_select_1');
l_o = left.options;
//condition to check - available slush bucket should have the records according to new filter set.
if (l_o.length != ids.length) {
setTimeout(setCollectorFilter, 100); // setting timeout untill the available slush bucket get refreshed.
return;
} else { // when 'available' slush bucket is refreshed - control will come to else block where we are setting the necessary records in 'selected'/right slush bucket
g_form.setValue('u_opportunity', ids.toString());
setSlushBucket('u_opportunity', 'contract_model=10f2246fdb11909064cb5eea4b96194b'); //reset the fiter to reset the available slush bucket
g_form.setDisplay('u_opportunity', true);
}
}
}
}
}
function clearValues() {
g_form.setValue('u_opportunity', '');
}
//Below function will set the filter of the list collectors account to the query passed in the param
function setSlushBucket(collectorName, sqlQuery) {
window[collectorName + 'g_filter'].reset();
window[collectorName + 'g_filter'].setQuery(sqlQuery);
window[collectorName + 'acRequest'](null);
}
Regards,
Kartik