create relationship between contact and opportunity in a drawer

hi,

i've the following context.

after a change of a field on contact. i display the drawer in order to create an opportunity.

i've got a n,n relationship between these modules.

i don't succeed in creating relationship between the opportunity i've created in my drawer and the contact.

the opportunity is created but nothing in subpanel in both module.

here is my code :

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
openDrawer: function(contact) {
var opportunityLie = app.data.createBean("Opportunities");
app.drawer.open({
layout: "create",
context: {
create: true,
module: 'Opportunities',
model: opportunityLie,
}
}, function (context, newModel) {
if (newModel && newModel.id) {
var collectionContact = newModel.getRelatedCollection('contacts');
collectionContact.add(contact);
}
});
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Parents
  • Hi ,

    In the drawer context, you are passing incomplete information. As there is a relationship in both modules then during record creation there is a need to use LinkedModel Plugin so that whenever Opportunity will create, the parent information will auto-populate. 

    You need to set app.plugins.plugins.view.LinkedModel.createLinkModel(context.parent.get('model'), linkName) in model of context object.

    Hope it will help!

Reply
  • Hi ,

    In the drawer context, you are passing incomplete information. As there is a relationship in both modules then during record creation there is a need to use LinkedModel Plugin so that whenever Opportunity will create, the parent information will auto-populate. 

    You need to set app.plugins.plugins.view.LinkedModel.createLinkModel(context.parent.get('model'), linkName) in model of context object.

    Hope it will help!

Children
No Data