Announcement

Collapse
No announcement yet.

How to initialize a field with value of a field in the linked table during create?

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

  • How to initialize a field with value of a field in the linked table during create?

    e.g.
    initialize a field lastname during create in the table project-position with the value of the field lastname from the n:1 linked table project, that also contains the field lastname (in the creating-form before saving)

    Christoph

  • #2
    If you have an ID of a related record (if it's passed in a link field, e.g. projectId), you can utilize record\update formula function.

    You can also utilize a Workflow tool from Advanced Pack that will update a related entity upon record creation.

    Comment


    • #3
      thanks yuri (again for your help)

      I've made the Workflow ... but it need some tries. Until I used
      (my 1:n is: 1 project : n project-positions):
      a formular in the entity.projekt-positions where the content has to be taken from the entity.project (formular: entitycurrentId = entitylinkedID)
      AND the same formular in the Workflow-action for the entity.project-positions,
      the Workflow works :-)

      Now I try to create a Workflow which updates the €-sum-field in the entity.project of all linked entities.projekt-positions.
      (the same 1:n is: 1 project : n project-positions)
      ​The Workflow must be create for the entity.project ... but with which trigger? The right trigger would be after create (or update) one of the entity.project-positions
      So I thought, first it need 2 Signals: create.project-positions and update.project-positions
      But how to create this?
      and second it needs in Formular of the Workflow for project the @<name of the signal>​

      Christoph
      P.S.
      I read the documentation ... more than on time, but sorry, I can't understand it - may be my understanding of the espo-deeps are not good enough. But I'll struggle with this wonderful software. (... a example sometimnes would be helpfull)
      P.P.S:
      I want to replace a crm-software (written in java, custom-designed with javascript and SQL), runs for 25 years in a german company for more than 300 people, with espo-crm. It's still working, but it becomes more and more difficult to run it with current OS, current java and current database-version (I use the great FirebirdDB). So I've found espo-crm, made a try and start the "upgrading".

      Comment


      • #4
        It's not very clear for me what exactly you want to achieve.

        Whenever a specific project field is changed, to copy the new value to related records?

        Comment


        • #5
          Good morning yuri, thank you for your time
          My goal is: if I changed the amount in a record (the n in 1:n) in project-positons (the price of a machine) or if a create a new record in project-positons with a another price, I want so change the field sum-prices-of-all-positions in the higher-level entity projects (the 1 in 1:n). The formula in the entirty projects (to build the the sum) "runs" only, if the project-record was changed and saved.
          I thought, I need signals for project-positions (update or create) to start a workflow in the entity projects.
          If this advisement is ok, then I want to know, how (and where) create the signals. Or is there a better way to reach the goal?

          Christoph

          Comment


          • #6
            Hi ctheuring,

            If you want the Project record to change the value of the sum-prices-of-all-positions field when we create a related Project Position with the amount field filled in or change the amount field value of the linked Project Position, you should use Workflow:
            • Target Entity​: Project Position
            • Trigger Type: After record saved (created or updated)
            • Actions:
              Update Related Record > Project
              Code:
              sumAmount = entity\sumRelated('projectPositions', 'amount');
              	​
              ​​

            Comment


            • #7
              The last line (duplicate formula) is redundant.

              ctheuring, please let me know if you have any difficulties or questions with this solution.

              Comment


              • #8
                lazovic - you made my day :-) ... and I have learned another solution about espo - thanks.

                The outcome of this is: how to update sumAmount if a projectPositon is deleted?
                I made a Workflow with
                • Target Entity​: Project Position
                  Trigger Type: ... ops, there is no Trigger ) after (or before) delete... so I tried after record updated ... but I promised, that there is no update by a deletion.
                  Actions:
                  Update Related Record > Project​
                -> it doesn't run - as expected.
                Do you have still also a solution?

                Christoph







                Comment


                • #9
                  ctheuring,

                  You should create another workflow to recalculate the value of sumAmount field after the related Project Position has been deleted:

                  Click image for larger version

Name:	image.png
Views:	154
Size:	51.7 KB
ID:	99053

                  Formula used:
                  Code:
                  sumAmount = entity\sumRelated('projectPositions', 'amount');
                  You can learn more about signals in workflows here:​​​​​​​​ https://docs.espocrm.com/administrat...object-signals.
                  ​​

                  Comment


                  • #10
                    Originally posted by lazovic View Post
                    ctheuring,

                    You can learn more about signals in workflows here:​​​​​​​​ https://docs.espocrm.com/administrat...object-signals.
                    ​​
                    I've read it, but now I understand, that the Built-in signals must not declared ... sorry, sometimes it's difficult to understand "out-of-the-box" explanations in a foreign language.

                    Now this one (of my current problems/questions) running. But these questions are better in another post.
                    Thanks a lot

                    Christoph

                    Comment


                    • #11
                      I recommend to keep learning the signals for the last. They are mostly needed for more complex BPM processes.

                      Comment

                      Working...
                      X