Sage CRM 2021: Using additional parameters passed from a tab or button in a .NET application extension.

It is possible to pass an additional parameter from a tab or a button. Please see the article "Passing an additional parameter to a .NET dll or ASP page from tab and buttons".

This article will consider two different approaches that for using the an extra parameter as a flag to process the page.

  • Using Dispatch Redirect.
  • Using an internal switch within a class definition.

Using Dispatch Redirect.

Consider this situation

The parameter ListChoice=Opportunity has been added to the URL

Which in turn produces a URL that looks like this

http://[servername]/[instancename]/eware.dll/Do?SID=137788432628359 &Act=432 &Mode=1 &CLk=T &Key0=2 &Key1=28 &Key2=30 &dotnetdll=ExamplePageSwitcher &dotnetfunc=RunSwitcher &ListChoice=Opportunity &J=Redirect &T=Person

The RunSwitcher class above invokes a Web Class 'Switcher'

The value of the parameter can be read using the Dispatch.QueryField or Dispatch.EitherField methods.

if (Dispatch.EitherField("ListChoice") == "Case")
Dispatch.Redirect(UrlDotNet(ThisDotNetDll, "RunCaseList"));

Dispatch.Redirect(UrlDotNet(ThisDotNetDll, "RunOpportunityList"));

This allows redirects the request to the new URL.

Note: It is important to understand that this is a redirection and the public URL changes accordingly.

http://[servername]/[instancename]/eware.dll/Do?SID=137788432628359 &Act=432 &Mode=1 &CLk=T &Key0=2 &Key1=28 &Key2=30 &func=baseUrl &dotnetdll=ExamplePageSwitcher &dotnetfunc=RunOpportunityList

In this instance the RunOpportunityList is defined in the AppFactory class and so may be invoked directly from a Tab or Button.

Using an internal switch within a class definition.

An alternative approach is to handle the switch within the class itself.

Here a web class has been used and the parameter accessed via the Dispatch.EitherField method is examined and used to determine what list should be created and then displayed within the page.

Note: It is important to understand that no redirection takes place and therefore the public URL would remain unchanged.

http://[servername]/[instancename]/eware.dll/Do?SID=137788432628359 &Act=432 &Mode=1 &CLk=T &Key0=2 &Key1=28 &Key2=30 &dotnetdll=ExamplePageSwitcher &dotnetfunc=RunSwitcher &ListChoice=Opportunity &J=Redirect &T=Person