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 :

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);
            } 
        });
    }

Parents Reply Children
No Data