Prefill field with value of former record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saschavalentin
    Junior Member
    • Jan 2018
    • 14

    Prefill field with value of former record

    Is it possible to prefill a field of an entity with a value of another of the previous record?

    For example: In entity "custom1" there are the fields "field1", "field2", "field3". When adding a new record "field2" should be prefilled with the value of "field3" from the previous entered record.
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello
    if you want to prefill, but not set the value after record saved, you need to develop it.
    if after record saved set is good for you and If records (previous and current) are related, you can do it only with formula or with workflow.

    Comment

    • saschavalentin
      Junior Member
      • Jan 2018
      • 14

      #3
      Hi Tanya,

      thank you. It would be better to prefill the field so you can see it when the new record is entered, but I´m not a developer ;-) and so I´m not sure how to do this.

      So I have to go the other way. And in that case: How do I relate two records?

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        You can create a Relationship in Entity Manager https://www.espocrm.com/video/entity-manager/

        Comment

        • saschavalentin
          Junior Member
          • Jan 2018
          • 14

          #5
          Thats true. But can I relate to the same entity? Related to itself? I thought it must be a foreign one.

          Comment

          • tanya
            Senior Member
            • Jun 2014
            • 4308

            #6
            Yes, foreign entity could be the same as target entity. For example, the task could have subtasks. You can implement it with Relationships.

            Comment

            • saschavalentin
              Junior Member
              • Jan 2018
              • 14

              #7
              Thanks again. I´ll give it a try

              Comment

              • saschavalentin
                Junior Member
                • Jan 2018
                • 14

                #8
                Now I´ve worked one week but didn´t get this running. My thoughts were this: Reference the field of the related entity with linkName.attributeName
                But how do this get the right value from the last record? Do I have to add some SQL-statement?

                Comment

                • tanya
                  Senior Member
                  • Jun 2014
                  • 4308

                  #9
                  Better to search data with ORM https://www.espocrm.com/documentatio...r-content-find
                  What is done and where did you stop?

                  Comment

                  • saschavalentin
                    Junior Member
                    • Jan 2018
                    • 14

                    #10
                    Okay, I´ve created a relation between "Fahrtenbuch" entity and itself and then entered
                    anfangskm=$entityManager->getRepository('Fahrtenbuch')->limit(0, 10)->order('endkm', true)->find();

                    But that doesn´t work. I´m not sure if ORM commands could be entered in formula??

                    Comment

                    • tanya
                      Senior Member
                      • Jun 2014
                      • 4308

                      #11
                      No, formula-language has a limited functionality, described here https://www.espocrm.com/documentatio...ation/formula/
                      You can use in related record field, but you can not find any other record....

                      Comment

                      Working...