Set Property for new Item by Code
Sebastian Schweer
Hallo,i try to create an item by Code, which is no problem as long as i don't try to set a Propety.
If i try to set a Propety i got the following error:
"Property, indexer, or event 'Properties' is not supported by the language; try directly calling accessor methods 'SAPbobsCOM.IItems.get_Properties(int)' or 'SAPbobsCOM.IItems.set_Properrties(int, SAPbobsCOM.BoYesNoEnum)'(CS 1545)"
My code looks like this:
SAPbobsCOM.Items oItem = (SAPbobsCOM.Items) SwissAddonFramework.B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
oItem.ItemCode = "123456";
oItem.Properties(1) = SAPbobsCOM.BoYesNoEnum.tYES;
Can anybody help me and told me, how i can set a property by C# Code?
Best regards,
Sebastian
Bastian Hofmeister
Hi,You have to use the set_properties-Method like it is explained in the message.
Don't forget to Update!
try
{
SAPbobsCOM.Items oItem = (SAPbobsCOM.Items)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
oItem.GetByKey("10000");
oItem.set_Properties(1, SAPbobsCOM.BoYesNoEnum.tYES);
oItem.Update();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
HTH
Basti
Sebastian Schweer
Hallo Basti,thank you for your response.
The "Set_Properties" Methode dosen't show up in my IntelliSense Options and my API, so i don't find it. But it works. Thanks :)
Best Regards,
Sebastian
0
Please sign in to leave a comment.
Comments
0 comments