
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2017 10:21 AM
Can someone help me understand why the below is script is not returning any values?
Within the custom form users fill out there is a field called 'submission_type' that is required. Whenever the submission type is 'R.S.G.' I only want to return the 'R.S.G.' products.
Within the Product Table I have 10 values populated with 'R.S.G.', but its not returning any of those products.
var FilterProductList = Class.create();
FilterProductList.prototype = {
initialize: function() {
},
FilterProductList:function() {
var gp = ' ';
var a = current.submission_type;
//return everything if the submission_type value is empty
if(!a)
return;
//ConnectUs Products has the business unit to product relationship
var grp = new GlideRecord('x_hemas_connectus2_connectus_products');
grp.addQuery('business_unit',a);
grp.query();
while(grp.next()) {
if (gp.length > 0) {
//build a comma separated string of products if there is more than one
gp += (',' + grp.product);
}
else {
gp = grp.product;
}
}
// return quired products
return 'sys_idIN' + gp;
},
type: 'FilterProductList'
};
Screen shot from custom form where no products are available to select
Screen Shot from Product Table
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2017 01:41 PM
Hi Edwin,
Can you make sure that 'Product' field on 'x_hemas_connectus2_connectus_products' table is a reference field?
If so, then may be put in some log entries to see if the info is correct.
Like-
gs.log('Submission type from Script Include: ' + current.submission_type); //before -> //return everything if the submission_type value is empty
gs.log('sysIDs returned: ' + gp); //before the last return statement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2017 01:00 PM
This did not work for me, received an error about global
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2017 01:41 PM
Hi Edwin,
Can you make sure that 'Product' field on 'x_hemas_connectus2_connectus_products' table is a reference field?
If so, then may be put in some log entries to see if the info is correct.
Like-
gs.log('Submission type from Script Include: ' + current.submission_type); //before -> //return everything if the submission_type value is empty
gs.log('sysIDs returned: ' + gp); //before the last return statement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 08:52 AM
I feel kind of slow now because a light came on in my head after you asked for me to make sure the product field was a reference field. It wasn't at first, so I updated it and it started working. Thank you so so much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 01:32 PM
Glad its solved!