I can't seem to link or add an Activity to a Sales opportunity stage via the SDK. I am doing it during the addition of the Activity by assigning the fields SalesOpportunityId and SalesOpportunityLine with the desired LineNum and the Activity's DocEntry respectively.
The resulting Activity is not connected with a Sales opportunity, its SalesOpportunityId and SalesOpportunityLine containing null. The Sales opportunity exists in the B1 database and I have no problem additing to it an Activity via user interface.
Here's how I do it: http://pastebin.com/2MGg0TAK. Could you help me make it work?