Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

Customization Error

(0) ShareShare
ReportReport
Posted on by

i created a new table in SL database and created the DH File so i can use it in the customization manager and it compiles and everything but when i run it i get this error , i looked it up it says i didnt import the DH file , but i actually did any help will be appreciated

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Customization Error

    Thanks Rick that actually worked

    and yes examples is the best way to learn

    thank you so much

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Customization Error

    Perhaps the best explanation is to show you some SQL statements that I used to create a custom table attached to the payroll employee screen (a sample is sometimes worth a thousand words).

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[xEmployeeExt]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

    BEGIN

    PRINT 'Dropping table: xEmployeeExt'

    DROP TABLE [dbo].[xEmployeeExt]

    END

    Go

    CREATE TABLE xEmployeeExt (

    EmpId               CHARACTER (10) NULL DEFAULT (' '),

    CellNbr             CHARACTER (20) NULL DEFAULT (' '),

    Email               CHARACTER (50) NULL DEFAULT (' '),

    EmergencyContact    CHARACTER (50) NULL DEFAULT (' '),

    ContactNbr          CHARACTER (30) NULL DEFAULT (' '),

    TerminationReason CHARACTER (50) NULL DEFAULT (' '),

    Rehire CHARACTER (30) NULL DEFAULT (' '),

    tstamp    timestamp NOT NULL

    )

    GO

    IF EXISTS (SELECT * FROM sysindexes WHERE name = 'xEmployeeExt0')

    BEGIN

    PRINT 'Dropping index: xEmployeeExt0'

    DROP INDEX xEmployeeExt.xEmployeeExt0

    END

    Go

    PRINT 'Creating index xEmployeeExt0'

    Go

    Create Index xEmployeeExt0 on xEmployeeExt

                 ([EmpID])

    Go

    PRINT 'Index: xEmployeeExt0 created successfully'

    Go

    You will see that I created an index on the xEmployeeExt table.  The 0 index must refer to a unique field or fields that uniquely identifies one record in the table.

    As for you compile error on the form_load event, without the text of the code you added, I cannot tell what is causing the error.  However, here is the code I added to the payroll employee screen for the new custom table xEmployeeExt.

    Private Sub cEmpID_Chk(ChkStrg As String, retval As Integer)

    Dim GetxEmployeeExt As Integer

    Dim SqlStr As String

      If Trim(ChkStrg) <> "" Then

           SqlStr = "SELECT * FROM xEmployeeExt WHERE EmpID = " + SParm(Trim(ChkStrg))

           GetxEmployeeExt = SqlFetch1(Csr_xEmployeeExt, SqlStr, bxEmployeeExt, LenB(bxEmployeeExt))

           If GetxEmployeeExt = NOTFOUND Then

                FoundXtra = False

                bxEmployeeExt = nxEmployeeExt

           Else

                FoundExt = True

           End If

       End If

       Call DispFields("form1", "")

    End Sub

    Private Sub Update1_OnDelete(level As Integer, retval As Integer)

       Dim Empid As String * 10

       Dim SqlStr As String

       If level = LEVEL0 Then

          Empid = GetObjectValue("cempid")

          SqlStr = "Delete from xEmployeeExt where Empid = " & SParm(Empid)

          Call TranBeg(True)

          Call sql(Csr_xEmployeeExt, SqlStr)

          Call TranEnd

          Call SqlFree(Csr_xEmployeeExt)

        End If

    End Sub

    Private Sub Update1_OnUpdate(level As Integer, insertflg As Integer, retval As Integer)

       If level = Finished Then

          Call TranBeg(True)

          If FoundExt Then 'update existing

            Call SUpdate1(Csr_xEmployeeExt, "xEmployeeExt", bxEmployeeExt, LenB(bxEmployeeExt))

          Else

            bxEmployeeExt.Empid = GetObjectValue("cEmpId")

            Call SInsert1(Csr_xEmployeeExt, "xEmployeeExt", bxEmployeeExt, LenB(bxEmployeeExt))

          End If

          Call TranEnd

       End If

    End Sub

    Private Sub Form1_Display()

    End Sub

    '$include: "xEmployeeExt.dh"

    Private Sub Form1_Load()

       Call VBA_SetAddr("bxEmployeeExt", bxEmployeeExt, nxEmployeeExt, LenB(bxEmployeeExt))

       Call SqlCursorEx(Csr_xEmployeeExt, NOLEVEL + SqlUpdate, "Csr_xEmployeeExt", "xEmployeeExt", "xEmployeeExt")

    End Sub

  • Community Member Profile Picture
    on at
    RE: Customization Error

    Hi Rick , Thank you for the reply

    when i tried calling these two functions in the Form1_Load event , i got a notification that the code has compiled unsuccessfully

    and second question is what do you mean when you say the table must have a index 0 as a unique index ??

    thanks  

  • Community Member Profile Picture
    on at
    RE: Customization Error

    AmrSaleh,

    Adding a SQL table to an existing SL screen through Customization Manager requires some code added to the Form1_Load event including a VBA_SetAddr call and a SqlCursorEx call.  Also, the table you create must have a tstamp field.  Finally, the new table must have a index 0 as a unique index.

    If you will provide the SQL statements that you used to create your table and the index and if you will provide the code you inserted in the Form1_Load event I will the happy to take a look at it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,892 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,772 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans