Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!
SOLVED

Referencing Variables declared in another field?

Avatar

Level 1

Sorry if this is common knowledge, but how can I reference the value of a variable created in one field from another field?

For example field "subTotal" contains a variable called rSubTotal

A function inside another field ("total") wants to call the current value of rSubTotal.

How can I achieve this in LiveCycle Designer?

Thank you and have a wonderfuld day,

Brandon Boswell

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

You can cast it as on Int/Float by using parseInt or parseFloat when you use it. Unfortunately those vars are strings only.

Paul

View solution in original post

5 Replies

Avatar

Former Community Member

The scope of the variable is only for the duration of the script. You coudl write the result of the var to a hidden field and then reference the hidden field.

Paul

Avatar

Level 1

Is there anyway to pass the variable without the hidden field?

Avatar

Former Community Member

You can create a gloabal variable in the Form Properties (under variables). Remember to get the value of that var you will need to access the value property not the rawValue property.

Paul

Avatar

Level 1

I tried using global variables, but always recieved errors because Global Variables are of the type "string" and not integers. Is there a way to create a global variable that is an integer.

Avatar

Correct answer by
Former Community Member

You can cast it as on Int/Float by using parseInt or parseFloat when you use it. Unfortunately those vars are strings only.

Paul

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] ----