Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL (Archived)

Where is the code?

Posted on by 40

Hi,

While I have a fair amount of experience in software development, this is my first foray into SL customizations, and I am a bit stumped.
I'm trying to modify the behavior of an "Invoice Comments" button in Timecard Entry (TMTCE00**). 
Normally, when this button is clicked, it launches the Notes application (PANOT00**). I need to inhibit the execution of PANOT00 based on code I write in button_click event. 
However, where is the code that actually runs PANOT00?  How can I inhibit this? Where is the setting in SL that binds this button to run PANOT00?
Thanks for helping this newbie.
Marc
** I'm not sure if this application is standard to SL or is itself a customization. 

*This post is locked for comments

  • MarcKriez Profile Picture
    MarcKriez 40 on at
    Re: Where is the code?

    After a bit of investigation using the techniques you described, I ended up adding a button specifically for  Friday which does as you suggested (focus, call original box).

    The original button still launches Mon - Thu and still fails if used on a Friday AM or PM box....Clicking on the new Friday button *always* sets focus to the hidden Friday box and only launches Friday's notes.

    Not the best, but it's a workable solution that allows the users to get at the notes as I investigate further and expand my understanding....

    Thanks for your help, Barry!

  • MarcKriez Profile Picture
    MarcKriez 40 on at
    Re: Where is the code?

    Barry,

    Wow, thanks for the very informative post!  Now that I have a clearer understanding of how this works, I'll give you the specifics of what my assigned task is:

    In the Timecard entry screen, there are controls (InGrid = true as well) for Monday thru Thursday. There is an existing customization that split Friday into 2 fields for AM and PM. I'm guessing that the "real" Friday control is being hidden using a technique similar to what you described. (EDIT: there is in fact, a hidden Friday field)

    Now, ordinarily, clicking on any control Mon - Thu, then clicking on "Invoice Comments" button works just fine.  

    However, clicking on either of the new Friday boxes--AM or PM--then clicking on "Invoice Comments" button throws up an error saying the selected control does not contain day information. I would surmise that since these 2 buttons are hiding the real Friday textbox and these 2 boxes fail the criteria, this is why the "Invoice Comments" button is failing.

    I was hoping to write code to (in pseudocode)

     1) Check if selected control is the new AM or PM textbox then call PANOT00

           I couldn't even find a call to check for Focused control...(HasFocus? IsFocused?)

     2) Otherwise, use OOB/default processing to determine if PANOT00 should be called

    But if the OOB behavior is doing the check for the hidden Friday box and immediately going to the Error MsgBox and disallowing running of PANOT00, I'm not sure how to "hijack" this.  In my mind, a replacement button, can be coded with my "new" criteria, but if I called the existing button, it would still throw the error...

    Hopefully, there is something else that can be done...and hopefully, I explained the situation clearly...

    Specs: SL 7.0 FP1 - Advanced, v7.03.21203.02 (7.0.0.0) running on Server 2003 R2

    Thanks!

    Marc

  • Barry Flynn Profile Picture
    Barry Flynn 3,090 on at
    Re: Where is the code?

    Marc

    The screen that you are customizing is a compiled .exe.

    Customization Manager does not show you the source code of that screen, or allow you to modify it.

    It does, however, allow you to write VBA code in the various Events.

    In some cases the customization event will run before the host screen's event.

    In other cases the customization event will run after the host screen's event.

    In some Events (usually with a parameter called retval) your code can abandon that event.

    For example in the Update control's OnUpdate event, which runs when the user clicks on SAVE, your code can cause the Save operation to be aborted and abandoned.

    For a button, about all you have is the Click event, and, to my knowledge, there is no ability to "abandon the click".

    However there is a workaround, which doesn't always work :)

    Change a couple of properties on the button.

    Set TabStop to false.

    set Left to, say, -1000.

    That effectively makes the button totally inaccesable to the user.

    Now use the Insert Wizard to add your own button to "replace it".

    Now when the user clicks "the button", it will be "your button", not the "real one".

    If your code determines that you don't want to call PANOT00, then simply exit, and it won't get called.

    If you decide that calling it is OK, then you must programmatically click the "real button".

    And it is this bit that may not work.

    Or if it works now, it may cease working in a future version.

    Here's a couple of ways of possibly pushing a button.

    If neither works, post the SL Version that you are using, and I might be able to do a little experimenting.

                   Call ApplSetFocus("TheButtonsName")

                   Call SendKeys(" ",true)

    or

                   sivmyapp.controls("TheButtonsName").value = true

    Hope that helps a bit.

    Barry

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans