The survey calculation DatStat Object consists of many very useful methods that can be called from survey calculations.  These methods allow for more capability and flexibility within a survey calculation.  Note: The survey calculation editor does not currently color code any of the DatStat object methods.  Variable name references used in the DatStat object methods will not be updated when using the survey rename capability unlike the tags (e.g. {Value:GENDER}).

How to Use

Almost all of the DatStat object methods share the same signatures as those used by our runtime SDK.  To make a call just prefix the method or property with “DatStat.” (case sensitive).  The methods are also data-type aware so make sure to pass variables of the proper type to them (eg if the method is expecting an integer, do not pass a string to it).

Reference Guide

 

Method Name Returns Description
GetHttpFormElement(name : String) String This method retrieves the name of an Http form element.
var val = DatStat.GetHttpFormElement(‘MYHIDDEN’);
GetParameter(parameterName : String) String This method signature is equivalent to the HookContext.GetParameter() method. It retrieves a survey parameter string value.
var parameter_text = DatStat.GetParameter(‘MYPARAM’);
GetRandomizationMap(variableName : String) String This method retrieves the randomization map for a specific variable that is randomized. The value returned is a comma delimited list of ordinals (e.g. 3,1,0,2).
var order = DatStat.GetRandomizationMap(‘CUSTOMER_EVAL’);
GetResponse(variableName : String) Object This method signature is equivalent to the HookContext.GetResponse() method. This method retrieves the response code and is equivalent to using a {Value} tag.
var val = DatStat.GetResponse(‘Q55’);
GetResponseLabel(variableName : String) String This method signature is equivalent to the HookContext.GetResponseLabel() method. This method retrieves the response label.
var theResponse = DatStat.GetResponseLabel(‘Q55′);
GetUserData(dataName : String) String This method signature is equivalent to the HookContext.GetUserData() method. It will return the value for the specified piece of User Data from a participant list.
var userData= DatStat.GetUserData(‘LOCATION’);
IsOnPage(variableName : String) Boolean This method will return true if the item identified by the variableName parameter appears on the page of the set of responses that are being currently processed.
if(DatStat.IsOnPage(‘Q55′)) { // do something }
PageItemNames() String[] This method returns an array of variable names that appear on the page of the set of responses that are currently being processed.
var items : String[] = DatStat.PageItemNames();
QuotaCountGet(quotaName : String) int This method returns the current count for the specified quota.
var count = DatStat.QuotaCountGet(‘MALE’);
QuotaLimitGet(quotaName : String) int This method returns the quota limit defined for the specified quota. If the current survey session happens to be a test participant then the test data quota limit is returned.
var limit = DatStat.QuotaLimitGet(‘MALE’);
QuotaStatusGet(quotaName : String) int This method returns a ‘0’ or ‘1’ that designates the quota status for the sepecified quota. A value of ‘0’ means that the specified quota hasn’t yet met the limit. A value of ‘1’ means that the specified quota has met or exceeded the quota limit.
var status = DatStat.QuotaStatusGet(‘MALE’);
ResponseReplacement(input : String) String This method signature is equivalent to the HookContext.ResponseReplacement() method. This method replaces all tags to their proper values.
var surveyName = DatStat.ResponseReplacement(‘{SurveyName}’);
SetResponseData(variableName : String, responseValue : Object) Boolean This method signature is equivalent to the HookContext.SetResponseData() method. This method sets a specific variable to a particular value. A value of true is returned if the variable was set properly, otherwise a value of false is returned. Setting a value to ‘blank’ is equivalent to clearing the value. (i.e. DatStat.SetResponse(“Q1”,) )
DatStat.SetResponseData(‘Q1’, myvar);
SetUserData(dataName : String, dataValue : String) void This method signature is equivalent to the HookContext.SetUserData() method. This method sets a user data field to a particular string value.
if ( DatStat.GetResponse(‘GENDER’) == 1 )
DatStat.SetUserData(‘PRONOUN’, ‘his’);
else
DatStat.SetUserData(‘PRONOUN’, ‘her’);