record \ find syntax question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alexander Singer
    Junior Member
    • Jan 2020
    • 4

    record \ find syntax question

    Hello together,

    for some testings I am using the ESPOCRM demo

    Inside this demo i've added a formula in fomula field to entitiy "account"

    $someVariableName='IDAccount';
    $IDAccount=accountId;
    $someVariableName='IDAuftrag';
    $IDAuftrag=record\findRelatedOne('Account',$IDAcco unt,'quotes','dateOrdered','desc');
    letzterAuftrag=record\attribute('Quote',$IDAuftrag ,'dateOrdered');


    "letzterAuftrag" is a new field created in account.

    Unfortunatley i do not what i did wrong, as it is not working. Currently it just shows no result

    What I want is to review all connected entities "Quote" for each "Account" and want to show on "Account" page the latest date when a customer did an order. so to show "dateOrder" out of "Quote"-Entity inside "Account"-Entity

  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Hi,

    Formula script is executed when target record (account in your case) is saved. For your requirement it won't work.

    You can use scheduled workflow that will run with interval, take all accounts (via specified report) and apply formula (with Update Target Record action).
    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

    • Alexander Singer
      Junior Member
      • Jan 2020
      • 4

      #3
      I know, that the script is just executed when the target record is saved, but even i update the target record manually i do not have any results.

      Comment

      • Alexander Singer
        Junior Member
        • Jan 2020
        • 4

        #4
        any Ideas?

        Comment

        • Maximus
          Senior Member
          • Nov 2018
          • 2731

          #5
          Hi Alexander,
          Do you have Advanced Pack? If so, I suggest you investigate the solution described by yurikuzn. Otherway you have to develop a custom hook for your purpose https://github.com/espocrm/documenta...pment/hooks.md.

          Comment

          Working...