Convert an excel formula into javscript for livecycle

Avatar

Avatar

boden75

Avatar

boden75

boden75

02-08-2016

Wondering if someone can help me out by making this functional in Livecycle. Thank You

If (DecimalField2 < 1, DecimalField4, DecimalField8)

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

mattiaswallin

Avatar

mattiaswallin

mattiaswallin

03-08-2016

Okay then the code will be:

     if (DecimalField4.rawValue < 1){

          DecimalField25.rawValue = DecimalField2.rawValue

     }

     else {

          DecimalField25.rawValue = DecimalField4.rawValue

     }

And to make it more rigid use full paths to your fields, for example "form1.page1.DecimalField4.rawValue".

And this code should be entered on the calculate event for the DecimalField25 I would say. (could probably be used on an exit event of DecimalField4 aswell, seeing it seems like you do a lookup on that value).

Hope this has helped, if it works please mark my answer as correct.

Regards, Mattias

Answers (2)

Answers (2)

Avatar

Avatar

boden75

Avatar

boden75

boden75

03-08-2016

I will try to explain a bit better what I'm trying to do.

In a decimal field(DecimalField25), I would like that field to look at another decimal field(DecimalField4). If the value in DecimalField4 is less than 1, then look at another decimal field(DecimalField2) and use the value that was entered into DecimalField2 and input it into DecimalField25. If the value in DecimalField4 is greater than 1, then simply use the value that was entered into DecimalField4 and input it into DecimalFeidl25.

Hope this explains things a bit better. Thank You

Avatar

Avatar

mattiaswallin

Avatar

mattiaswallin

mattiaswallin

02-08-2016

Okay, I am not perfectly skilled in excel, but from what I know of their if statements, that code would be written as =IF(DecimalField2 < 1, DecimalField4, DecimalField8). And that would mean "if decimalfield2 is less than one, enter decimalfield4 in the field in which this function is written, else enter decimalfield8."

Therefore it is a bit hard to understand what you want to achieve... It would have helped if you would have simply wrote two sentences of about what you want to achieve. However, doing my own interpretation that you want this in a decimalfield of it's own (which I will name DecimalField1) the code would look like:

     if (DecimalField2.rawValue < 1){

          DecimalField1.rawValue = DecimalField4.rawValue

     }

     else {

          DecimalField1.rawValue = DecimalField8.rawValue

     }

So, this is the real answer to your question, however I am afraid it is a bit lackluster, but then you need to ask better questions.

And I would also encourage you to learn the concepts of if statements, it is such a core method of any programming, scripting aswell. So if you are doing anything code related, you really should know how to search for if statement syntaxes and such.

Hope this was to some help.

Regards, Mattias