0
votes

Is there any possibility for adding thousand separator inside an Azure Logic App Expression?

I'm creating an Azure Logic App which sends an JSON to an REST Service. The JSON is build inside the Logic App with a Compose. The Data for the JSON comes from different REST Services.

The Services deliver me numbers like "13251", "11231543.3" etc.

I need to transform and send the numbers with thousand separator like "13.251", "11,231,543.3" etc.

My code looks like:

{
  "Item": {
    "nr": "@{body('current')?['nr']}",
    "amount": "@{body('current')?['amount']}",
  }
}

So I basically need something like: .ToString("#,##0.00")

"13251" => "13.251"

"11231543.3" => "11,231,543.3"

Thanks for your help!

3

3 Answers

0
votes

You cannot send numbers with thousand separators in Json, since it will invalidate the Json.

Consider this Json:

{
    "age": 123,456.0
}

This will be seen as:

{
    "age": 123,
    456.0
}

Which is invalid Json.

If you wish to format it as a string: there doesn't seem to be a conversion available to format numbers. There are several format-enabled conversions for DateTime.

More info: Reference guide to using functions in expressions for Azure Logic Apps and Microsoft Flow

0
votes

You might want to try the Execute JavaScript code action for this. Sample: enter image description here Hope this Helps!

0
votes

It can be achieved in logic app, but it's complicated. We can use "Math functions" in logic app(div and mod) and we also need to use "String functions", "if condition", "until" and initialize some variables. I achieved it by the actions and methods I mentioned above but it's too complicated. I think it is easy for us to do it by add additional code in azure function.