Expand my Community achievements bar.

SOLVED

Using Hidden Fields as Variables

Avatar

Level 7

I am limited in my JavaScript coding abilities. I am building a rather large homeowners insurance application that ultimately computes the premium. There are a ton of options that affect costs and I need a way to store a few numeric values. LC Designer doesn't appear to allow numeric variables (only string variables). As a work around, I have started to setup some hidden numeric fields to store some values and have their values change according to the users actions. I think this is going to work but is inefficient--the PDF ends up containing a lot of information about these hidden fields that is totally irrelevant to the task being asked of them. I thought I should ask a couple of questions before I get too far down the path I am taking.

My question #1: what are the other caveats in doing it this way?

My question #2: is there a better way or work-around that is relatively easy to do? (I am not stupid, but I am not much of a coder either). If someone could provide an example of something that can act like a numeric variable (easily accessed & changed) I would be most grateful.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

If I do a serach in the Designer Help there is plenty of information on variables. It talks about creating them, their scope and even gives examples. The only thing it doesn't talk about is your question about arrays. The var cannot hold an array ...but I have seen people use a scripting object to define the array for global use.

Paul

View solution in original post

7 Replies

Avatar

Former Community Member

Using hidden fields to store temporary values is quite common.  How many hidden fields are you using?  How many do you think you need?  I would be too worried this making the form "inefficient" unless the number of hidden fields is quite large.

My two cents

Steve

Avatar

Level 7

I will be using about 5 to 8 hidden fields as variables.

Avatar

Former Community Member

The other solution is to create global variables to hold your info (Form Properties/Variables) but from an efficiency perspective it ends up being the same thing.

Paul

Avatar

Level 4

Don't worry... 8 fields are like nothing...

I have a similar issue due to the different number/date patterns of different countries. So I need to overgive the values and change the specific patterns in a hidden field. So I do have 2 large tables which don't matter much.

(After the mail with the xml arrives the difference between the formats  999,999 (other ways to write: Ger 999,999; Swiss 999 999) and 999.999 (other ways to write: Ger 999 999, Swiss 999.999) can't be detected.)

Avatar

Level 7

Paul,

I have tried without success using the form properties variables tab for entering variables. There is absolutely no documentation on the specific manner in which this is done, or whether it can accommodate arrays. I mean absolutely no documentation that I can find other than references to the LC feature like: "enter variables in the variables tab of the form properties," period. Great! but tell me more please, like specifically how?

Other than the name of the variable and a value, are there supposed to be:    

  • " ' "
  • " " "
  • "var"
  • "="
  • syntax needed, you get my drift, I hope.

And, what about arrays? And, does it matter if these values are intended to be numeric?

I think I would prefer to use the variables tab because it centralizes their location, and in some cases I may need to change ones I might use as constants, down the road. This becomes much handier for that.

Stephen

Avatar

Correct answer by
Former Community Member

If I do a serach in the Designer Help there is plenty of information on variables. It talks about creating them, their scope and even gives examples. The only thing it doesn't talk about is your question about arrays. The var cannot hold an array ...but I have seen people use a scripting object to define the array for global use.

Paul

Avatar

Level 7

Thank you! Paul  I had thoroughly read the LC help and looked online as well, but my coding efforts fell short, and I couldn't make it work. Now, it works like a charm! And, it's so simple.  I really am not certain what I was doing wrong, except maybe making it seem harder than it really was. But this is a great breakthrough for me! This helps tremendously.  Stephen

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----