Search code examples
axaptadynamics-ax-2012x++role

How to assign contact Role by code?


I have to assign a Role for a Customer?

I am creating a Customer, after that, for creating a role,

I have already the contact in GlobalAddressBook , I want to add a ROLE for this contact, I don't wanto to create a new record in DirPartyTable.

I use this code:

DirPartyRelationship::createRecordRelations("Vendor" , CompanyInfo::find().RecId , this.findDirPartyRecid().RecId , curext());

I created a record on Table DirPartyRelationship , but on GlobalAddress form (in HomePage) I can't find the new role for my Vendor.

I sow some classes : DirParty , and nother, but I don't know how to use? If I have to use.

Is there a class for creating a role by code? I don't know how I to do this.

Thanks all,

Enjoy! I appreciate your help!!


Solution

  • I found one of the possible solution.

    If I already have a contact (example Vendor o Customer) I have to take its value in field Party and use this value forcing in the same field in the Cust/Vend Table.

    Exaple: if I have a Customer, go on VendTable, I take the value in Party field. When I create in CustTable my new Customer I force the value taken into in VendTablein field CustTable.Party.

    Automatically when I create a customer create a new role, with this system associate a Role.(for my Company).

    If you have more information updated my answer. Thanks all!

    References:

    https://community.dynamics.com/ax/f/33/t/170776 ;

    https://community.dynamics.com/ax/f/33/t/174210?pi51736=1#responses ;

    https://msdn.microsoft.com/en-us/library/vendtable.aspx .