- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2014 08:14 AM
I'm trying to compare two reference variables on a catalog item and if the second one matches the first one, alert the user of the duplication and clear the contents of the second variable. First reference variable is new_site_owner and the second reference variable is new_site_owner2 Below is the catalog client script I am using woth Type: OnChange and Variable Name: new_site_owner2. Is this the correct way to compare two reference variables? Thanks
function onChange(control, oldValue, newValue, isLoading) {
if (!isLoading || newValue == '') {
return;
}
if(newValue == g_form.getValue('new_site_owner')) {
alert("Owners cannot be the same");
g_form.setValue('new_site_owner', '');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2014 01:14 AM
Hi Chris,
Use the () after the toString since it is a function. I hope this would solve your issue.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (g_form.getValue('new_site_owner2').toString() == g_form.getValue('new_site_owner').toString()) {
alert("The primary site owner and the secondary site owner cannot be the same person");
g_form.setValue('new_site_owner2', '');
}
}
You can also use the below condition if you writing onchange script on new_site_owner2 field.
if (newValue == g_form.getValue('new_site_owner').toString()) {
Regards
Viswanath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2014 01:14 AM
Hi Chris,
Use the () after the toString since it is a function. I hope this would solve your issue.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (g_form.getValue('new_site_owner2').toString() == g_form.getValue('new_site_owner').toString()) {
alert("The primary site owner and the secondary site owner cannot be the same person");
g_form.setValue('new_site_owner2', '');
}
}
You can also use the below condition if you writing onchange script on new_site_owner2 field.
if (newValue == g_form.getValue('new_site_owner').toString()) {
Regards
Viswanath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2014 05:11 AM
Pradeep. I am unable to access the demo site. It's telling me System initializing, please check back later. I was able to resolve this thru another community users suggestion. Thank you for your time.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2016 12:33 PM
Thank you for providing this script. I was able to make this work to avoid having the same 2 people be selected for approvers. My question is how do I reverse the script? Meaning, I want an alert message to appear if two variables are not equal. I thought I could simply use the same script but replace (==) with (!=) but that did not work.