Problems with a formula in Cases

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pehoma
    Member
    • Aug 2022
    • 52

    Problems with a formula in Cases

    Hello again,

    I need again some help with a formula in the entity cases.
    With every incoming email the system generates a case. If the case already exist the system should change the status of that case to "new from email". This is done by a formula and works. But the status of the case also change to "new from email" when we send an email related to the case. We don't want that.
    The formula we use so far is the following:

    ifThen(
    entity\isNew() == true && record\exists('Email', 'subject=', name) = true && createdById == 'system',
    status = 'newfrommail'
    );​

    Could someone help me to adjust this formula so that only in case on an oncoming email related to a case the status of this case changes to "new from email" but when we send an email related to this case the status will NOT be changed.

    Thanks
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #2
    Hi,
    test this : i dont know if createdById is filled there.

    ifThen(
    entity\isNew() && record\exists('Email', 'subject=', name) && createdById == 'system',
    status = 'newfrommail'
    );​​
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • victor
      Active Community Member
      • Aug 2022
      • 727

      #3
      Hi pehoma,

      Please try this formula.
      If it doesn't work for you, write to me and we will adjust it.
      Code:
      ifThen(
          entity\isNew() == true && record\exists('Email', 'subject=', name, 'status=', 'Archived') = true && createdById == 'system',
          status = 'created by mail'
          );​
      Last edited by victor; 09-02-2022, 10:17 AM.

      Comment

      • yuri
        Member
        • Mar 2014
        • 8440

        #4
        This wrong:
        Code:
        record\exists('Email', 'subject=', name, 'status=', 'Archived') = true

        Should be:
        Code:
        record\exists('Email', 'subject=', name, 'status=', 'Archived')
        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

        • pehoma
          Member
          • Aug 2022
          • 52

          #5
          Thank you all for your replies, but unfortunately it's not working. Maybe I haven't explained it correctly.

          We have a group email account and various personal accounts. So incoming mails in the group account are checked if there is an existing case, if not the system creates a new case. That's standard function from the system.
          What we want to have, is that the cases created from an incoming email have status "newfrommail". Also the replies to existing cases. That means that if the case is actual in status closed, and the client send an email as a reply, the case will be again in status "newfromemail". This worked correct with the formula we had:
          ifThen(
          entity\isNew() == true && record\exists('Email', 'subject=', name) = true && createdById == 'system',
          status = 'newfrommail'
          );​​

          But the problem with this formula is, that also when we send an email related to a case, the status changes to new from email. Here an example:
          Incoming mail from client a, not related to an existing case: The system creates a new case, status is "newfrommail"
          one of our team checks the case and change the status to "assigned"
          now the team member send an email to the client out of the case. With the formula we have right now, the status changes now to "newfromemail", but it should not change the status. Only by incoming mails not by outgoing mails.

          I hope I could explain my problem better.
          Thanks for your help

          Comment

          • victor
            Active Community Member
            • Aug 2022
            • 727

            #6
            Hi pehoma,


            Your version of the formula is missing the 'Archived' part. The new version of the formula should look like this:
            Code:
            ifThen(
            entity\isNew() == true && record\exists('Email', 'subject=', name, 'status=', 'Archived') = true && createdById == 'system',
            status = 'newfrommail'
            );​​


            or like this:
            Code:
            ifThen(
            entity\isNew() == true && record\exists('Email', 'subject=', name, 'status=', 'Archived') && createdById == 'system',
            status = 'newfrommail'
            );​​
            ​​
            Last edited by victor; 09-04-2022, 03:00 PM.

            Comment

            Working...