Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Calling custom method from form datasource in a form control event handler

Posted on by 2,650
Hi All,
 
I have read this post https://community.dynamics.com/forums/thread/details/?threadid=391a4b99-f612-41eb-bef6-3f7dc26df454 cover to cover and I will explain my scenario - hopefully someone can assist.
 
I have written an extension to the TsTimesheetEntry form.
 
The extension is a simple check box added to the form that when turned on, the modified event handler method attempts to call a custom data method which has been added as an extension on the TsTimesheetTable form datasource.
 
The idea is that if the form control is marked to true, this custom method on the form data source should be called to alter the query on the form and refresh.
 
The issue I am having is similar to others in this blog but no matter which combination of the solutions I try, when I attempt to call the custom data method from the form data source in my form control event handler the system complains that the method cannot be found:  

Error executing code: FormDataSource object does not have method 'delegateQuery'.
 
But the custom method delegateQuery has been added via a form extension CoC method 
 
[ExtensionOf(formDataSourceStr(TsTimesheetEntry, TSTimesheetTable))]
 
public void delegateQuery(NoYes _applyFilter)
{              
      // query logic changed
}
 
My question is - how can I successfully call this custom data method from another custom form control event handler method.
 
Thanks in advance
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    Calling custom method from form datasource in a form control event handler
    Hi Kauto,
     
    As moderator, I corrected the link in your question. It had some invalid characters at the end of the URL. Please share the coding you applied, so we might be able to understand what you did so far and we can see how to help you.
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,347 Super User 2024 Season 2 on at
    Calling custom method from form datasource in a form control event handler
    Hi Kauto,
     
    The link you provided is not working. Also can you please show us your code in the event handler to be able to help.
     
    But in general, if you are facing an issue when calling the coc method in the modified event handler, then why not put the modification logic using coc instead of event handlers? You still can use extensions.
     
    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans