I have a table getting the value from lookup, in one of them the user should enter a numeric value, how to set max and min value in the numeric column depending on another column in the same table
Question
Question
Answer
you will always know how many loops you will do because the number of TR's and find that you use to specify the specific column in that table will be specific to the look up rule values generated.
like table A .. look up generated 10 rows...
when you do your onlookupcompleted or onlookupcomplete onlookupfinished
https://answers.laserfiche.com/questions/181863/How-to-use-the-javascript-lookupcoplete-events **** good copy of sample code
you want to iterate thru table A and find column value for max purchase and then do you logic.
Multiple tables doesn't matter because your code will find the speicic class you want to iterate through.
TIPS::: Run through the code step by step.. and make sure that you are iterating through the form at the correct time.
post code if doenst work.
Replies
are you talking about creating a limit in the column value of a look up table? or you talking about the user input of a table in laserfiche forms .. a particular user input column value needs to have a min max?
if you talking about the table in laserfiche forms then you should be able to select the column value option button so that you can add like min max and variable name etc .. heres an image of what it would look
i need to add min and max dynamically depending on the value from other columns
ex:
i have a column with maximum purchase of 70 items, the user will fill another column how many items you can request, but it shouldn't exceed max value
so that means you have some logic to get the min and max values?
are they coming from look up as well?
the column with maximum purchase allowed from the lookup.
okay i would add another column value you and call it max purchase .. hide the value .. use the fx function of the Number value in advanced and you should be able to reference the column value max purchase.. use some math logic that im sure you can figure out to make it so that if its over your max value you will give it 0
**make sure to save the data
so each user input number value will output a function using max purchase value to add a character that will create an error.. you can add some javascript logic to tell user hey you cant add this value because its over the max purchase limit of this column.
i think user value mod max purchase output value to do what you want
make sense?
it makes sense, but there is nothing out of the box to add the max and min as variables or formulas.
yeah .. would be nice tho but probably not a lot of users need that
Without using JS, you could add a hidden field that could have a formula to see if the value entered was greater than the Max value from the lookup, using that to trigger a rule to show a custom HTML Field (Value is out of range).
We went down the JS route and created a Popup and hide the Submit button until the values were fixed. Ours wasn't in a table but same concept.
if I did the same for the table getting data from lookup I have to go through each row and add a condition with JS, and this is in case I know how many rows will be returned from DB.
or loop it with row count to add a condition with JS. and this is only for one table what if my form has multiple tables. I think I'll do it that way for now.
you will always know how many loops you will do because the number of TR's and find that you use to specify the specific column in that table will be specific to the look up rule values generated.
like table A .. look up generated 10 rows...
when you do your onlookupcompleted or onlookupcomplete onlookupfinished
https://answers.laserfiche.com/questions/181863/How-to-use-the-javascript-lookupcoplete-events **** good copy of sample code
you want to iterate thru table A and find column value for max purchase and then do you logic.
Multiple tables doesn't matter because your code will find the speicic class you want to iterate through.
TIPS::: Run through the code step by step.. and make sure that you are iterating through the form at the correct time.
post code if doenst work.