How can I target a specific record in a formula?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Christian Lietzke
    Junior Member
    • Jul 2021
    • 14

    How can I target a specific record in a formula?

    Hi everybody,

    I have a small problem, I hope you could help me dealing with.

    I use two custom entities called "stamps" and "outbox". The "stamps" entity contains 3 records named "head office", "Division North" and "Division South". Each of these records contain number-fields for several used stamps.
    The "outbox" entity contains a record for every letter sent from the 3 divisions of our company. Among other info, each record has an enum-field for the division and the used stamp.

    My problem is, how can I target the correct record/attribute from within a formula in a workflow?
    The trigger works just fine, so I can activate a formula when the record is saved and it contains the wanted division- and stamp-fields. I just don't know how to tell the formula editor how to target the specific record of the "stamps" entity.

    When I check the formula within the formula sandbox I can select the target type (i.e. "stamps") and the target (i.e. the record named "head office") which works fine, but how can I parse this into a formula?

    Hope you can help me.

    Kind regards,
    Chris
  • Vadym
    Super Moderator
    • Jun 2021
    • 345

    #2
    Hi Christian,

    Please describe what you are trying to achieve in more detail, and we will find the best solution for you.
    Also, provide a formula you have and screenshots if you can.

    Perhaps these threads will be helpful:



    Comment

    • Christian Lietzke
      Junior Member
      • Jul 2021
      • 14

      #3
      Hi Vadym,

      I've attached 2 screenshots, hope they help.

      What I try to do is:
      We use a custom entity to track every letter/parcel/etc. that leaves our company. (Postausgänge) When a letter is send out, our secretary adds a new record with a generated number (Ausgangsnummer), the actual date (Ausgangsdatum), the recipient (Empfänger/Kontakt), any needed remarks (Bemerkungen) and the postage costs (Porto) for this letter.
      The postage field is an enum field containing the available stamps.

      The stamps entity contains the number of the available stamps (Briefmarken) in each of our divisions (head office, north, south).

      What I want to do now for example is:
      I send a letter out using a stamp worth 0,85 Euro. So I generate a record for this letter and select the correct postage cost (porto) in the used field.
      When this entry is saved, the workflow should subtract 1 from the corresponding field (Briefmarke 0,85€) in the correct record of the stamps entity.

      This should work pretty easily, but I don't know how to target a specific record within the stamps entity to subtract 1 stamp from the correct field.
      When try this with the formula sandbox, I can define the entity (target type) and record (target) I would like to use, but within the formula editor of a workflow I would have to adress the correct record from within the formula.

      Hope this clarifies what I need to know.

      Comment

      • Christian Lietzke
        Junior Member
        • Jul 2021
        • 14

        #4
        Funny thing is, when I read the docs about the record-function again and tried to explain what I needed in the post above, I suddenly understood how it worked and what I need.
        The problem is easy to solve, I just thought too complicated.

        The formula I use now is:

        $recordID=record\findOne('Briefmarkenverwaltung', 'createdAt', 'desc', 'cuBMBT=', 'Stammhaus');
        $pwz085=record\attribute('Briefmarkenverwaltung', $recordID, 'cuBMV085');
        $pwz085sub=$pwz085-1;
        record\update('Briefmarkenverwaltung', $recordID, 'cuBMV085', $pwz085sub)

        Thanks for pointing me in the right direction.

        Comment

        • Vadym
          Super Moderator
          • Jun 2021
          • 345

          #5
          Christian,

          We're glad you solved the issue.

          All the best

          Comment

          Working...