compare two variables on on a catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2016 12:11 PM
I'm trying to compare two variables on on a catalog item. One variable is text type variable and the other one is reference type variable. Please see below: Requestor and the Approver should be the same person. I tried below onChange scrip. That doesn't work.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (g_form.getValue('infoblox_host_req_txtbox_requestor_name').toString() == g_form.getValue('infoblox_host_req__ref_approver').toString()) {
alert("The requstor and the approver cannot be the same person");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2016 12:44 PM
g_form.getValue('infoblox_host_req__ref_approver').toString())
should return the SID For the approver.. not the display value.. try replacing the .toString with .getDisplayValue()... or both .getDisplayValue().toString()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2016 12:44 PM
Comparing names is not an ideal comparison, as it can be same for different userIDs. Why are you not using Requestor's name as a reference field too?
As in for your script, try using getDisplayValue for your reference field.
g_form.getDisplayValue('infoblox_host_req__ref_approver').toString()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2016 12:52 PM
Sorry should have said that also.. i can't emphasize how much i agree.. never do a check like this with a user entry if you can avoid it... this is a really bad idea...
if the user types in Bob Tilton.. and the ref field is Robert Tilton your comparison will have no issue with that .... good catch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2016 12:45 PM
Use this script,
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (g_form.getValue('infoblox_host_req_txtbox_requestor_name') == g_form.getReference('infoblox_host_req__ref_approver').name) {
alert("The requstor and the approver cannot be the same person");
}
}