Cost Center filter by Company & Company Code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 06:32 AM
I need to set a filter for the Cost Center field based on the Company in Company of the Contingent Worker field. IF the company in the Company of the Contingent Worker field has a Company Code of 1000 than only show Cost Centers with Company Code of 1000.
Here is what I have and it is not working. Thoughts?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var company = g_form.getReference('cwo_company_of_the_cwr', getCode);
company.addEncodedQuery("u_company_code=1000 ");
function getCode(company)
{
var a=cost_center.u_company_code ("1000");
g_form.setValue('cwo_cost_center',a);
}
}
Catalog Form:
Company Table with Company Code Field
Cost Code Table with Company Code Field
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 06:36 AM
What you are looking for is not done with a client script. It is done with a mechanism called a reference qualifier. It is designed specifically to filter the results presented on a reference field. I recommend starting here:
Also, I invite you to watch the Quick Tip on Episode 36 of TechNow. I talk about these specifically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 06:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2017 09:08 AM
How about this?
function getCompanyCode ( ) {
var answer = '';
var includes = current.variables.textmatch;
var usr = new GlideRecord('sys_user');
usr.addQuery('u_company_code','CONTAINS',1000);
usr.query();
}
while (usr.next()) {
if (answer = 1000 ) {
answer += (',' + company.name); }
else {
answer = ('' + company.name); }
}
return 'sys_idIN' + answer; }
}