onLoad Get Value Client Script Not Working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 07:47 AM
Hi all,
Despite my best efforts using the getValue in a Client Script for onLoad, it does not seem to work
If the state is rejected, the alert should not trigger, yet it does.
I have tried several times, with different variations but no luck. Does anyone have a workaround on this?
Would be much appreciated.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 08:15 AM - edited 08-04-2023 09:04 AM
Hi @Rae Khan ,
g_form.getValue('state') !='Rejected' -> This statement will always be True (As it is a Display Value NOT the Value)
g_form.getValue('state') !='rejected' -> This statement will determine based on your value of state.
If you are using || which means OR, and one of the conditions is always true so ultimately it will result into TRUE, and the code will work always.
If you are using && this will always check for both the condition to be TRUE and, in this case, when you will actually have the state not as "rejected" it will work, and Code will work.
So, in either of the case "g_form.getValue('state')!='Rejected'" is of no use.
You can try using:
if (g_form.getValue('state') != 'rejected') {
alert("Hello");
}
Hope this will work for you!!
Its Working for me!
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 08:37 AM
do not use below , it is not working i think it is bug
if (g_form.getValue('state') != 'rejected')
I modified to work it , it worked in below PDI
if (g_form.getValue('state') == "requested" || g_form.getValue('state') == "not requested" || g_form.getValue('state') == "approved" || g_form.getValue('state') == "cancelled" || g_form.getValue('state') == "not_required" )
alert('hello' + g_form.getValue('state') );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 09:58 AM
Like @Mike Patel mentioned, you can use the and operator “&&” in the IF condition instead of the “||” OR operator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 10:56 AM
@Rae Khan You are seeing the alert because your first condition in if statement is evaluating to true. Update your code as follows.
function onLoad(){
//Type appropriate comment here,
if(g_form.getValue('state')!='rejected'){
alert('HELLO');
}
}
Hope this helps.