On a Lead it is possible to insert Associations, when I qualify a Lead, a Opportunity is made, which shows Associations lines.
I want to insert the associations from the Lead into the opportunity in AX2012.
I have found out the associations in the Lead is using the smmLeadRelTable
, the Opportunity is using the smmOpportunityRelTable
.
How can i insert the association? I don't see the relation between these tables and I can't figure how to start to initialize these values?
The smmLeadRelTable
as well as the smmOpportunityRelTable
table references leads and opportunities using the RefTableId/RefRecId pattern. This pattern allows for generic references in cases where it is not clear at design time what tables will be referenced or where a number of different tables should be referenced. To create a reference, you would initialize the RefTableId
field with the id of the table that is to be referenced. You would then initialize the RefRecId
with the RecId of the record from that table that is to be referenced.
To fulfill your requirement you want to transfer the entries in smmLeadRelTable
to smmOpportunityRelTable
, replacing the LeadId
with the OpportunityId
. The entries in smmOpportunityRelTable
are created in method createLinkRelation
in class smmCreateEntity
. There you could add an EventHandler or edit the method directly to add your logic that will create an entry in smmOpportunityRelTable
for each opportunity relation in smmLeadRelTable
.