- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 12:07 PM - edited 01-10-2023 12:08 PM
Hi Experts,
I need a help on this catalog client script. Script looks ok to me, bit it is not working on portal.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(g_form.getValue('account') == 'Service Account'){
g_form.setVisible('service_account_link', true);
g_form.setReadonly('service_account_link', true);
alert('Service Account');
}
}
I want to add more conditions to the if condition like.
if((g_form.getValue('account') == 'Service Account') || (g_form.getValue('account') contains 'offshore') ||(g_form.getValue('account') startwith 'billing'))
Thanks,
Jay
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 09:50 PM - edited 01-10-2023 10:02 PM
Hi @jay1111 ,
You can use in built Javascript methods like startsWith() and includes().
var str = g_form.getDisplayValue("account");
if(str.startsWith("billing") || str.includes("offshore")){
alert("Service Account");
}Get display value of reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 12:46 PM
Also one more thing to check is UI type in Client script should be set to All
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 01:31 PM
I did it.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(g_form.getValue('account') == 'Service Account'){
//g_form.setDisplay('service_account_link', true);
//g_form.setReadOnly('service_account_link', true);
alert('Service Account');
}
}I even tried, just adding only alert. But, still not working.
Thanks,
Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 01:38 PM
is account a reference field? Then g_form.getValue('account') will return the sysid. So you cant compare it with a value 'Service Account'. In such case use UI policy or if you want to use client script, use sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 01:51 PM
Yes it a reference field and it worked when I used sysID. But, how can I achieve if Account Name contains "offshore" or startwith "billing".
Thanks,
Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 09:50 PM - edited 01-10-2023 10:02 PM
Hi @jay1111 ,
You can use in built Javascript methods like startsWith() and includes().
var str = g_form.getDisplayValue("account");
if(str.startsWith("billing") || str.includes("offshore")){
alert("Service Account");
}Get display value of reference field