Once you learn to play with data, you can accomplish the impossible and bring the magic out of the data.
Prajwal
This is my original quote, so I am going to tag it. 🙂
In Adobe Campaign, one of the medium through which you collect data is “Surveys“. You can mould your business strategy using this collected data.
Today’s article is going to be short and sweet. We are going to see how we can count the survey responses using JavaScript.
You will get many scenarios in which you need to know the survey response count in your workflow.
The below JavaScript will give you that count. You should use this in your workflow or report.
/*
Author: Prajwal Shetty
Version: 1.0
Date:12/04/2019
Purpose: Count survey response
*/
var responsesCountQry = xtk.queryDef.create(
<queryDef schema='temp:webApp:555666' alias='mySchema' operation="select">
<select>
<node alias="@count" expr="count([webAppLogRcp/@id])"/>
</select>
</queryDef>);
responsesCountQry = responsesCountQry.ExecuteQuery();
for each( var response in responsesCountQry.webApp_555666) {
ctx.vars.var1 = response.@count.toString();
break;
}
Here, 555666 is the primary key of the survey.
PS: This code will only work in build 8767 and above.
Hope this helps.