Adding Content - Intermediate
  1. Knowledge Base
  2. Customer Portal
  3. Adding Content - Intermediate

How do I correct the format of a back office value?

Sometimes the answer provided back from back office APIs is in a format one would not want to show the customer. I.e. Next Payment Date for Benefits is returned with a timestamp:

01/01/2017 00:00

 

So clearly we want to be able to cut that out.

Within the editor it is possible to format the answers using extra snippets of text.

 

Convert a date to drop the timestamp

The following illustrates the Next Payment Date example above. One can see that to remove the timestamp the highlighted part needs to be added to the end of the Data Field in question:

${NextPayment.Date.ToString("dd/MM/yyyy")}

I.e. copy and paste this:  .ToString("dd/MM/yyyy")  to the end of the template field that is a date.

You can break a date into its constituent elements:

  • The following will convert the date into just the date of the month:

${Claim.Hb.Entitlement.StartDate.ToString("dd")}

  • This will convert the month e.g. 10 to the month into the word October

${Claim.Hb.Entitlement.StartDate.ToString("MMMM")}

  • And this will change the date to only show the year e.g. 2018

${Claim.Hb.Entitlement.StartDate.ToString("yyyy")}


Convert a long decimal to only have two decimal places

In some cases the back office APIs actually provide an answer like this: 1244.0323232

Whereas obviously you would want the customer to see:
1244.03

The following will ensure that this formatting is applied to the value:

${PropertyBand.FullYearCharge.ToString("f")}