Rounding numbers in Design Studio Portal Page Designer

Sort:
You are not authorized to post a reply.
Author
Messages
Jill
Basic Member
Posts: 7
Basic Member
    I'm trying to create a simple, little report in Portal Page Designer.  It will be a listing showing managers their direct reports' vacation balances in EMSS.
     
    How can I round a Lawson number field?  Available Hours is stored in the database as 53.758834 -- so that's how it is displayed on my report.  They want it rounded to 2 decimal places.
     
    I'm guessing there is a straightforward way to do this.  But I'm pretty new to Design Studio and JavaScript.
     
    Thanks for the help!
    TracyO
    Veteran Member
    Posts: 97
    Veteran Member
      Jill
      I had the same problem with my amounts, This should work for you:

      /***************************************************************/

      // New in process verson

      function roundToPennies(n)

      {

      pennies = n * 100;



      pennies = Math.round(pennies);



      //pennies = pennies / 100 ;



      strPennies = pennies;



      return strPennies;

      }
      Gary Davies
      Veteran Member
      Posts: 248
      Veteran Member

        That will work. There is a javascript function that already does this though called toFixed you use as such:

        Total = Total.toFixed(2)

        This rounds the variable Total to 2 decimals.
        Jill
        Basic Member
        Posts: 7
        Basic Member
          Thanks!  Both of those seem like simple enough JavaScript functions.

          Follow-up (really) dump question...so, how do I call this function?  My first attempt uses a Data Query block and the source contains NUGGLETS.  Do I have to do the whole query in JavaScript to make formatting changes?

          I warned you I was new to Design Studio and JavaScript!

          Thanks for you help!
          You are not authorized to post a reply.