Case, what is a proper logic?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Russ
    Senior Member
    • Feb 2022
    • 423

    Case, what is a proper logic?

    Hi!
    A client sends an email, we check the case and assign it to someone, we write an email to the client, asking for his clarifications, and we use the general company mailbox to answer (info).
    Now, a client sends a reply with the details, but we all going to miss that email because the info mailbox belongs to all and everyone, should we have some sort of a notification that the case was updated with a new email?

    Probably something is already there but I am missing what, thank you!
  • Kharg
    Senior Member
    • Jun 2021
    • 410

    #2
    The assigned user and followers of the record should get a notification about a new email related to the case and the stream should get updated with the email content.



    Cases are used to keep track of issues, problems or failures that were reported by customers. They can be created both manually (by regular or portal users) and automatically (through a web form, workflow or email).

    Comment

    • Russ
      Senior Member
      • Feb 2022
      • 423

      #3
      Originally posted by Kharg
      The assigned user and followers of the record should get a notification about a new email related to the case and the stream should get updated with the email content.



      https://www.espocrm.com/features/cases/
      Can you please help me with a workflow trigger that I can use, instead of an email (too many), I would like to update a target case, like "action required: true"
      Thanks

      Comment

      • Kharg
        Senior Member
        • Jun 2021
        • 410

        #4
        Yes, just use the update related record workflow action in the email entity, should be easy or you can just use a formula to update the case if a new email gets related to the case record.

        Comment

        • Russ
          Senior Member
          • Feb 2022
          • 423

          #5
          Thanks, Kharg, how do I make "action required: false" once case was opened/viewed by anyone?

          Thanks

          Comment

          • Kharg
            Senior Member
            • Jun 2021
            • 410

            #6
            Hi Russ you can use a beforeRead hook, it’s quite easy
            take a look at this post of mine
            So, I am trying to setup a beforeRead hook but it isn't working correctly. I just want to update my status field from "Unread" to "Read" once the record has been opened but after I refresh the list view the status field is changed back to "Unread" List api returns a "Unread" status but


            then you will have to create the recordDefs for it

            Comment

            • Russ
              Senior Member
              • Feb 2022
              • 423

              #7
              Originally posted by Kharg
              Hi Russ you can use a beforeRead hook, it’s quite easy
              take a look at this post of mine
              So, I am trying to setup a beforeRead hook but it isn't working correctly. I just want to update my status field from "Unread" to "Read" once the record has been opened but after I refresh the list view the status field is changed back to "Unread" List api returns a "Unread" status but


              then you will have to create the recordDefs for it
              https://docs.espocrm.com/development...assnamelist​
              Thanks a lot!
              Where do I paste that code? I create a new file? In which folder?
              So, I am trying to setup a beforeRead hook but it isn't working correctly. I just want to update my status field from "Unread" to "Read" once the record has been opened but after I refresh the list view the status field is changed back to "Unread" List api returns a "Unread" status but


              In the recordDefs folder? How do I invoke it?

              Sorry, too many questions, I never did that

              Comment

              • Kharg
                Senior Member
                • Jun 2021
                • 410

                #8
                Russ If you provide me with your entity name and the field with its statuses I can help you.

                Comment

                • Russ
                  Senior Member
                  • Feb 2022
                  • 423

                  #9
                  Originally posted by Kharg
                  Russ If you provide me with your entity name and the field with its statuses I can help you.
                  The entity is "Case". Field name is "action required" (boolean)


                  When new ticket related email is in, action required==true
                  then when someone opened a ticket (case), it should change to action required==false


                  Thanks
                  Last edited by Russ; 06-22-2023, 05:24 PM.

                  Comment

                  • Russ
                    Senior Member
                    • Feb 2022
                    • 423

                    #10
                    Originally posted by Kharg
                    Yes, just use the update related record workflow action in the email entity, should be easy or you can just use a formula to update the case if a new email gets related to the case record.
                    Hi, can you please guide me on how to update a parent ticket when email was received and mark action required: true (boolean)?

                    Ticket is a Case (ticket is just a different label name)

                    Thanks
                    Attached Files

                    Comment

                    • Kharg
                      Senior Member
                      • Jun 2021
                      • 410

                      #11
                      CaseActionRequired.php in Espo\Custom\Hooks\Case folder
                      PHP Code:
                      <?php
                      
                      namespace Espo\Custom\Hooks\Case;
                      
                      use Espo\ORM\Entity;
                      use Espo\ORM\EntityManager;
                      use Espo\Core\Record\ReadParams;
                      use Espo\Core\Record\Hook\ReadHook;
                      
                      class CaseActionRequired implements ReadHook
                      {
                         private EntityManager $entityManager;
                      
                         public function __construct(EntityManager $entityManager)
                         {
                             $this->entityManager = $entityManager;
                         }
                      
                        public function process(Entity $entity, ReadParams $params): void
                        {
                             $actionRequired = $entity->get('actionRequired');
                             if ($actionRequired != false) {
                                 $entity->set('actionRequired', false);
                                 $this->entityManager->saveEntity($entity);
                             }
                        }
                      }
                      Case.json in Espo\Custom\Resources\metadata\recordDefs

                      PHP Code:
                      {
                          "beforeReadHookClassNameList": [
                              "Espo\\Custom\\Hooks\\Case\\CaseActionRequired"
                          ]
                      }

                      Comment

                      • Russ
                        Senior Member
                        • Feb 2022
                        • 423

                        #12
                        Originally posted by Kharg
                        CaseActionRequired.php in Espo\Custom\Hooks\Case folder
                        PHP Code:
                        <?php
                        
                        namespace Espo\Custom\Hooks\Case;
                        
                        use Espo\ORM\Entity;
                        use Espo\ORM\EntityManager;
                        use Espo\Core\Record\ReadParams;
                        use Espo\Core\Record\Hook\ReadHook;
                        
                        class CaseActionRequired implements ReadHook
                        {
                        private EntityManager $entityManager;
                        
                        public function __construct(EntityManager $entityManager)
                        {
                        $this->entityManager = $entityManager;
                        }
                        
                        public function process(Entity $entity, ReadParams $params): void
                        {
                        $actionRequired = $entity->get('actionRequired');
                        if ($actionRequired != false) {
                        $entity->set('actionRequired', false);
                        $this->entityManager->saveEntity($entity);
                        }
                        }
                        }
                        Case.json in Espo\Custom\Resources\metadata\recordDefs

                        PHP Code:
                        {
                        "beforeReadHookClassNameList": [
                        "Espo\\Custom\\Hooks\\Case\\CaseActionRequired"
                        ]
                        }
                        @Khrarg, thanks, this part worked!




                        but my number 10 question is also pending, thanks
                        Last edited by Russ; 06-26-2023, 04:27 PM. Reason: (link to text)

                        Comment


                        • Kharg
                          Kharg commented
                          Editing a comment
                          I will give you a solution as soon as possible, need some free time to write it
                      • rabii
                        Active Community Member
                        • Jun 2016
                        • 1250

                        #13
                        Originally posted by Russ

                        Hi, can you please guide me on how to update a parent ticket when email was received and mark action required: true (boolean)?

                        Ticket is a Case (ticket is just a different label name)

                        Thanks
                        Hey Russ

                        That should be easy to achieve. you can add a script formula and use record\update function to update the Case (Ticket) actionRequired field to be true. see attached screenshot.
                        Attached Files
                        Rabii
                        Web Dev

                        Comment


                        • Kharg
                          Kharg commented
                          Editing a comment
                          rabii now you have to tell us. How did you replace the checkbox with a switch?
                      • rabii
                        Active Community Member
                        • Jun 2016
                        • 1250

                        #14
                        Kharg

                        Customised existing field. https://docs.espocrm.com/development...andard-fields/

                        here is the custom field view bool.js

                        PHP Code:
                        define('custom:views/fields/bool', ['views/fields/bool'], function (Dep) {
                        
                            /**
                             * A boolean field (checkbox).
                             *
                             * @class
                             * @name Class
                             * @extends module:views/fields/bool.Class
                             * @memberOf module:views/fields/bool
                             */
                            return Dep.extend(/** @lends module:views/fields/bool.Class# */{
                        
                                listTemplate: 'custom:fields/bool/list',
                                detailTemplate: 'custom:fields/bool/detail',
                                editTemplate: 'custom:fields/bool/edit',
                                searchTemplate: 'fields/bool/search',
                        
                            });
                        });
                        edit.tpl
                        PHP Code:
                        <style>
                            .form-switch {
                              display: inline-block;
                              cursor: pointer;
                              -webkit-tap-highlight-color: transparent;
                            }
                            .form-switch i {
                              position: relative;
                              display: inline-block;
                              margin-right: .5rem;
                              width: 46px;
                              height: 26px;
                              background-color: #e6e6e6;
                              border-radius: 23px;
                              vertical-align: text-bottom;
                              transition: all 0.3s linear;
                            }
                            .form-switch i::before {
                              content: "";
                              position: absolute;
                              left: 0;
                              width: 42px;
                              height: 22px;
                              background-color: #f1f5f9;
                              border-radius: 11px;
                              transform: translate3d(2px, 2px, 0) scale3d(1, 1, 1);
                              transition: all 0.25s linear;
                            }
                            .form-switch i::after {
                              content: "";
                              position: absolute;
                              left: 0;
                              width: 22px;
                              height: 22px;
                              background-color: #f1f5f9;
                              border-radius: 11px;
                              box-shadow: 0 2px 2px rgba(0, 0, 0, 0.24);
                              transform: translate3d(2px, 2px, 0);
                              transition: all 0.2s ease-in-out;
                            }
                            .form-switch:active i::after {
                              width: 28px;
                              transform: translate3d(2px, 2px, 0);
                            }
                            .form-switch:active input:checked + i::after { transform: translate3d(16px, 2px, 0); }
                            .form-switch input { display: none; }
                            .form-switch input:checked + i { background-color: #10b981; }
                            .form-switch input:checked + i::before { transform: translate3d(18px, 2px, 0) scale3d(0, 0, 0); }
                            .form-switch input:checked + i::after { transform: translate3d(22px, 2px, 0); }
                        </style>
                        
                        <label class="form-switch">
                          <input type="checkbox" {{#if value}} checked{{/if}} data-name="{{name}}">
                          <i></i>
                        </label>
                        detail.tpl
                        PHP Code:
                        <style>
                            .form-switch {
                              display: inline-block;
                              cursor: pointer;
                              -webkit-tap-highlight-color: transparent;
                            }
                            .form-switch i {
                              position: relative;
                              display: inline-block;
                              margin-right: .5rem;
                              width: 46px;
                              height: 26px;
                              background-color: #e6e6e6;
                              border-radius: 23px;
                              vertical-align: text-bottom;
                              transition: all 0.3s linear;
                            }
                            .form-switch i::before {
                              content: "";
                              position: absolute;
                              left: 0;
                              width: 42px;
                              height: 22px;
                              background-color: #f1f5f9;
                              border-radius: 11px;
                              transform: translate3d(2px, 2px, 0) scale3d(1, 1, 1);
                              transition: all 0.25s linear;
                            }
                            .form-switch i::after {
                              content: "";
                              position: absolute;
                              left: 0;
                              width: 22px;
                              height: 22px;
                              background-color: #f1f5f9;
                              border-radius: 11px;
                              box-shadow: 0 2px 2px rgba(0, 0, 0, 0.24);
                              transform: translate3d(2px, 2px, 0);
                              transition: all 0.2s ease-in-out;
                            }
                            .form-switch:active i::after {
                              width: 28px;
                              transform: translate3d(2px, 2px, 0);
                            }
                            .form-switch:active input:checked + i::after { transform: translate3d(16px, 2px, 0); }
                            .form-switch input { display: none; }
                            .form-switch input:checked + i { background-color: #10b981; }
                            .form-switch input:checked + i::before { transform: translate3d(18px, 2px, 0) scale3d(0, 0, 0); }
                            .form-switch input:checked + i::after { transform: translate3d(22px, 2px, 0); }
                        </style>
                        
                        {{#if valueIsSet}}
                        <label class="form-switch">
                          <input type="checkbox" {{#if value}} checked{{/if}} disabled>
                          <i></i>
                        </label>{{else}}
                        <span class="loading-value">...</span>{{/if}}
                        list.tpl
                        PHP Code:
                        <style>
                            .form-switch {
                              display: inline-block;
                              cursor: pointer;
                              -webkit-tap-highlight-color: transparent;
                            }
                            .form-switch i {
                              position: relative;
                              display: inline-block;
                              margin-right: .5rem;
                              width: 46px;
                              height: 26px;
                              background-color: #e6e6e6;
                              border-radius: 23px;
                              vertical-align: text-bottom;
                              transition: all 0.3s linear;
                            }
                            .form-switch i::before {
                              content: "";
                              position: absolute;
                              left: 0;
                              width: 42px;
                              height: 22px;
                              background-color: #f1f5f9;
                              border-radius: 11px;
                              transform: translate3d(2px, 2px, 0) scale3d(1, 1, 1);
                              transition: all 0.25s linear;
                            }
                            .form-switch i::after {
                              content: "";
                              position: absolute;
                              left: 0;
                              width: 22px;
                              height: 22px;
                              background-color: #f1f5f9;
                              border-radius: 11px;
                              box-shadow: 0 2px 2px rgba(0, 0, 0, 0.24);
                              transform: translate3d(2px, 2px, 0);
                              transition: all 0.2s ease-in-out;
                            }
                            .form-switch:active i::after {
                              width: 28px;
                              transform: translate3d(2px, 2px, 0);
                            }
                            .form-switch:active input:checked + i::after { transform: translate3d(16px, 2px, 0); }
                            .form-switch input { display: none; }
                            .form-switch input:checked + i { background-color: #10b981; }
                            .form-switch input:checked + i::before { transform: translate3d(18px, 2px, 0) scale3d(0, 0, 0); }
                            .form-switch input:checked + i::after { transform: translate3d(22px, 2px, 0); }
                        </style>
                        
                        <label class="form-switch">
                          <input type="checkbox" {{#if value}} checked{{/if}} disabled>
                          <i></i>
                        </label>
                        I am just playing around but willing to build my own theme sometimes soon once i have enough time (it will be using tailwind css )
                        Rabii
                        Web Dev

                        Comment


                        • Kharg
                          Kharg commented
                          Editing a comment
                          Thank you for sharing

                        • rabii
                          rabii commented
                          Editing a comment
                          you are welcome mate

                        • rabii
                          rabii commented
                          Editing a comment
                          if you want to avoid repetition just add the css to a custom css file and use it instead of repeating the same css in each template, i just felt lazy to do it.
                      Working...