Client Script - Hide Variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 10:47 AM
I have no idea why this script isn't working, it seems to be working in every other client script I have going.
This is my client script that on submit, if the number in quantity is quoted, clear the vendor as well as hide the rest of the variables on the submitted request or if not, clear the first quantity quoted. when I submit the request with u_quantity_quoted_2 blank, the vendor clears out but the rest of the variable are visible. what am I missing? does it matter that this was a custom table?
function onSubmit() {
//Type appropriate comment here, and begin script below
var quote = parseInt(g_form.getValue('u_quantity_quoted_2'));
// if quote < 0, hide quantity left, model, price, and quantity order
if(quote < 0){
g_form.clearValue('u_vendor');
g_form.setDisplay('u_quantity_left_2',false);
g_form.setDisplay('u_model_2',false);
g_form.setDisplay('u_price_2',false);
g_form.setDisplay('u_quantity_order_2',false);
} else {
g_form.clearValue('u_quantity_quoted');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 12:33 PM
Hi Alex,
You can create a UI policy to hide all the fields if " u_quantity_quote_2 " is blank. This wil take care of the vice versa case too i.e if it contains value the fields will not be hidden.
For the next part left i.e "u_quantity_quoted" should clear you can create a client script. Make sense?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 12:39 PM
That makes complete sense. that's what I am doing with the first order set, but I thought I would use a script because eventually there will be about 15 order sets the user could potentially fill out and I didn't want to make 16 different ui policies for one form. can I still use the same if script for hiding the variables in a ui policy? - I have never used scripts in a ui policy before.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 03:44 PM
Hi Alex,
Thanks for the update. So it means that when the record is created for the first time at that point of time there will be no validation. However after the record is submitted or if some one opens the same record then this validation should take place. Is that statement correct?
Please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2015 08:37 AM
that statement is correct, yes!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2015 01:47 PM
Hi Alex,
You can create a OnLoad client script. Here is the sample code. Basically this will only run after the record is created.
function onLoad() {
//Type appropriate comment here, and begin script below
if (!g_form.isNewRecord())
{
//yourcode
}
}
Please let me know if you are blocked and I can help you out.