Formula in 'Before Safe Custom Script' not executed in all cases.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ednt
    Member
    • May 2022
    • 32

    Formula in 'Before Safe Custom Script' not executed in all cases.

    Hi,

    the title is wrong, but I can not change it. It should be:

    'After Safe Custom Script' is needed


    I wrote a small script which updates some custom fileds in an entity from a linked account when it is saved.
    In general this works, if I use 'Edit' and 'Save' in the entity.

    The problem is, that the fields are not updated when I change the linked account after pressing update.
    If I use something like

    Code:
    description = datetime\now();
    it works, but not if I try to replace a custom field with an entry from the new selected account.
    Maybe the actual link is still the old one.

    The following example replaces description with the value from the old account.description, but not with the description from the new selected account.
    Code:
    description = account.description;
    It looks that I need an 'After Save Custom Script'

    How can I solve this?
    Last edited by Ednt; 04-20-2023, 01:13 PM.
  • yuri
    Member
    • Mar 2014
    • 8619

    #2
    Hi,

    If you have advanced pack, you can add AfterSave scripts with the Workflow tool.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • Ednt
      Member
      • May 2022
      • 32

      #3
      I tried something like:
      Code:
      description = record\attribute('Account', record\findOne('Account', accountId, 'desc', 'accountId=', accountId), 'description');
      But how can I access the changed accountId ?

      Comment

      • Ednt
        Member
        • May 2022
        • 32

        #4
        We own the advanced pack, so I will look inside the Workflow rules.
        Thank you.

        Comment

        Working...