Send additional information to the logic hook

I was familiar with Sugar 6.5. Now I'm learning how to work with recent versions but is hard to change the mindset.

I'm working in a custom module. I've created a custom button to duplicate a record and create a new version of the record.
I've extend record view and I'm able to create the duplicate record using the drawer.open layout:create

I need to send some extra information for the logic hook before_save so I can diferenciate from a create record and a new version create record.

How can I send additional information to the logic hook?
For example send a control variable like subaction=newVersion

Is it possible for someone to direct me towards a path?

Parents
  • Hey  ,

    From the backend perspective, a new record is no different from a copy of an existing record, so this can be tricky to achieve at the logic hook level.

    Perhaps you could try a different approach: extending the create API for the module you work with? Try it out

    And then on the frontend you could use something like: 

    this.model.isCopy()

    Which could help you determine if it is a new record or a copy. I have not tried this right now, just looked quickly at the code, so please feel free to verify it works.

    I've recently achieved wonders by differentiating the behaviour for creation and update, at the API level for a customer of mine.

    Hope it helps

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States

Reply
  • Hey  ,

    From the backend perspective, a new record is no different from a copy of an existing record, so this can be tricky to achieve at the logic hook level.

    Perhaps you could try a different approach: extending the create API for the module you work with? Try it out

    And then on the frontend you could use something like: 

    this.model.isCopy()

    Which could help you determine if it is a new record or a copy. I have not tried this right now, just looked quickly at the code, so please feel free to verify it works.

    I've recently achieved wonders by differentiating the behaviour for creation and update, at the API level for a customer of mine.

    Hope it helps

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States

Children