Announcement

Collapse
No announcement yet.

Want to automatically populate QuoteItems based on account_id?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Want to automatically populate QuoteItems based on account_id?

    Task entity in the db has a field called account_id. I want to automatically populate QuoteItem based on the account_id in the Task table. So when creating an invoice, and user selects an account name from Quote entity->account field, QuoteItems populate. If I was to use a query, it would look something like this: "SELECT task.* FROM account INNER JOIN task ON account.id = task.account_id AND task.status = 'Completed' ". If it was manually creating a relationship in entitydefs->task.json/quoteitem.json, it may look something like this:

    //Task entity
    //Task.json
    {
    "links": {
    "quoteitem": {
    "type": "hasMany",
    "foreign": "task",
    "entity": "QuoteItem",
    "isCustom": true
    }
    }
    }


    //QuoteItem entity
    //QuoteItem.json
    {
    "task": {
    "type": "link"
    }
    },
    "links": {
    "task": {
    "type": "belongsTo",
    "foreign": "quoteitems",
    "entity": "Task",
    "isCustom": true
    }
    }
    }

    Not too sure how and where(folder/file) to do this. May I have some assistance?

  • #2
    You can create Hook (in Hooks folder) for Quote record. And define afterSave or beforeSave method.

    Comment


    • #3
      yuri Which file are you referring to regarding "Quote record"? Espo/modules/advanced/hooks/quote/quoteitem.php?

      Comment


      • #4
        yuri Would appreciate as much help you can give. I'm on a timetable and I thank you for being patient with me.

        Comment

        Working...
        X