Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Specify "Period" parameter when generating report export using xtk.report

Avatar

Level 2

Hello!

I'm automating some Message Center reports, using this as a basis:

https://experienceleague.adobe.com/docs/campaign-classic/using/automating-with-workflows/use-cases/m...

I'm specifically looking at the "Message Center Service Level" report, and I'm getting a basic PDF generated using this code:

var reportName = "messageCenterQualityOfService";
var path = "/home/customers/specsavers/incoming/Temp/mcqos.pdf";
var exportFormat = "PDF";
var _ctx = <ctx _context="global" _reportContext="messageCenterQualityOfService" />
var isAdhoc = 0;

xtk.report.export(reportName, _ctx, exportFormat, path, isAdhoc);

This generates a report based on the default parameters, "Channel", "Execution Instance" and "Period".

Can someone help me set the "_ctx" parameter so that I can generate the report for different "Periods". e.g. "1 week view" via JavaScript?

IainOllerenshaw_0-1659528951943.png

Thank you!

5 Replies

Avatar

Employee

Hello,

 

Is it possible to check the debug view to see the context elements/attributes (and so parameters/values) available?

Avatar

Level 2

Thank you, imicu.

 

I'm so sorry, how do I see the debug view of the report? It's an out-of-the-box report:

IainOllerenshaw_0-1659689284040.png

Many thanks!

Avatar

Employee

I do not have that report in my sandbox, but what you can do it to go to Explorer > Administration > Configuration > Reports

 

From here you have 2 options:

  1. Select the report, go to Properties and variable Tab and note the XPath for that variable.
  2. Select the report, go to Preview, select Global and tick 'Enable debug mode' checkbox. Play around with Period dropdown (refresh after changing the period) confirm that period tag modifies under vars. In my case (may not apply to you), it was looking like this 
<vars>
<period>7</period>
</vars>

All the variables defined in the variables tab are accesible under the ctx.vars.yourVariable

Once you identify the variable, you can use it in JS script by accessing with: 

ctx.vars.period = <VALUE>

Hope this helps.

Avatar

Level 2

This is really helpful, thank you!

 

I've debugged, and have the parameter and value that I need to run the report for a 2-week period (period=336). However, after amending my JS I still get a default report (24-hour period).

 

var reportName = "messageCenterQualityOfService";
var path = "/home/customers/specsavers/incoming/Temp/mcqos.pdf";
var exportFormat = "PDF";
var _ctx = <ctx _context="global" _reportContext="messageCenterQualityOfService" />
_ctx.vars.period = 336;
var isAdhoc = 0;

xtk.report.export(reportName, _ctx, exportFormat, path, isAdhoc);

Is this code correct?

 

Sincere thanks for your help - I'm definitely having "a moment" here!

Avatar

Employee

I believe it is suppose to be 

ctx.vars.period = 336;

without underscore.