Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

How to Find a Percentage Using 3 Fields

Avatar

Level 2

I'm new to Livecycle Designer ES and I'd really appreciate some help.  Could someone please tell me how to script (Java Script or FormCalc) the following?

Field 1 (number field) is what percent of

Field 2 (number field) a second number

Field 3 is where the calculation result will display in percent (%)

Fields 1 and 2 are user entered fields.

Thanks for any help!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

FormCalc

// form1.page1.subform1.percent::calculate - (FormCalc, client)

if (hasValue(form1.page1.subform1.number1) & hasValue(form1.page1.subform1.number2)) then

     form1.page1.subform1.number1/form1.page1.subform1.number2

endif

JavaScript

// form1.page1.subform2.percent::calculate - (JavaScript, client)

if (form1.page1.subform2.number1.rawValue != null && form1.page1.subform2.number2.rawValue != null) {

     this.rawValue = form1.page1.subform2.number1.rawValue/form1.page1.subform2.number2.rawValue;

}

I use the display patterns, below. You can change them according to your needs.

number1 and number 2    num{zzzz9.99}

percent                          num{zz9.9999}

Steve

View solution in original post

3 Replies

Avatar

Correct answer by
Former Community Member

FormCalc

// form1.page1.subform1.percent::calculate - (FormCalc, client)

if (hasValue(form1.page1.subform1.number1) & hasValue(form1.page1.subform1.number2)) then

     form1.page1.subform1.number1/form1.page1.subform1.number2

endif

JavaScript

// form1.page1.subform2.percent::calculate - (JavaScript, client)

if (form1.page1.subform2.number1.rawValue != null && form1.page1.subform2.number2.rawValue != null) {

     this.rawValue = form1.page1.subform2.number1.rawValue/form1.page1.subform2.number2.rawValue;

}

I use the display patterns, below. You can change them according to your needs.

number1 and number 2    num{zzzz9.99}

percent                          num{zz9.9999}

Steve

Avatar

Level 2

Thanks Steve!

Your solution is dead ON!  Again, thanks for your help!

Avatar

Level 2

Thanks for your help Steve! Much appreciated...

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