Possibility to put variable into Wysiwyg

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jakub Grufik
    Senior Member
    • Aug 2022
    • 361

    Possibility to put variable into Wysiwyg

    Hello,
    I would like to ask you if there is any possibility to use variables inside Wysiwyg field.

    I am trying to fill Wysiwyg via workflow with some variable/attribute we have in our project + some formatting, I tried pretty much everything that I know from other languages like:
    testWysiwyg = <p>variableName</p> or testWysiwyg = <p>$variableName</p> or ​​​​​​​testWysiwyg = <p>{variableName}</p> and a lot of other syntaxes.

    However, none of the above is working and I was not able to find any info about this topic.

    ​​​​​​​Thanks a lot in advance!
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1606

    #2
    I guess, it is not possible. The editor (summernote) is quite restrict and strips out, what not should be inserted, e.g. code.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8453

      #3
      > The editor (summernote) is quite restrict and strips out, what not should be inserted, e.g. code.

      It's not true. We have placeholders for email templates, we have BPM process variables for emails.
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • yuri
        Member
        • Mar 2014
        • 8453

        #4
        You can use a formula string\replace function to replace placeholders with needed values.
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        • Jakub Grufik
          Senior Member
          • Aug 2022
          • 361

          #5
          Sorry but I dont get it.
          I cannot use string function on wysiwyg which is not technically string its html..

          Tried:
          testDelete = '<p>{datumDalsiAktivity}</p>';
          string\replace(testDelete, {datumDalsiAktivity}, datumDalsiAktivity)​

          Where datumDalsiAktivity is the variable I need to use in Wysiwyg..it is obviously not working.

          I assume there is no way to put variable into wysiwyg then, right? Which is huge shame, cause now I am not able to use styles on the variable I need to display on the Opportunity(with red background).. Click image for larger version

Name:	wysiwyg_variable.jpg
Views:	585
Size:	20.9 KB
ID:	82531

          Comment

          • yuri
            Member
            • Mar 2014
            • 8453

            #6
            > it is obviously not working.

            A non-valid code won't be working.

            > wysiwyg which is not technically string its html..

            Wrong.

            > I assume there is no way to put variable into wysiwyg then, right?

            Wrong.

            > Which is huge shame

            This makes me feel frustrated.


            You need something like:

            Code:
            yourWysiwygFieldName = string\replace(yourWysiwygFieldName, '{datumDalsiAktivity}', 'SOME_TEXT_JUST_FOR_TEST');
            Make sure you have the placeholder '{datumDalsiAktivity}' intact in your wysiwyg. Use the code-view for this.

            Last edited by yuri; 09-01-2022, 10:36 AM.
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment

            • Jakub Grufik
              Senior Member
              • Aug 2022
              • 361

              #7
              You are right, I am so sorry for my hasty conclusion about this topic.

              It is somehow starting to work as I would expect, I was just using the wrong syntax and logic.

              Will keep you updated once I have an acceptable solution.

              Thank you very much sir!

              Comment

              • Jakub Grufik
                Senior Member
                • Aug 2022
                • 361

                #8
                Man, you are a GOD!

                Finally it is working. Formula used:
                testDelete = '<p><font style="background-color: rgb(231, 99, 99);">{somePlaceholder}</font></p>';
                testDelete = string\replace(testDelete, '{somePlaceholder}', datetime\format(datumDalsiAktivity, 'Europe/Amsterdam', 'DD.MM.YYYY HH:mm'))

                I had to use datetime\format because I was getting different date format even at a different timezone(probably the system's default timezone).

                The good thing is that I am now getting what I want!

                Thank you thousand times for your advice. One more time, sorry for being a dummy at the beginning.​

                Comment

                Working...