Skip to content

Implementing a new request

Magnus Gether Sørensen edited this page Feb 7, 2018 · 1 revision

"Execute for the given request has not been implemented yet"

If you received this exception, then it means you are in need of a feature that is not part of XrmMockup - yet! In order for XrmMockup to recognize the new request you have to do 2 things, create a new RequestHandler and add that handler to the list of handlers in Core.cs.

Creating a new RequestHandler

In the shared code project XrmMockupShared there is a folder called Requests. This folder contains all RequestHandlers. Create a new one by copying an existing one.

Clear the Execute method and any helper methods there might be in the RequestHandler you copied. Change the name of the class to request nameRequestHandler. Next change the name of the constructor to match the class name and change the string that is passed to the base class to be request name.

Now the RequestHandler is setup and you can implement the logic it should execute by filling out the execute method. Get inspiration of how to use the Core, XrmDb, MetadataSkeleton and Security by looking at the other RequestHandlers.

Using the RequestHandler in Core

Open Core.cs in the shared code project XrmMockupShared. Find the definition of the function GetRequestHandlers and add your new RequestHandler to the list - copy the way the other RequestHandlers are added. If your RequestHandler should only be added in specific versions, then wrap it in compiler arguments like this

#if !(XRM_MOCKUP_2011 || XRM_MOCKUP_2013)
    new CalculateRollupFieldRequestHandler(this, db, metadata, security),
#endif

Ensuring it works and making it public

To make sure you did everything correctly you should create a series of tests that ensures your logic is correct. Once all your tests work you make a pull request, which we will review. Thanks for being awesome and helping maintain XrmMockup!

Clone this wiki locally