cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to modify the Consolidating BP code using SDK?

leon_laikan
Participant
0 Kudos

Hi, everybody

Please see the attached picture which explains what I want to achieve.

Any help will be much appreciated.

Thanks

Leon Lai

Accepted Solutions (1)

Accepted Solutions (1)

former_member390407
Contributor

Hi Leon,

You can use FatherCard and FatherType properties to manipulate the consolidation partner.

Below is an example of how to update them:

// Get the company by SSO
Company diComp = app.SboApplication.Company.GetDICompany();
BusinessPartners bp = diComp.GetBusinessObject(BoObjectTypes.oBusinessPartners); // Get the metadata object
try
{
	if (!bp.GetByKey(cardCode)) // Get your BP whom we need to set the parent to
	{
		throw new Exception($"Can't get BP by CardCode {cardCode}");
	}
	bp.FatherCard = parentCardCode; // Set new consolidation partner
	bp.FatherType = BoFatherCardTypes.cPayments_sum; // Set type Payment/Delivery
	int res = bp.Update(); // Try to update
	if (res != 0)
	{
		throw new Exception($"Can't update BP: {diComp.GetLastErrorDescription()}");
	}
}
finally
{
	// Don't forget to release your DI API metadata objects to prevent memory leak
	Marshal.ReleaseComObject(bp);
}

leon_laikan
Participant
0 Kudos

Hi, Sergei

Thanks a lot for your reply.

I have not yet tested your suggestion (I have not yet started working on my project), but it appears to be correct.

It will be an essential part of the project I am working on. Your help is much appreciated.

Best Regards,

Leon Lai

Answers (0)