Difference between revisions of "OnError workflow for QAS"
Nguyenduyan (talk | contribs) |
Nguyenduyan (talk | contribs) (→Setup) (Tag: visualeditor-switched) |
||
Line 28: | Line 28: | ||
*OpenForTest = 4 | *OpenForTest = 4 | ||
+ | |||
+ | Note: | ||
The current context is set to the failed qas | The current context is set to the failed qas | ||
Line 33: | Line 35: | ||
Can get the browser info from getServerVariable | Can get the browser info from getServerVariable | ||
== Setup == | == Setup == | ||
+ | Define onError handler on Resource template type Questionnaire | ||
+ | |||
+ | [[File:OnError3.png]] | ||
+ | |||
+ | == Example == | ||
+ | <span style="color:#DF8621">Example script on workflow:</span> | ||
+ | <source lang="javascript"> | ||
+ | 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); | ||
+ | </source> | ||
+ | |||
+ | <span style="color:#DF8621">And here info can get when a QAS error::</span> | ||
+ | [[File:OnError1.png]] |
Revision as of 06:27, 22 May 2018
OnError workflow for QAS
If a qas has an error and a 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
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);