- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 04:00 AM
Hi All
I seem to have an issue with this client script not executing correctly on a Catalog Item. The script is looking up a user on the sys_user table using a callback function. Then depending on if the field on the looked up user record has a value in it, will then make a variable on the catalog item hidden or visible. As it currently stands the form is hidding variables even when there is no entry on the looked up field, whereas it shoudl be displaying the variabIe.
Ithink i am missing something between each of the "if" statements. Can anyone assist?
//AM I MISSING SOMETHING TO SEPERATE THE ABOVE FROM THE BELOW "IF" STATEMENT
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2025 04:18 AM
Hi, I have found the issue. It was due to an ACL on the sys_user table, which prevented the results of the client script from being displayed. Thankyou for you assistance anyway, it was very kind of you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 05:54 AM
Pretty much same maybe some indentation and {} in the else block
Now similarly add one more if at a time and see if that works. If i understand correctly, you are checking to see f these fields on the user table are populated or not, if not then you want to show the corresponding variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 06:00 AM
Hi, you understand correctly, when I add another field in, it stops working again. To me it needs something to seperate the fields into blocks of "If and else"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 06:11 AM
Try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var usr = g_form.getReference('name_of_existing_colleague', callBack);
}
function callBack(usr) {
//Field 1
if (usr.u_dunsaperpprodusername != "") {
g_form.setDisplay('sap_ecc_production', false);
} else {
g_form.setDisplay('sap_ecc_production', true);
}
//Field 2
if (usr.u_dunsaperppreprodusername != "") {
g_form.setDisplay('sap_ecc_pre_production', false);
} else {
g_form.setDisplay('sap_ecc_pre_production', true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 06:31 AM
Hi,
No that does not work, if i put a value in the u_dunsaperppreprodusername on the users record, and leave u_dunsaperpprodusername blank, the script is hiding both the variables on the form, where it should only be hiding 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 06:55 AM
Can you add some alerts inside the ifs on callback function.
Feels like there is some other scripts that might be impacting this
function callBack(usr) {
//Field 1
if (usr.u_dunsaperpprodusername != "") {
alert('1');
alert('value = '+ usr.u_dunsaperpprodusername );
g_form.setDisplay('sap_ecc_production', false);
} else {
alert('2');
g_form.setDisplay('sap_ecc_production', true);
}
//Field 2
if (usr.u_dunsaperppreprodusername != "") {
alert('3');
alert('value = '+ usr.u_dunsaperppreprodusername);
g_form.setDisplay('sap_ecc_pre_production', false);
} else {
alert('4');
g_form.setDisplay('sap_ecc_pre_production', true);
}
}