Using Hidden fields to detect which System Action triggered a Table Level Script.

2 minute read time.

A customer needs to know what particular System Action was used to trigger a Table Level Script.

The big problem facing us in this scenario is that the Values() collection usually used in server side scripts to obtain variables passed in from the browser can read any form data but it can not read information within the QueryString.

I have discussed a 'cheat' in a previous article how the Session ID and any other contextual variables can be obtained within a Table Level Script. See the article 'How can I get the SID in Serverside scripting?'

But we can't use that method to obtain the 'Act' code.

We must rely on the fact that the only information that we can know within the Table Level script is whatever is passed from the HTML form.

Here we will face another problem; The Values() collection will only read the fields that are defined in the 'block' associated with the record. The Values() collection will not read the additional hidden fields that are added by the dll - these are the ones that are not defined in Meta data but are added to allow the dll to control the interface and process flow of the application.

So we can't use Values() we have to use FormValues(). FormValues() allows us to read any data passed in from the form.

In many screens there are three hidden fields called _actionid, _HIDDEN_BEENTHERE and NextAction. It may be possible to use these to see what action code was used.

Note: The action code may not exactly correspond to what you are expecting. Action codes are 'cheats' and are not regarded as part of the published APIs. The use of Action Codes is not officially supported.

Note: The fields may not be present in all circumstances especially the _actionid. _actionid is usually added into the screen when a 'new' entity action is called from a new button on a list but it may not get added when called from the new button in the main menu.

Example Table Level Script

The code below can be used to test the availability of _actionid and _HIDDEN_BEENTHERE within the system screens you are monitoring.

function InsertRecord()
{
// Handle insert record actions here
Valid = false;
ErrorStr = 'InsertRecord: _actionid= ' +FormValues('_actionid') + ' _HIDDEN_BEENTHERE ='+FormValues('_HIDDEN_BEENTHERE')+ ' NextAction ='+FormValues('NextAction');
}

function PostInsertRecord()
{
// Handle post insert record actions here
Valid = false;
ErrorStr = 'InsertRecord: _actionid= ' +FormValues('_actionid') + ' _HIDDEN_BEENTHERE ='+FormValues('_HIDDEN_BEENTHERE')+ ' NextAction ='+FormValues('NextAction');
}

function UpdateRecord()
{
// Handle update record actions here
Valid = false;
ErrorStr = 'InsertRecord: _actionid= ' +FormValues('_actionid') + ' _HIDDEN_BEENTHERE ='+FormValues('_HIDDEN_BEENTHERE')+ ' NextAction ='+FormValues('NextAction');
}

function DeleteRecord()
{
// Handle delete record actions here
}