Skip to Content
author's profile photo
Former Member

UDF in SPP1

Hi,

In the DI Reference, I see that there's a UserFields property for the SpecialPricesDataArea, i.e. the SPP1 table. Yet, there's no way to add user fields to this object via the user interface.

Is it possible that I will add a "U_test" field to the SPP1 table manually, via SQL, and use it with the UserFields property?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 11, 2007 at 07:24 AM

    Hi Avi,

    There are quite a few instances where it's possible to add UDFs to a SBO table via the DI API where it's not possible via the user interface. In these cases your once choice is to add the UDF via the DI API. I don't recommend you try and add the UDF via SQL.

    Kind Regards,

    Owen

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Avi,

      The UserFieldsMD object in the DI API is used to add UDFs to tables. Here's an example from the SDK Help Center:

      Private Sub AddUserField()
      
      '//****************************************************************************
      '// The UserFieldsMD represents a meta-data object that allows you
      '// to addremove fields from tables or change the fields' characteristics
      '//****************************************************************************
      
          Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
      
      '//****************************************************************************
      '// In any meta-data operation there should be no other object "alive"
      '// but the meta-data object, otherwise the operation will fail.
      '// This restriction is intended to prevent a collisions.
      '//****************************************************************************
      
          '// The meta-data object needs to be initialized with a
          '// regular UserFields object
          Set oUserFieldsMD = oCompany.GetBusinessObject(oUserFields)
      
          '//**************************************************
          '// When adding user tables or fields to the SAP Business One database
          '// use a prefix identifying your partner name space
          '// this will prevent collisions between the various partners add-ons
          '//
          '// SAP's name space prefix is "BE_"
          '//**************************************************
      
          '// Set the Fields' mandatory properties
      
          oUserFieldsMD.TableName = "OCRD" '// BP table
          oUserFieldsMD.Name = "BE_UserField1"
          oUserFieldsMD.Description = "A user field"
          oUserFieldsMD.Type = db_Alpha '// am alphanumeric type
          oUserFieldsMD.EditSize = 20
      
          '// Add the field to the table
          oUserFieldsMD.Add
      
      End Sub

      One thing to be particularly aware of is that you can have only one instance of this object alive at any time. Therefore, it is a good idea to use the following code (after the Add method has been called) to 'kill' your current UDF object before attempting to add a new one:

      System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
      oUserFieldsMD = Nothing
      GC.Collect()

      Kind Regards,

      Owen

  • author's profile photo
    Former Member
    Oct 11, 2007 at 07:24 AM

    Hi..

    I think its possible to add manually User Feilds..but it's not a right way to add manually.. if u want to try this.. then do it.. hope so it will work... For that u have add this field into Two table... otherwise data can be conflict...

    you have to set this UDF into two table 1. CUFD and 2. SPP1 .

    if u will do this by code... It will be much better.

    Add comment
    10|10000 characters needed characters exceeded