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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

Custom validation on button click VBTools

(0) ShareShare
ReportReport
Posted on by 1,245

Hello Everyone.

I'm looking at injecting a custom validation code using customization manager in Automatic Invoice Creation (BI.AIC.00) screen.  I want to validate few fields on this screen when "Create Invoices" button is clicked.  To this effect, I have managed to successfully place a click event on this button.  See the code below:

 Private Sub cBegProcessing_Click()
    Dim S As String
    S = GetObjectValue("cGLSub")
    If Not ChkGLSub(S) Then
        MsgBox "GL validation fails"
        ' I want to stop further processing of this here... How?
    End If
End Sub

In my code, look at the comment "I want to stop...". Here what should I write so that this event does not move forward and go about creating invoices.

 TIA. 

Nayan

*This post is locked for comments

I have the same question (0)
  • Paul Phillips Profile Picture
    590 on at

    One quick clarification of terminology to avoid confusion - VBTools (SL SDK in v7) is used for creating new SL application screens using visual basic 6 (Solomon v6.5 and before) or VB.net (SL v7). Customization manager / VBA is used for modifying existing screens at run-time without recompiling them. VBA runs as a layer on top of an existing screen.

    I don't believe that it is possible to override the base screen's events in VBA. Even if it were, it would not be advisable because it could interfere with the standard processing logic and have bad side effects.

    In order to accomplish what you want, the typical pattern that SL customizers follow is to add a new button to the screen and set the existing cBegProcessing button's 'visible' property to false. Then make the new button have the same caption as the old, and move it to where the old one was.

    Then, you can put whatever logic you desire in the button. Once you have finshed your custom validation code, you can click the hidden original button to start processing by setting its value to true, e.g.:

    serr1 = SetObjectValue("cBegProcessing", "True")

    It is important that the button still be on the form because some other applications such as object model or application server may be launching the screen and automating it, expecting the button to be there and enabled.

    From the user's standpoint, they won't see any difference in the screen as long as you make the caption, button location, style, etc. the same for your replacement button.

    Regards,
    Paul

  • Nayan Mansinha Profile Picture
    1,245 on at

    Thanks Paul.  I did what you have mentioned but SetObjectValue on cBegProcessing is throwing System Message 9203 "The specified object is not user enterable: SetObjectValue". 

    And sorry for mixing up VBTools and Customization Manager.

    TIA

    Nayan

  • Nayan Mansinha Profile Picture
    1,245 on at

    Forgot to mention that I'm on SL 6.5. 

  • Paul Phillips Profile Picture
    590 on at

    No problem on the terminology - I just wanted to make sure that other folks who read this post don't get confused. The two are very similar and it is a common mixup.

    Instead of using SetObjectValue, this might work instead:

    sivMyApp.Controls("cBegProcessing").value = True

    sivMyApp should be a global reference to the Object Model SIVApplication object, which in this case refers to the screen itself in VBA. I don't think you will need to declare it first before using it. If memory serves sivMyApp has gone away in later versions, but for 6.5 hopefully this will work for you. I don't have a 6.5 environment handy at the moment to test.

     

    Regards,

    Paul

     

     

  • Nayan Mansinha Profile Picture
    1,245 on at

    that worked.  thanks Paul!

  • Community Member Profile Picture
    on at

    I would like to try and use SetObjectValue in VB.Net code to set value to a control as MyApp.Controls("ccustid").Value = "12321" is not setting value. The control on VB.net is showing as enabled = false. I've tried setting to true however property is not changing.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans