Announcement

Collapse
No announcement yet.

[Formula Question] Email Formula

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

  • [Formula Question] Email Formula

    Anyone play or create Formula for email? It look like there is some hidden trick we must also perform to get it to work.

    It work for my Sandbox but it doesn't work when I actual use the formula.

    Here is my sample Formula:

    Custom field: emailCatgeory is a Multi-Enum I'm using as test.

    Sandbox
    Code:
    output\print(
       ifThenElse(!entity\isNew() && fromAddress=='test@email.com', emailCategory=list('found email'), emailCategory=list('TRY AGAIN'))
    )​
    Note I use !entity because Sandbox will only work with existing record.

    Click image for larger version  Name:	image.png Views:	0 Size:	2.7 KB ID:	98222

    API Save Formula:

    Code:
    ifThenElse(entity\isNew() && fromAddress=='test@email.com', emailCategory=list('found email'), emailCategory=list('TRY AGAIN'))
    But this is the result I get instead
    Click image for larger version  Name:	image.png Views:	0 Size:	4.9 KB ID:	98223

  • #2
    - I created a field emailCategory​ with Multi-Enum type, with options: found email and TRY AGAIN (screenshot 1).
    - I changed your formula slightly to:​
    Code:
    ifThenElse(
        entity\isNew = true && fromAddress == 'test@gmail.com',
        emailCategory = list('found email'),
        emailCategory = list('TRY AGAIN')
        );​
    Everything worked for me (screenshot 2).
    Attached Files

    Comment


    • #3
      EDIT: SEE COMMENTS BELOW. Initial test is working! I'll try to play with it and update.

      Originally posted by victor View Post

      Everything worked for me (screenshot 2).
      Thank you Victor! Did you use API Before Save Script? I tried it and it doesn't work for me. It no problem if I use Sandbox, work fine there.

      Look at the code, I thought maybe there an error so I tried which way:

      entity\isNew == true

      Which will give you an Error 500 when you try to send a test email so it not that. Maybe it this I thought:

      entity\isNew() = true // still error, wishful thinking.

      The only thing I change from the formula is the email part, I thought it would be a typo on my end but that not the case since it work Perfectly when using Sandbox. I wanted to test to the Demo.espocrm.com but there don't have Email set up.
      Last edited by esforim; 10-06-2023, 07:01 AM.

      Comment


      • esforim
        esforim commented
        Editing a comment
        EDIT: HURRAY, it look like it working. The secret is to use it in Before Save rather than than API Before Save... we really need a more better wait to word these two formula option

      • victor
        victor commented
        Editing a comment
        I used "Before Save Custom Script".

      • esforim
        esforim commented
        Editing a comment
        Thank you again victor
    Working...
    X