How to create a dynamicLogic for Opportunity age ??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nishan Perera
    Active Community Member
    • Jan 2019
    • 348

    How to create a dynamicLogic for Opportunity age ??

    Hi,

    I want a field which is to show age of a particular opportunity with dynamic logic. opportunity age field read only and should update automatically ?? how it can be done ?

    any help ??
    Cheers!
    Nishan.
  • Maximus
    Senior Member
    • Nov 2018
    • 2731

    #2
    Hi,
    If you are talking about auto-counting of the age field, you can use scheduled workflow with a report.

    Comment

    • Nishan Perera
      Active Community Member
      • Jan 2019
      • 348

      #3
      Originally posted by Maximus
      Hi,
      If you are talking about auto-counting of the age field, you can use scheduled workflow with a report.
      I tried that, But it change the data modify date and the user. is it possible to do without update those data ?
      Cheers!
      Nishan.

      Comment

      • Maximus
        Senior Member
        • Nov 2018
        • 2731

        #4
        As far as I know there is no such an ability.

        Comment

        • yuri
          Member
          • Mar 2014
          • 8451

          #5
          Create a notStorable field and define SQL in "select" in entityDefs. Example here: https://forum.espocrm.com/forum/deve...storable-bools

          You need something like this:

          Code:
          "ageDays": {
              "type": "int",
              "notStorable": true,
              "readOnly": true,
              "select": "DATEDIFF(NOW(), created_at)",
              "orderBy": "DATEDIFF(NOW(), created_at) {direction}"
          }
          Last edited by yuri; 05-27-2020, 09:23 AM.
          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

          • Nishan Perera
            Active Community Member
            • Jan 2019
            • 348

            #6
            Originally posted by yurikuzn
            Create a notStorable field and define SQL in "select" in entityDefs. Example here: https://forum.espocrm.com/forum/deve...storable-bools

            You need something like this:

            Code:
            "ageDays": {
            "type": "int",
            "notStorable": true,
            "readOnly": true,
            "select": "DATEDIFF(NOW(), created_at)",
            "orderBy": "DATEDIFF(NOW(), created_at) {direction}"
            }
            Thank you for the code yuri. without entering table name i'm getting "Internal server error 500".

            For me this worked

            custom\Espo\Custom\Resources\metadata\entityDefs\O pportunity.json

            Code:
            {
                "fields": {
                    "oppAge": {
                        "type": "int",
                        "notStorable": true,
                        "select": "DATEDIFF(NOW(), opportunity.created_at)",
                        "orderBy": "DATEDIFF(NOW(), opportunity.created_at) {direction}",
                        "readOnly": true,
                        "isCustom": true
                    }
                }
            }
            Thank you for the support .!
            Last edited by Nishan Perera; 06-02-2020, 06:59 PM.
            Cheers!
            Nishan.

            Comment

            • Nishan Perera
              Active Community Member
              • Jan 2019
              • 348

              #7
              Hi yuri,

              I need some support on opportunity age calculation which is now working perfectly. Thing is I want to stop the age calculation if stage change to closed won or closed lost.

              Is this possible to achieve ? Let me know.
              Cheers!
              Nishan.

              Comment

              • Nishan Perera
                Active Community Member
                • Jan 2019
                • 348

                #8
                Hi Maximus , Could you also advice me on above which is "stop the age calculation if stage change to closed won or closed lost."
                Cheers!
                Nishan.

                Comment


                • Maximus
                  Maximus commented
                  Editing a comment
                  Hi,
                  Sorry, can't help here. It is out of my skills.
              • Nishan Perera
                Active Community Member
                • Jan 2019
                • 348

                #9
                yuri could you please help me on this. appreciate your support.
                Cheers!
                Nishan.

                Comment

                • Nishan Perera
                  Active Community Member
                  • Jan 2019
                  • 348

                  #10
                  Originally posted by Nishan Perera
                  yuri could you please help me on this. appreciate your support.
                  yuri Can you support me on this ?
                  Cheers!
                  Nishan.

                  Comment

                  • Nishan Perera
                    Active Community Member
                    • Jan 2019
                    • 348

                    #11
                    Is there anyone can help me on this ?
                    Cheers!
                    Nishan.

                    Comment

                    Working...