cancel
Showing results for 
Search instead for 
Did you mean: 

UDF in SPP1

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

former_member201110
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Thanks guys,

Owen - How can I add UDFs via the DI interface?

in the help file, looking at the UserFileds in the SpeciaPricesDataArea, there's no add() method.

Former Member
0 Kudos

Avi,

If u want to add User field mean then u go to

Tools -> User-Defined Fields -> Manage User Fields ->

there if u want to add for purchase mean Marketing there if u want to add in header part then u choose Title and add else u want to add field in matrix u choose Row and add the field.

If it helps give me reward points,

Thanx,

Regards,

Anitha

former_member201110
Active Contributor
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos

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.