cancel
Showing results for 
Search instead for 
Did you mean: 

Update User Defined Fields in ITM1

Former Member
0 Kudos

I don't see how to update the UDF I added to the ITM1 table. I added two Fields: "U_I001" and "U_I002"

I have an Items object to update ITM1/Price which works perfectly,

I can't acces my UDF from that table, which object am I supposed to use?

here is my code:

oItems = (SAPbobsCOM.Items)B1Connections.diCompany.GetBusinessObject(BoObjectTypes.oItems);
				
oItems.GetByKey("A001");
oItems.PriceList.SetCurrentLine(0);	

//This line works ok				
oItems.PriceList.Price = 'MyUpdatedPrice;

//These lines don't seem to refer to the right fields
oItems.PriceList.UserFields.Fields.Item("U_I001").Value = 'MyNEwValue1;
oItems.PriceList.UserFields.Fields.Item("U_I002").Value = 'MyNewValue2;
oItems.Update();

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Emmanuel,

How did you add UDF to the ITM1 table? If you add UDFs to the price list object it is added to the OPLN table and not the ITM1 table. Add the following error checking to your code to find out what error you receive:

If oItems.Update <> 0 Then
    oApplication.MessageBox(oCompany.GetLastErrorDescription)
End If

Hope it helps,

Adele

Answers (4)

Answers (4)

Former Member
0 Kudos

Yes but the thing is I am not trying to write in that field at all.

I am trying to write in my user defined field and I get this error as if I was trying to write to the 'Overwritten' field.

thanks,

Emmanuel

Former Member
0 Kudos

Yes I am doing it already.

The price is well updated according to the PriceList line I set, but the UDF aren't.

I added an enumerator on these userfields with:


IEnumerator FieldsEnum = oItems.PriceList.UserFields.Fields.GetEnumerator();
string sFields = "";
while (FieldsEnum.MoveNext())
{
  SAPbobsCOM.Field oField = (SAPbobsCOM.Field)FieldsEnum.Current;
  sFields += oField.Name + ", ";
}
B1Connections.theAppl.MessageBox(sFields,0,"","","");

and here is what is displayed in the message box?!:

<i>IsCommited, OnHand, SellItem, VATLiable, VatGourpSa, CstGrpCode, ItmsGrpCode,</i>

Former Member
0 Kudos

<i>On update I get the following error:

'1' is not a valid value for field 'overwritten'. The valid values are 'Y'-'Yes', 'N'-'No'</i>

If you look in the SDK it will tell you that it use tYes and tNo instead of 1,0 or Y,N or Yes, No... Would recommend trying it using tYes and tNo.. That might fix it...

Former Member
0 Kudos

Yes nothing in the SBO GUI refers to this table. I also noticed it as a tried to remove the field to re-create them...

But when I look at the database structure with SQL Server entreprise manager, I can see that the fields have been created properly in ITM1 Table...

thank you for helping me

Emmanuel

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Emmanuel,

I have tried to reproduce your problem and I have noticed strange things.

If I try to see the values for

oItem.PriceList.Count

and

oItem.PriceList.UserFields.Fields.Count

the values are correct.

But when I try to see for example the name of my first user field inside PriceList by doing

oItem.PriceList.UserFields.Fields.Item(0).Name

I obtain a value that does not correspond with the user field name I just added (in the DB it is correct)

I recomend you to open a CSN message for it and ask why does it happen.

I also don't know why inside B1 application we have no possibility to add a user field to the PriceList inside the Items. Maybe you can ask for it at the same time to support.

Please let us know what do they answer you.

Regards

Trinidad.

Former Member
0 Kudos

My Fields are created at my addon startup:

Columns = new B1DbColumnEBS[] {
    new B1DbColumnEBS("ITM1", "I001", "Description1", BoFieldTypes.db_Float, BoFldSubTypes.st_Rate, 9, new B1WizardBase.B1DbValidValue[0], "1",""),
    new B1DbColumnEBS("ITM1", "I002", "Description2", BoFieldTypes.db_Float, BoFldSubTypes.st_Price, 9, new B1WizardBase.B1DbValidValue[0], "0","")};

On update I get the following error:

'1' is not a valid value for field 'overwritten'. The valid values are 'Y'-'Yes', 'N'-'No'

This error makes me think I am not targeting the right fields...

Am I using the right object to access these fields (oItems.PriceList)?

Rgds,

Emmanuel

Former Member
0 Kudos

Hi Emmanuel,

Are the fields created in the table? Is it actually inside ITM1? If you look at the SBO GUI there is no place where you can add UDFs to ITM1, only to OPLN. Make sure that the fields are actually created.

Hope it helps,

Adele