How did I get Here?

3 minute read time.
In this post I would like to consider how you can establish whether a page has just been called via a hyperlink (from the tab) or it has been called because "Save" action button has been pressed.

Pages can be called either by direct hyperlinking to them or by clicking a "button".

An example of using the a direct hyperlink is the effect of clicking on Tab or by following a hyperlink on a listblock. For example hyperlinking to the company summary screen from the listing of opportunities.

Example of button links are the form action buttons like 'Save', 'Change' or 'Filter'. In the Interface these buttons look like they are HTML Submit or Image buttons but they are actually hyperlinks. These hyperlinks may call pseudo URL containing a JScript statement that include a"document.EntryForm.submit()" method.

We have different options open to us depending on whether the page is drivendirect from the dll (using an in built action) or if it is an ASP page.

In CRM pages that are called via a hyperlink are always called using the HTTP method 'GET' and all CRM forms are called 'EntryForm' and are submitted using the HTTP method 'POST' and by default forms will also recall their own page.

You can interrogate the Request.ServerVariables('HTTP_METHOD') in an ASP page to work out how the page was called. You can also directly use the eWare.Mode property with is unavailable within the internal API of CreateScripts, Validation Scripts etc.

You don't have access to the Request.ServerVariables collection in a system built page. So your range of actions is limited. If the system built page is an entry page like the 'Company Summary' then you will have access to the field level scripts of the blocks that make up the page, and if it is a listpage like 'opportunity list' under the Company tab group then that page hasa filter box which you can access in the Customization area of meta data.Both the custom content and the 'create script' can be used. Within the 'Create Script' we have access to the Values() collection. We can then look for the variables that are in the QueryString.

For example, if you put the following code into the comp_name field of the'company entry screen':


Valid = false;
ErrorStr = Values('Act'); 


This will show that when you enter the company summary screen from a search hyperlink or the company tab bar then Act = 200, from the recent list Act=520, if you click the change button, Act=201 and if you click the delete button Act=202.

The value of Act can then help you identify how the page was called.

Example of onCreate Rule


This rule changes the caption of a field to include the URL for a external system. The script will change the Caption only when the screen is in either View mode or Save mode and not edit mode.


if(Values("Act")==200||Values("Act")==520||Values("_actionid")==201) 
{ 
var customerref = Values('comp_customerref'); 
var customerstatusurl ="http://www.mydomain.com/bm/bm_customerstatus.cfm?customerref="+customerref;
Caption = 'Customer Ref'; 
}

Act==200 checks if on summary screen Act==520 check if come from recent list_actionid==201 Checks if returned to view from edit mode. This is a hidden form value specific to the company summary screen.

The Custom Content box on a screen can also be used. This is useful for client side script, therefore you can use any browser object for example the document.referrer property and the document.URL property.

Note: The Values() collection only returns QueryString information in an onCreate Script. This technique can not be used for TableLevel scripts or Validation scripts.