OnError workflow for QAS

From Catglobe Wiki
Revision as of 07:39, 19 October 2021 by Administrator (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

OnError workflow for QAS

If a qas has cgscript error or js error and onError handler is defined in the Resource template type Questionnaire, then that script is called with 8 parameters:

0: The unique id of the qas

1: The resourceid id of the questionnaire

2: the resource name of the questionniare (or empty string)

3: The label of the question it failed on (or "unknown")

4: The service action that filed

5: The stacktrace message

6: The stacktrace itself

7: The statis of the questionnaire:

  • NotSet = 0,
  • Closed = 1,
  • Paused = 2,
  • Open = 3,
  • OpenForTest = 4

Note:

The current context is set to the failed qas

Can get the browser info from getServerVariable

Setup

Define onError handler on Resource template type Questionnaire

OnError3.png

Example

Example script on workflow:

array a = Workflow_getParameters();
number RPQId = a[0];
number qnaireRId = a[1];
string qnaireName = a[2];
string questionLabel = a[3];
string serviceAction = a[4];
string stacktraceMessage = a[5];
string stacktraceItself = a[6];
number qnaireStatus = a[7];

//1: NotSet 2: Closed 3: Paused 4: OpenForTest
string qnaireStatusText;
if(qnaireStatus == 0)
	qnaireStatusText = "NotSet";
else if(qnaireStatus == 1)
	qnaireStatusText = "Closed";
else if(qnaireStatus == 2)
	qnaireStatusText = "Paused";
else if(qnaireStatus == 3)
	qnaireStatusText = "Open";
else if(qnaireStatus == 4)
	qnaireStatusText = "OpenForTest";

//get the browser info from getServerVariable
string httpReferer = getServerVariable(HTTP_REFERER);
string httpUserAgent = getServerVariable(HTTP_USER_AGENT);
string remoteAddr = getServerVariable(REMOTE_ADDR);

string content = "<p>
	RPQId: "+ RPQId +" <br />
	Qnaire RId: "+ qnaireRId +" <br />
	Qnaire Name: "+ qnaireName +"<br />
	Question Label: "+ questionLabel +"<br />
	Service Action: "+ serviceAction +"<br />
	Stacktrace Message: "+ stacktraceMessage +" <br />
	Stacktrace Itself: "+ stacktraceItself +"<br />
	Qnaire Status: "+ qnaireStatus +" "+ qnaireStatusText +"<br />
	RPQ link: "+ httpReferer +"<br />
	Browser info: "+ httpUserAgent +"<br />
	Computer's IP: "+ remoteAddr +"</p>";

// the current rpq context is set to the failed qas
sendEmail("test@maysunshine.vn", "test", "demoOnError", content);

And here info can get when a QAS error::

Cgscript error

OnError1.png

Js error (question label can be found in the stacktrace)

OnErrorJs.png