Changing Context when jumping between pages using the COM ASP API

1 minute read time.
 I have created a very simple page that contains a couple of buttons. The starting page is an ASP page in the context of the Opportunity. These buttons will allow me to jump to different places in the application. The first "company" button jump is built using

var strCompanyButton = CRM.Button("Company","findcompany.gif", CRM.Url(200));
myBlock.AddButton(strCompanyButton);

The button when pressed will call the internal CRM action 200. This is the companysummary action and it will automatically change contexts and ensure that the correct information is displayed in the top content area.

If I wanted to call an ASP page I can do this from a button using

var strCustomButton = CRM.Button("CustomJump","myimage.gif", CRM.Url("custompage.asp"));
myBlock.AddButton(strCustomButton);

But this assumes the jump is taking place within the same context. The topcontent detailing the opportunity would not change and, unless I explicitly called the correct tab group in the destination page, the opportunity tabgroup would still be used.

This is because context is determined by the name/value pairs in the querystring that is passed to the eWare.dll. The CRM.URL() method when used on an ASP page builds the URL needed to maintain session but keeps the current context.
Below is the result of my custom Person jump and we can see here the topcontent and menus are all correct and even the "Testjump" tab has been correctly highlighted.


I made sure that this was the case by controlling the context myself.

The code behind the button looks like:

var strSID = new String(Request.QueryString("SID"));
var intDominateKey = 2; //person is the new target context
var intKey1 = 28; //unique id of target company
var intKey2 = 30; //unique id of target person
var strFileName = "testjump.asp"; //target file
var strTabName = "Person"; //tabgroup name to be used.
var strTarget = "http://localhost/CRMdemo/CustomPages/testjump.asp?SID="+strSID+" &Key0="+intDominateKey+" &Key1="+intKey1+" &Key2="+intKey2+" &J="+strFileName+" &T="+strTabName;

var strPersonButton = CRM.Button("Person","findperson.gif",strTarget);
myBlock.AddButton(strPersonButton);

I hardcoded some of the values above. In the real world the values would be derived from the existing context. Hopefully the comments make it clear what needs to be changed. The most important part is the change in the dominate key (Key0).

Other useful articles:

Key Values in URLs

Parents
  • Jeff, I've just used this on 7.3SP3 system and it works fine except....

    On one of my Company tabs I have SQL restriction: comp_type='Customer'

    When I jump to the company the correct context and tab is shown BUT I get an error:

    tabsql: Select NBQU_NBQuoteID from NBQuote WHERE NBQU_NBQuouteID = 3381 and (comp_type='Customer')

    3381 is the ID of my company. If I remove the SQL against the tab it's OK but I see a tab I shouldn't as my company is a 'Prospect'

    Any ideas?

    Thanks

    Roger

Comment
  • Jeff, I've just used this on 7.3SP3 system and it works fine except....

    On one of my Company tabs I have SQL restriction: comp_type='Customer'

    When I jump to the company the correct context and tab is shown BUT I get an error:

    tabsql: Select NBQU_NBQuoteID from NBQuote WHERE NBQU_NBQuouteID = 3381 and (comp_type='Customer')

    3381 is the ID of my company. If I remove the SQL against the tab it's OK but I see a tab I shouldn't as my company is a 'Prospect'

    Any ideas?

    Thanks

    Roger

Children
No Data