- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2018 06:15 AM
I am building a quick form for itil use until we build out the full procurement application. There are 5 variables: requested_by (reference to sys_user), location (reference to location), vendor (lookup select box to core_companies with filter vendor = true&&state=active), description (single line text), purpose(multi line text).
I am working on a onChange client script but getting lost as I try to clarify what is server-side vs what is client-side. The script should run everytime the vendor field changes and needs to GlideRecord the core_companies table to confirm that the u_primary_contact field is not null. if it is null then notify the user. The simple workflow will send an email to the primary contact of the vendor with the form variables thus notifying them of an order. and then the workflow closes the request as it is only record keeping and not the full procurement system. Below is what I have done and i don't believe it has a chance. Any help is appreciated.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2018 07:03 AM
You might also consider modifying the filter on the vendor variable to only show companies where the u_primary_contact field is not null.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2018 06:31 AM
You're actually pretty close. Can you paste your script in here so I can modify it for you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2018 06:40 AM
Nice to know I can even find the ballpark. Thank you.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//GlideRecord the company table and make sure the vendor has a primary contact with a valid email address
var ven = new GlideRecord('core_company');
ven.addQuery('sys_id', g_form.getValue('vendor'));
ven.query();
if (ven.next()) {
if (ven.u_primary_vendor_contact == '') {
alert("The vendor selected does not have a primary contact listed so we don't know who to email with your request.");
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2018 06:50 AM
Give this a quick try and see if it works better.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//GlideRecord the company table and make sure the vendor has a primary contact with a valid email address
var ven = new GlideRecord('core_company');
ven.addQuery('sys_id', g_form.getValue('vendor'));
ven.query(vendorContactReturn);
}
function vendorContactReturn(ven) {
if (ven.next()) {
if (ven.u_primary_vendor_contact == '') {
alert("The vendor selected does not have a primary contact listed so we don't know who to email with your request.");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2018 07:28 AM
I tried this code with no luck I then changed the addQuery based on amauryboulom's suggestion with no luck. I may do what Jim suggested and change my reference qualifier to filter u_primary_vendor_contact !=NULL