Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

number_format

Avatar

Level 3

Hello

Is there a function (number_format) in liveCycle who can change a number style for exemple :

5000 => 5 000

50000 => 50 000 ...

In need to do it into a long String.

Thanks

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

How about this?

Untitled.png

A hidden numeric field (product) generates the formatted result.

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

if (HasValue(multiplicand) & HasValue(multiplier)) then

  $.rawValue = multiplicand * multiplier

else

  $.rawValue = null

endif

The visible result field (product_) uses the formatted value of the hidden result, globally replace commas with spaces and adds the result to a text string.

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

if (form1.page1.product.isNull) {

  this.rawValue = null;

}

else {

  var productFormatted = product.formattedValue;

  var comma = /\,/g;

  this.rawValue = "The answer is " + productFormatted.replace(comma," ") + ".";

}

Steve

View solution in original post

4 Replies

Avatar

Former Community Member

The display of a text field or numeric field is not necessarily the way the value assigned to the object is stored. There are display patterns that can be used to differentiate the display from the value used in a operation.

Could you be more specific?

Steve

Avatar

Level 3

Hello

I need to write in textField the result of a calcul. But i want to write this result in with some text exemple :

var resultCalcul=3000 *10;

myfield.rawValue = "My text "+resultCalcul+" End of my result"; // i want ti write resultCalcul lick this 30 000

Thanks

Avatar

Correct answer by
Former Community Member

How about this?

Untitled.png

A hidden numeric field (product) generates the formatted result.

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

if (HasValue(multiplicand) & HasValue(multiplier)) then

  $.rawValue = multiplicand * multiplier

else

  $.rawValue = null

endif

The visible result field (product_) uses the formatted value of the hidden result, globally replace commas with spaces and adds the result to a text string.

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

if (form1.page1.product.isNull) {

  this.rawValue = null;

}

else {

  var productFormatted = product.formattedValue;

  var comma = /\,/g;

  this.rawValue = "The answer is " + productFormatted.replace(comma," ") + ".";

}

Steve

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