- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2022 01:29 PM
On my record producer, I have 2 variables, Company (default to logged in user's Company) and Service Offering a reference field.
I have a requirement where I need to set value to one particular record on the service offering if logged in user's company is equal to 'Credit Company' and hide the rest, else, display the rest EXCLUDING 'Credit Company'.
I have created a script include and added a reference qualifier on the service offering variable.
However, this doesn't work well. Anyone can review and help?
javascript:new getServiceOfferingByCompany().getServiceOfferingByCompany()
var getServiceOfferingByCompany = Class.create();
getServiceOfferingByCompany.prototype = {
initialize: function() {},
filterCreditOnly: function() {
var answer = ' ';
var company = current.variables.company.getDisplayValue();
//gs.log(company);
//return Offerring = Credit Services if company is Credit Company
if (company == 'Credit Company')
return '127eaa3597741110d682d200f153afd9'; //sys_id of the Offering = Credit Services
var offering = new GlideRecord('service_offering');
offering.addEncodedQuery('state=published^ORstate=^name!=Credit Services^ORname=NULL');
offering.query();
while (offering.next()) {
if (answer.length > 0) {
answer += (',' + offering.sys_id);
} else {
answer = offering.sys_id;
}
}
return 'sys_idIN' + answer;
},
type: 'getServiceOfferingByCompany'
};
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2022 02:06 PM
Thank you everyone. I have combined both of your comments and did some minor tweaks on it and this should be working.
var getServiceOfferingByCompany = Class.create();
getServiceOfferingByCompany.prototype = {
initialize: function() {},
filterCreditOnly: function() {
var answer = [];
var company = current.variables.company;
var serv = '127eaa3597741110d682d200f153afd9';
//return Offerring = Credit Services if company is Credit Company
if (company == 'af1f6e7597741110d682d200f153af0d')
return 'sys_idIN' + serv;
else {
var offering = new GlideRecord('service_offering');
offering.addEncodedQuery('state=published^ORstate=^name!=Credit Services^ORname=NULL');
offering.query();
while (offering.next()) {
answer.push(offering.getValue('sys_id'));
}
return 'sys_idIN' + answer;
}
},
type: 'getServiceOfferingByCompany'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2022 02:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2022 11:46 PM
hello
Can you please mark the appropriate answer as correct ? and close the thread so that it will be removed from un solved list