web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

Sales Orders Trigger

(0) ShareShare
ReportReport
Posted on by

I am trying to setup a Sales Order Trigger that will pull in a user field from the customer table when someones enters a customer id.  The same way it automatically pulls in all shipping/billing info for that customer.  Here is the VBA i have written but its not working.  Any help is appreciated as I am still learning.

inserted safmaskedtext (xloyalty) and linked to user3 of soheader

New module

Type loyalty

user3 as string * 30

End Type

Global bloyalty As loyalty

This screen code

Private Sub ccustid_1_Chk(ChkStrg As String, retval as Integer)

Dim Cur As Integer

Dim SQL as String

SQL="SELECT User5 FROM Customer WHERE Custid="&SParm(ChkStrg)

Call SqlFetch1(Cur, SQL, bloyalty, LenB(bloyalty))

Call SetObjectValue("xloyalty", bloyalty.user3)

SqlFree (Cur)

Close (Cur)

End Sub

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Ram Peru Profile Picture
    2,830 on at

    Hello Griffin,

    you have to use DispFields API function after SetObjectValue. DispFields API function is used to display the value of underlying data field(s) corresponding to the particular control(s).

    Call DispFields('Form1","xloyalty")

    This may solve your issue.

    Thanks,

    Perumalsamy R

    (Congruent info tech)

  • Community Member Profile Picture
    on at

    Thank You for the added function and an explanation of DispFields.  That makes sense but I still cannot get it to work.  

    I am not getting any errors but it is not grabbing the field from customer table.  Would I have to import the customer.dh file into the module?

  • Verified answer
    Mark E Profile Picture
    6,451 on at

    There is no ccustid_1 object in the Sales Order screen.  It does, however, have a ccustid_0 object.

    First, add the Customer.dh module to the VBA Project in the Sales Order screen

    Then, try this code...

    Private Sub ccustid_0_Chk(ChkStrg As String, retval as Integer)

    Dim SQLStr$, xCustUser5$

    SQLStr = "select* from Customer where Custid = " & SParm(ChkStrg)

    serr = SqlFetch1(c1, SQLStr, bCustomer, LenB(bCustomer))

    xCustUser5 = bCustomer.User5

    serr = SetObjectValue("xloyalty", xCustUser5)

    Call DispFields("Form1","")

    End Sub

  • Community Member Profile Picture
    on at

    Thank You so much Mark.  That worked perfectly.  I appreciate everyone's help here.  I have learned so much.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans