Condition/OnClick field on a client script for a record producer

Jason Stephens
Kilo Guru

I am trying to run a client script ONLY if a field on my form (caller_id) is not empty. Otherwise, I do not want it to run. I would assume I could put caller_id!='' in the condition/OnClick field to accomplish this, but it doesn't work. Why doesn't this work?

14 REPLIES 14

function onLoad() {

if (g_form.getValue('current.caller_id'!= '')){

g_form.setValue('u_caller_user_id', g_form.getReference('caller_id').user_name);

}

OK - I'm still having issues. This is my code. Seems simple enough, but I can't get it to act right. I don't want it to run if my caller_id field is empty, but it doesn't run at all. We have another client script (that is already in place) that will not run if I set this one to global. I'm sorry to be a pain on this one, but it's so simple yet driving me crazy....


Take 'current' out of your script. That's only for server-side scripts.


Same result. I think I added "current" as one more thing to try earlier. Either way - same result...


Your code looks fine other than that. It's just down to standard troubleshooting now. Set up a script with nothing but an alert to see if you can get that to run. If that works, then add your if condition with an alert in it and get that to run. Narrow it down to the specific line or specific variable to see what's going on.


Does it make a difference that the field I'm trying to check is a reference field? I can't find anything anywhere that says so, but it just doesn't want to go into the 'if' statement....