Announcement

Collapse
No announcement yet.

Email template, a float number with 5 decimal places is rounded to 2 decimal places

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Email template, a float number with 5 decimal places is rounded to 2 decimal places

    I have a "float "number with 5 decimal places. When I upload it to an email template, it is rounded to 2 decimal places. It is important for me to have exactly 5 decimal places because this is the price of the quote and accuracy is very important.
    Already looked at all PHP files where there is "round", but did not find which function is responsible for loading data into a placeholder of Email Template
    Help me, please. How to fix it?

    У меня есть числа "float" с 5 знаками после запятой. Когда я загружаю их в шаблон электронной почты, то они округляются до 2 знаков после запятой. Для меня важно именно 5 знаков после запятой, потому что это цена котировки и точность здесь очень важна.
    Уже пересмотрел все PHP-файлы, где есть "round", менял тупо 2 на 5, но эффекта нет, не нашел, какая функция отвечает за загрузку данных в плейсхолдер шаблона электронной почты.
    Помогите мне, пожалуйста. Как это исправить?
    Last edited by sobolevfff; 06-25-2020, 08:45 PM.

  • #2
    I wrote a lengthy post but lost the post so I will be lazy with this post. Here how I did it with my formula, not sure if you can adopt it for email template or not:

    number\round(Analytics.entryPriceA, 5);

    Also refer to this if it help: https://docs.espocrm.com/administrat.../#numberformat

    Comment


    • #3
      As an option (only from 5.9.0):

      {{entryPlaceA_RAW}}

      or

      {{numberFormat entryPlaceA_RAW decimals=5}}

      Email templates support handlebars (same as pdf) but for a parent record.

      Comment


      • #4
        Thanks for the help!
        I created a new field with the formula entryPriceAS = number\format(entryPriceA, 5);.
        When loaded into the email template everything works fine.

        Comment


        • #5
          Originally posted by yurikuzn View Post
          As an option (only from 5.9.0):

          {{entryPlaceA_RAW}}

          or

          {{numberFormat entryPlaceA_RAW decimals=5}}
          Unfortunately, this does not work.

          Comment


          • #6
            sobolevfff Be careful if you use formula, you might get outdated info (in certain circumstances). Because formula will only activate after you Save or Modified a record.

            In relation to yuri Email template, I haven't tested it but did you update the field name to be right? Yuri wrote a generic one and not really relate to your field name. Secondly are you on version 5.9.0 or higher?

            Anyway yours would look like this:

            {{entryPriceA_RAW}}
            or possibly:
            {{Analytics.entryPriceA_RAW}}

            That "ParentsRecord" may also be giving you that "Not working" issue.
            Last edited by esforim; 06-26-2020, 08:08 AM.

            Comment


            • #7
              I have version 5.9.3
              Yes, I updated the fields before loading the template. When placeholder {{Analytics.entryPriceA_RAW}}, I didn’t have any data at all, an empty place in the letter.

              Comment


              • #8
                I suppose you could always try to see if you can reproduce on the demo server. Since I got free time I decide to give it a test on demo server. You are absolute right, none of the code I test worked (it currently under Contact if you want to give it a tweak or test before server reset).

                As usually I spam various code hoping one would work. Basically none of them worked, not sure why. Even the simple code did not work properly.

                Maybe you can report it as a bug(?).

                Code:
                {{floatTest_RAW}}
                
                {{Contact.floatTest_RAW}}
                
                {{numberFormat floatTest_RAW decimals=3}}
                
                {Contact.floatTest} //even this one didnt work
                
                {{Contact.floatTest}}
                
                {{numberFormat Contact.floatTest_RAW decimals=3}}
                Last edited by esforim; 06-26-2020, 08:43 AM.

                Comment


                • #9
                  It works 100%. {{numberFormat fieldName_RAW decimals=5}}

                  Parent field should be filled.

                  Comment


                  • #10
                    Very odd, last week time I try it didn't work at all, but I try again to this time to see how if I made a mistake. Manage to get one of the formula working. But where did I go wrong? Does it only work if it a Parent field?

                    Here some screenshot for better visualization.

                    Click image for larger version

Name:	Float test.png
Views:	588
Size:	123.4 KB
ID:	59929

                    Comment

                    Working...
                    X