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