The CreatorCon Call for Content is officially open! Get started here.

Advance Reference Qualifier not bringing back choices

Edwin Fuller
Tera Guru

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

find_real_file.png

Screen Shot from Product Table

find_real_file.png

1 ACCEPTED SOLUTION

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.




View solution in original post

8 REPLIES 8

This did not work for me, received an error about global


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.




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


Glad its solved!