Announcement

Collapse
No announcement yet.

Formula in Case

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

  • Formula in Case

    Hello
    At "E-mail to case" I try to evaluate the e-mail address of the sender with formula. Unfortunately my code does not work:

    ifThen(string\contains(inboundEmail.emailAddress, '.de'), country = ' Germany');

    Does anyone have a tip that might help me
    Thanks.
    Peter

  • #2
    Hi Peter,
    I've tested it and it works for me. What type of field for the 'address' field do you use? I am using the 'address' type and called my field 'address'. So in Formula I use 'addressCountry'. Check in the attribute list how your address field is properly defined.

    Comment


    • #3
      Thank you, Maximus,
      the field "country" is a custum one selection field. One option of this field is "Germany".
      Probably you cannot describe a selection field like this.
      Last edited by peterberlin; 04-24-2020, 12:04 PM.

      Comment


      • #4
        Hi Peter,

        Is 'country' is a field in Case entity type?

        Comment


        • #5
          Hi Yuri,

          Yes. But that's not it. I've also tested other fields.
          This code is not working:
          string\contains(inboundEmail.emailAddress, '.de')

          I want to check the incoming e-mail (e-ail to case) which TLD it is.
          Last edited by peterberlin; 04-25-2020, 02:39 PM.

          Comment


          • #6
            Try to use record\findOne

            Code:
            // find first email related to case
            $id = record\findOne('Email', 'createdAt', false,
                'parentType=', 'Case',
                'parentId=', entity\attribute('id')
            );
            
            // if found
            ifThen($id,
               // get email address
               $emailAddress = record\attribute('Email', $id, 'fromEmailAddressName');
               $emailAddress = string\lowerCase($emailAddress);
            
               // check TLD
               $isDe = string\substring($emailAddress, -3) == '.de';
               ifThen($isDe,
                   entity\setAttribute('country', 'Germany');
               );
            );
            Last edited by yuri; 04-25-2020, 03:38 PM.

            Comment


            • #7
              Hi, Yuri,
              Thank you very much. But the code didn't work.
              I put it into a workflow (record new).

              Comment


              • #8
                Hi, Yuri,
                I put your code in the Entity and it works there.
                Thank you very much.
                You can also use string\contains.
                I have to check the sender name as well as the e-mail address. What is the name of the variable? fromEmail???????????????

                Comment


                • #9
                  It's the sender name in the code.

                  Code:
                   
                   $emailAddress = record\attribute('Email', $id, 'fromEmailAddressName');
                  If you need "To" name it's more tricky to fetch it.

                  Comment


                  • peterberlin
                    peterberlin commented
                    Editing a comment
                    Thanks. I'll use it as far as it goes. It's already a big help.
                Working...
                X