Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL (Archived)

Sales Orders Trigger

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Sales Orders Trigger

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

  • Verified answer
    Mark E Profile Picture
    Mark E 6,405 on at
    RE: Sales Orders Trigger

    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
    Community Member Microsoft Employee on at
    RE: Sales Orders Trigger

    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?

  • Suggested answer
    Ram Peru Profile Picture
    Ram Peru 2,830 on at
    RE: Sales Orders Trigger

    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)

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans