How to update follow up status using formula

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ivan2805
    Junior Member
    • Jul 2022
    • 24

    How to update follow up status using formula

    Hi Everyone,

    I just started using EspoCRM for the compan9y i worked for, i find it awesome to use with, however i have a question.

    I'm trying to create a field that flag has this leads alredy being follow up or not, so i can put it in the list and detail layout, however I want this field to be updated automatically when a call / meeting is created.

    I've created a new field in leads entity called Follow Up using Boolean, however I dont know how to achieve this using formula.

    FYI, I don't have advance pack, and I'm not a programmer, so I don't really understand how to use formula at all.

    Can someone here please explain to me on how to achieve this.

    Thank you in advance for the answer.
  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    #2
    best way to handle this is to add formula to both meeting and call and check if the record is new and their parentType == Lead then update the parent record:

    Formula for Call entity:

    Code:
    ifThen(entity\isNew() && parentType == "Lead",
    
    record\update('Lead', parentId, 'followUp', true)
    
    )
    Formula for Meeting entity:

    Code:
    ifThen(entity\isNew() && parentType == "Lead",
    
    record\update('Lead', parentId, 'followUp', true)
    
    )
    Please replace the field followUp with the exact field defined on lead entity.

    Hope this helps
    Rabii
    Web Dev

    Comment

    • ivan2805
      Junior Member
      • Jul 2022
      • 24

      #3
      Ho Rabii

      Thank you so much for the code, i have tested it and it works fine.

      Comment

      • ivan2805
        Junior Member
        • Jul 2022
        • 24

        #4
        HI Rabii

        I've tried to put the same formula in entity opportunity to update the field automatically, but it's not working, do you think i need to put a different code for the formula in opportunity, please advice.

        Thank you in advance

        Comment

        • rabii
          Active Community Member
          • Jun 2016
          • 1250

          #5
          what do you want to achieve on opportunity. of course this could will not work on opportunity formula because there is no parentType. just explain what you need to achieve on opportunity and i am happy to provide you with necessary code.
          Rabii
          Web Dev

          Comment

          • ivan2805
            Junior Member
            • Jul 2022
            • 24

            #6
            Hi @rabii

            So the above code are working fine, everytime there's a call or meeting executed, the follow up field turn to true, however there are some cases where when we have leads and directly in that same day the it should be converted to opportunity, because we meet the leads and inputted it at the same day, so no need to log a call or a meeting.

            When this is happend, the follow up status remain false, how to change it to true just like what happend with the call and meeting using the above code.

            Thank you so much un advance for your help

            Comment

            • rabii
              Active Community Member
              • Jun 2016
              • 1250

              #7
              Hi

              if i understand well your required, you wanted when a lead is converted to an opportunity to mark the lead as follow up true, try the code below on the opportunity formula:

              Code:
              ifThen(entity\isNew() && originalLeadId,
              
              record\update('Lead', originalLeadId, 'followUp', true)
              
              )
              Rabii
              Web Dev

              Comment

              • ivan2805
                Junior Member
                • Jul 2022
                • 24

                #8
                Hi rabii,

                I've tried, however unfortunately its not working, could there be some mistake on the formula?

                Comment


                • rabii
                  rabii commented
                  Editing a comment
                  try this instead, put this code on your lead formula and please change field followup to your field name:

                  Code:
                  ifThen(entity\isAttributeChanged('status') && entity\attribute('status') == "Converted" && entity\attribute('createdOpportunityId'),
                  
                  entity\setAttribute('followup', true)
                  
                  )
                  i have tested this code and it works.
              • ivan2805
                Junior Member
                • Jul 2022
                • 24

                #9
                Thanks it works perfectly

                Comment

                Working...