Custom Variables in Report

Problem:
Hi,
is there a way to get javascript variables or one of the new “User Variables” in my report to JSON file ?
The problem is I need a custom ID-String in every Report which is generating in the presentation but I can’t get this string to submit…

ActivePresenter Version: 7

OS: Win7x64

Notes:

Hi,

You can add following code into the On Load event of the first slide:

if (!prez.initReport) {
    prez.initReport = true;
    var fOldReport = prez.formatReportData;
    prez.formatReportData = function(data, format) {
        var result = fOldReport.call(this, data, format);
        var isObject = typeof result == 'object';
        if (!isObject) {
            try {
                var json = JSON.parse(result);
                result = json;
            } catch (ex) {
                alert('The report is not a valid JSON');
                return result;
            }
        }
        result['customId'] = prez.variable('variable_name'); //Replace this line
        return isObject ? result : JSON.stringify(result);
    }    
} 

Regards,

Wow, thank you - this works like a charm for AP7.
Do you see a way to adapt this for my “old” presentations, written in AP6 without the need to export every single project file trough AP7? I saw the onload event is fired in the rlprez.js - but there was no such a file in AP6 exports so I cant just paste it in.

Unfortunately, the JavaScript API of version 6 is very limited, so you can not do this without converting to version-7 projects.