Workflow - access targetRecord attribute when updating relatedRecord attribute

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Jakub Grufik
    commented on 's reply
    aight, thanks a lot for the info, appreciate it

  • rabii
    commented on 's reply
    I think targetEntity\attribute('amountConverted')​​ and workflow\targetEntity\attribute('amountConverted') and bpm\targetEntity\attribute(ATTRIBUTE) are all identical and they allow you to access targetEntity attributes.
    When using formula in a task that creates or updates another record, the current entity (for the script) is switched to the record you are creating. To access attributes of the target record you can utilize the function targetEntity\attribute(ATTRIBUTE).

    I have not used any of bpm or workflow syntax and always used targetEntity\attribute(ATTRIBUTE) which does always the job. remember you can add your own formula functions and use them in formula script.

  • Jakub Grufik
    replied
    hello rabii thanks a lot for the help.

    Could you please tell me if there is any difference between targetEntity\attribute('amountConverted')​​ and workflow\targetEntity\attribute('amountConverted') ?

    I am currently using workflow\targetEntity\attribute('amountConverted')​ in the workflow I was discussing above. To be honest I was not testing if its working properly.​​

    Leave a comment:


  • rabii
    commented on 's reply
    here is the documentation you asked for https://docs.espocrm.com/administrat...#formula-usage

  • rabii
    replied
    Originally posted by Jakub Grufik
    Hello guys,

    I am currently facing issues with one of my workflow, where I am targeting opportunities, but I would like to update the related record "Assigned User".

    Everything seems to be working fine except that I am trying to assign the value from targetRecord attribute(oportunity.amountConverted) to relatedRecord attribute(assignedUser.obrat).

    Syntax entity\attribute('amountConverted') seems to be taking value from the entity I am trying to update, not from the entity I am targeting with the workflow.

    Is there any other syntax how to access targetEntity attribute when updating relatedEntity attribute?

    Hopefully, it is clear what I am trying to achieve (screen1, screen2)

    ​Thanks a lot for the help!
    you can simply use targetEntity\attribute('amountConverted')​ check out the documentation here https://docs.espocrm.com/administrat...#formula-usage this works for both bpmn and workflows.

    Leave a comment:


  • Jakub Grufik
    commented on 's reply
    will check, thanks a lot. That would be all from my side for today, have a nice rest of the day buddy

  • lazovic
    commented on 's reply
    This part of the documentation describes this feature:
    https://docs.espocrm.com/administrat...ing/#attribute.

  • Jakub Grufik
    commented on 's reply
    just for you to know, here "$contactId = workflow\targetEntity\attribute('contactId');" I am using attribute 'contactId', but I was not able to find this attribute in Administration > Entity Manager -> Opportunity -> Fields, is ID something special that is not being displayed anywhere?

  • Jakub Grufik
    commented on 's reply
    damn, that is actually true I am just so stupid that I have not realized which is related to which.. thanks again man, I am already looking into it and slowly but surely starting to understand it more deeply

  • lazovic
    commented on 's reply
    There is no need to include possible values for the Entity Type and Attributes in the documentation, because these are all individual and generally easy enough to look up in your own instance.

    You just need to go to Administration > Entity Manager and work with the names of the required entities (important: not with Labels, but with Names). Similarly, you need to work with attributes: go to Administration > Entity Manager > the entity you need > Fields and focus on fields names (not labels).

    You have no need to apologize, I perfectly understand you and will gladly help you figure it out.

  • Jakub Grufik
    replied
    lazovic oh, sorry I forgot to ask you one more question - the last one for the next hour I promise

    Is there by any chance a list or documentation with possible values that can be used in the formula to target specific ENTITY_TYPE and its ATTRIBUTE? I would love to have it to be able to use the full potential of formulas.

    Basically possible values for "ENTITY_TYPE, and possible values for its ATTRIBUTE (screen1)

    That would be all for today I guess

    Thanks a lot one more time and sorry for spamming!
    Attached Files

    Leave a comment:


  • Jakub Grufik
    commented on 's reply
    Thanks a lot, my friend! As always, very very helpful information.

    I appreciate your valuable time.

  • lazovic
    commented on 's reply
    Yes, exactly, you understood everything correctly.

  • Jakub Grufik
    replied
    lazovic oh yeah thanks a lot man! this actually makes sense.

    Please correct me if I am wrong - the syntax I used before with "contact.adressState" was trying to take value from relatedRecord contact, which according to the used syntax should be related to assignedUser not to the opportunity, right? Hence there would be empty value, cause assigned user does not have related entity "contact", correct?
    Attached Files

    Leave a comment:


  • lazovic
    commented on 's reply
    In the last action of this Workflow, before the existing lines, add these lines:

    $contactId = workflow\targetEntity\attribute('contactId');
    $contactAddressState = record\attribute('Contact', $contactId, 'addressState');

    And then in the existing formulas, replace contact.addressState with $contactAddressState.
Working...