Announcement

Collapse
No announcement yet.

Case, what is a proper logic?

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

  • 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!

  • #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


    • #3
      Originally posted by Kharg View Post
      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


      • #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


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

          Thanks

          Comment


          • #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


            • #7
              Originally posted by Kharg View Post
              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


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

                Comment


                • #9
                  Originally posted by Kharg View Post
                  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


                  • #10
                    Originally posted by Kharg View Post
                    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


                    • #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 $entityReadParams $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


                      • #12
                        Originally posted by Kharg View Post
                        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 $entityReadParams $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

                      • #13
                        Originally posted by Russ View Post

                        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?

                      • #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 {
                              
                        displayinline-block;
                              
                        cursorpointer;
                              -
                        webkit-tap-highlight-colortransparent;
                            }
                            .
                        form-switch {
                              
                        positionrelative;
                              
                        displayinline-block;
                              
                        margin-right.5rem;
                              
                        width46px;
                              
                        height26px;
                              
                        background-color#e6e6e6;
                              
                        border-radius23px;
                              
                        vertical-aligntext-bottom;
                              
                        transitionall 0.3s linear;
                            }
                            .
                        form-switch i::before {
                              
                        content"";
                              
                        positionabsolute;
                              
                        left0;
                              
                        width42px;
                              
                        height22px;
                              
                        background-color#f1f5f9;
                              
                        border-radius11px;
                              
                        transformtranslate3d(2px2px0scale3d(111);
                              
                        transitionall 0.25s linear;
                            }
                            .
                        form-switch i::after {
                              
                        content"";
                              
                        positionabsolute;
                              
                        left0;
                              
                        width22px;
                              
                        height22px;
                              
                        background-color#f1f5f9;
                              
                        border-radius11px;
                              
                        box-shadow0 2px 2px rgba(0000.24);
                              
                        transformtranslate3d(2px2px0);
                              
                        transitionall 0.2s ease-in-out;
                            }
                            .
                        form-switch:active i::after {
                              
                        width28px;
                              
                        transformtranslate3d(2px2px0);
                            }
                            .
                        form-switch:active input:checked i::after transformtranslate3d(16px2px0); }
                            .
                        form-switch input displaynone; }
                            .
                        form-switch input:checked background-color#10b981; }
                            
                        .form-switch input:checked i::before transformtranslate3d(18px2px0scale3d(000); }
                            .
                        form-switch input:checked i::after transformtranslate3d(22px2px0); }
                        </
                        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 {
                              
                        displayinline-block;
                              
                        cursorpointer;
                              -
                        webkit-tap-highlight-colortransparent;
                            }
                            .
                        form-switch {
                              
                        positionrelative;
                              
                        displayinline-block;
                              
                        margin-right.5rem;
                              
                        width46px;
                              
                        height26px;
                              
                        background-color#e6e6e6;
                              
                        border-radius23px;
                              
                        vertical-aligntext-bottom;
                              
                        transitionall 0.3s linear;
                            }
                            .
                        form-switch i::before {
                              
                        content"";
                              
                        positionabsolute;
                              
                        left0;
                              
                        width42px;
                              
                        height22px;
                              
                        background-color#f1f5f9;
                              
                        border-radius11px;
                              
                        transformtranslate3d(2px2px0scale3d(111);
                              
                        transitionall 0.25s linear;
                            }
                            .
                        form-switch i::after {
                              
                        content"";
                              
                        positionabsolute;
                              
                        left0;
                              
                        width22px;
                              
                        height22px;
                              
                        background-color#f1f5f9;
                              
                        border-radius11px;
                              
                        box-shadow0 2px 2px rgba(0000.24);
                              
                        transformtranslate3d(2px2px0);
                              
                        transitionall 0.2s ease-in-out;
                            }
                            .
                        form-switch:active i::after {
                              
                        width28px;
                              
                        transformtranslate3d(2px2px0);
                            }
                            .
                        form-switch:active input:checked i::after transformtranslate3d(16px2px0); }
                            .
                        form-switch input displaynone; }
                            .
                        form-switch input:checked background-color#10b981; }
                            
                        .form-switch input:checked i::before transformtranslate3d(18px2px0scale3d(000); }
                            .
                        form-switch input:checked i::after transformtranslate3d(22px2px0); }
                        </
                        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 {
                              
                        displayinline-block;
                              
                        cursorpointer;
                              -
                        webkit-tap-highlight-colortransparent;
                            }
                            .
                        form-switch {
                              
                        positionrelative;
                              
                        displayinline-block;
                              
                        margin-right.5rem;
                              
                        width46px;
                              
                        height26px;
                              
                        background-color#e6e6e6;
                              
                        border-radius23px;
                              
                        vertical-aligntext-bottom;
                              
                        transitionall 0.3s linear;
                            }
                            .
                        form-switch i::before {
                              
                        content"";
                              
                        positionabsolute;
                              
                        left0;
                              
                        width42px;
                              
                        height22px;
                              
                        background-color#f1f5f9;
                              
                        border-radius11px;
                              
                        transformtranslate3d(2px2px0scale3d(111);
                              
                        transitionall 0.25s linear;
                            }
                            .
                        form-switch i::after {
                              
                        content"";
                              
                        positionabsolute;
                              
                        left0;
                              
                        width22px;
                              
                        height22px;
                              
                        background-color#f1f5f9;
                              
                        border-radius11px;
                              
                        box-shadow0 2px 2px rgba(0000.24);
                              
                        transformtranslate3d(2px2px0);
                              
                        transitionall 0.2s ease-in-out;
                            }
                            .
                        form-switch:active i::after {
                              
                        width28px;
                              
                        transformtranslate3d(2px2px0);
                            }
                            .
                        form-switch:active input:checked i::after transformtranslate3d(16px2px0); }
                            .
                        form-switch input displaynone; }
                            .
                        form-switch input:checked background-color#10b981; }
                            
                        .form-switch input:checked i::before transformtranslate3d(18px2px0scale3d(000); }
                            .
                        form-switch input:checked i::after transformtranslate3d(22px2px0); }
                        </
                        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...
                      X