Hello,
I have a custom entity for WhatsApp in my instance, whenever we receive a whatsapp message a new post gets created in the stream, if the message is a pdf/image that's what get posted.
This entity has an ActionButton to create a Lead from the WhatsApp conversation if No lead is already present.
I 'd like to copy all the attachments in the WhatsApp conversation stream to the lead Attachments field in Lead, would that be possibile?
What's the best way to achieve that? a Hook? Adding the attributes to the handler??
This is my current code.
WhatsApp-handler.js
I have a custom entity for WhatsApp in my instance, whenever we receive a whatsapp message a new post gets created in the stream, if the message is a pdf/image that's what get posted.
This entity has an ActionButton to create a Lead from the WhatsApp conversation if No lead is already present.
I 'd like to copy all the attachments in the WhatsApp conversation stream to the lead Attachments field in Lead, would that be possibile?
What's the best way to achieve that? a Hook? Adding the attributes to the handler??
This is my current code.
WhatsApp-handler.js
Code:
define('custom:WhatsApp-handler', ['action-handler'], function (Dep) { return Dep.extend({ actionNewLead: function() { var attributes = {}; attributes.phoneNumber = this.view.model.get('from'); attributes.whatsAppId = this.view.model.get('id'); attributes.whatsAppName = this.view.model.get('name'); attributes.source = "WhatsApp"; var scope = 'Lead' var router = this.getRouter(); router.dispatch(scope, 'create', { attributes: attributes, }); }, initNewLead: function () { this.controlButtonVisibility(); this.view.listenTo( this.view.model, 'change:leadId', this.controlButtonVisibility.bind(this) ); }, controlButtonVisibility: function () { if (this.view.model.get('leadId') === null) { this.view.showHeaderActionItem('NewLead'); return; } this.view.hideHeaderActionItem('NewLead'); }, }); });
Comment