Hello All,
We have to generate
mirror page for each broadLog records.
Had tried generating mirror page in JS using GetMirrorURL.
nms.delivery.GetMirrorURL(deliveryId,broadlogId)
We are able to print mirror page for all broadLog records for email channel, but there is a catch in it.
By copying the mirror page URL generated by GetMirrorURL function, mirror page is rendering fine for the deliveries where mirror page is configured in Email delivery.
But it throws error for URLs generated by GetMirrorURL function for deliveries where mirror page URL haven't configured.
So is there any other way to generate mirror page for all broadLog records in a workflow?
Like, replicating https://<instance_url>/nl/jsp/m.jsp?c=<%=escapeUrl(cryptString(message.deliveryPartId.toString(16)+'...>
(Had referred this community question, but unable to generate the correct mirror page URL)
Workflow used:
Query on broadLogRcp as targeting dimension,
JS
var data = xtk.queryDef.create(
<queryDef schema="temp:query" operation="select" >
<select>
<node expr= "@id" /> //broadLogId
<node expr= "@deliveryId" />
<node expr= "@deliveryPartId" /> //tried fetching deliveryPartId from [delivery/mirrorPageInfo/@id] in query
</select>
</queryDef>
)
var output = data.ExecuteQuery();
for each (var file in output.query)
{
instance.vars.deliveryId = file.@delId.toString(16);
instance.vars.broadlogId = file.@id.toString(16);
instance.vars.partId = file.@deliveryPartId.toString(16);
vars.url = "https://xxxxxxxxxxxx.campaign.adobe.com/nl/jsp/m.jsp?c="+ escapeUrl(cryptString(???????????));
//tried passing multiple probability variable in cryptstring, but has not worked for us,(message.deliveryPartId.toString(16)+'|'+message.id.toString(16)))
logInfo("Mirror Page URL1: " + vars.url);
}
Views
Replies
Total Likes
Hi @SD_11,
Well I am not sure why that is happening, but I can suggest one quick thing that you can do. In the delivery properties, go to the validity tab, then under "mirror page management" select the mode as "Force the generation of the mirror page". Let me know if that helps.
Regards,
Ishan
Thanks for your response. Yes this works for new deliveries. But is there any way to fetch mirror page for all existing deliveries which have been already sent, irrespective of mirror page configured in Delivery.
Views
Replies
Total Likes
Hi @SD_11 ,
If the GetMirrorURL function is not generating the mirror page URL for all deliveries, you can try using the delivery ID and delivery part ID to construct the mirror page URL manually.
You can use the following URL format to construct the mirror page URL:
Replace <instance_url> with your Adobe Campaign instance URL, deliveryPartId with the delivery part ID, and deliveryId with the delivery ID.
In your workflow JS code, you can construct the mirror page URL like this:
vars.url = https://<instance_url>/nl/jsp/m.jsp?c= + escapeUrl(cryptString(file.@deliveryPartId.toString(16) + '|' + file.@deliveryId.toString(16)));
This should generate a mirror page URL for all broadLog records, even for deliveries where the mirror page URL is not configured.
Views
Replies
Total Likes
Hi @akshaaga ,
Yes We had tried the same.
Created 2 deliveries, one with mirror page configured and one with no mirror page. After sending delivery, had Queried my email id using JS to fetch those 2 records using queryDef. But by using the syntax provided, Mirror page URL generated in JS is not working even for the delivery where mirror page is configured in email body.
Kindly check what to add in deliveryPartId expr, and help us with the script.
var data = xtk.queryDef.create(
<queryDef schema="nms:broadLogRcp" operation="select" >
<select>
<node expr= "@id" />
<node expr= "@address" />
<node expr= "[delivery/@id]" alias="@deliveryId" />
<node expr= "??????" alias="@deliveryPartId" /> //Please provide expr for deliveryPartId, We had tried few, but it doesn't worked.
</select>
<where>
<condition expr="@address = 'myEmail@test.com'"/>
</where>
</queryDef>
)
var output = data.ExecuteQuery();
for each (var file in output.broadLogRcp)
{
vars.url = "https://<hardcoded_our_instance_url>/nl/jsp/m.jsp?c="+ escapeUrl(cryptString(file.@deliveryPartId.toString(16) + '|' + file.@deliveryId.toString(16)));
logInfo("Mirror Page URL : " + vars.url);
}
Many thanks in advance!
Views
Replies
Total Likes
Hi @SD_11 ,
To retrieve the delivery part ID of the mirror page for a broadLogRcp record, you can use the following expression in your select statement:
<node expr="[@id = currentInstance/@deliveryRcpId]/mirrorPageRcpId" alias="@deliveryPartId" />
This expression uses the currentInstance function to retrieve the ID of the deliveryRcp linked to the current broadLogRcp record, and then selects the mirrorPageRcpId of that deliveryRcp. This assumes that the mirror page was configured at the delivery level, rather than at the broadLog level.
Here is the modified script:
var data = xtk.queryDef.create(
<queryDef schema="nms:broadLogRcp" operation="select">
<select>
<node expr="@id" />
<node expr="@address" />
<node expr="[delivery/@id]" alias="@deliveryId" />
<node expr="[@id = currentInstance/@deliveryRcpId]/mirrorPageRcpId" alias="@deliveryPartId" />
</select>
<where>
<condition expr="@address = 'myEmail@test.com'" />
</where>
</queryDef>
);
var output = data.ExecuteQuery();
for each (var file in output.broadLogRcp) {
vars.url = https://<hardcoded_our_instance_url>/nl/jsp/m.jsp?c= + escapeUrl(cryptString(file.@deliveryPartId.toString(16) + '|' + file.@deliveryId.toString(16)));
logInfo("Mirror Page URL: " + vars.url);
}
Make sure to replace <hardcoded_our_instance_url> with the URL of your Adobe Campaign instance. Also, note that the currentInstance function is only available in the context of an event, so you will need to run this code as part of an event.
Views
Replies
Total Likes
Thanks for Your response Akshaaga.
I am trying to generate Mirror page URL in JS activity in a Workflow.
Attribute 'id = currentInstance' unknown (see definition of schema 'Delivery logs (Recipients) (nms:broadLogRcp)').
XTK-170036 Unable to parse expression '[@id = currentInstance/@deliveryRcpId]/mirrorPageRcpId'.
So How can I achieve it by running as part of an event?
Or any solution by, Instead of queryDef on broadLogRcp table in JS, by using Query activity on targeting dimension as broadLogRcp and giving condition @address equals to myEmail@test.com.
And next to query, using a JS, queryDef on temp:query?
Views
Replies
Total Likes
Hi @SD_11 ,
The error message indicates that the [@id = currentInstance/@deliveryRcpId]/mirrorPageRcpId expression is not correctly parsing the attribute currentInstance.
When running the script as part of an event, the currentInstance attribute may not be available. Instead, you can pass the deliveryRcpId as a parameter to the event, and retrieve it in the JS activity using vars.deliveryRcpId.
You can try using the following code that uses a query activity to retrieve the broadLogRcp records based on the email address, and then generates the mirror page URL for each record:
// Query activity on targeting dimension as broadLogRcp with condition @address equals to myEmail@test.com
for each (var rcp in ctx.broadLogRcp) {
var deliveryId = rcp.delivery.@id.toString(16);
var deliveryPartId = xtk.session.getResource(rcp.delivery.part.resource.@href).id.toString(16);
var mirrorPageRcpId = rcp.mirrorPageRcpId.toString(16);
var mirrorPageUrl = "https://<instance_url>/nl/jsp/m.jsp?c=" + escapeUrl(cryptString(deliveryPartId + '|' + deliveryId + '|' + mirrorPageRcpId));
logInfo("Mirror Page URL for broadLogRcp " + rcp.@id + ": " + mirrorPageUrl);
}
In this example, rcp is the current broadLogRcp record, and ctx is the context object that provides access to the input data.
The deliveryId and deliveryPartId are retrieved from the rcp.delivery object, and the mirrorPageRcpId is retrieved directly from the rcp object. The mirror page URL is generated using these values, as in the previous example.
Views
Replies
Total Likes
Thanks for your patience and clear explanation!
Workflow:
Query: (internal name: query)
Javascript: Copy pasted the same in JS
Error received, JST-310000 Error while compiling script 'WKF2807/js242' line 2: ctx is not defined.
Tried using queryDef on temp:query, and used same script in for loop. And still facing the error.
Views
Replies
Total Likes
Hi @SD_11 ,
The error "ctx is not defined" is because the variable ctx is not declared or defined in your JavaScript code.
ctx is a built-in object in Adobe Campaign Classic that provides access to various properties and methods related to the context of the script execution.
To resolve this error, you should declare the ctx object at the beginning of your script.
You can do something like below (you can modify the script to include the ctx object):
// Declare the ctx object at the beginning of the script
var ctx = xtk.workflowExecutionContext.currentActivityInstance.context;
// Use the ctx object to get the queryDef from the previous Query activity
var queryDef = ctx.getOptionValue("queryDef");
// Create a new queryDef based on the previous queryDef
var newQueryDef = xtk.queryDef.create(queryDef.serialize());
// Add the mirrorPageRcpId node to the select statement
newQueryDef.select.add(
xtk.queryDef.createNode(
"mirrorPageRcpId",
"[@id = currentInstance/@deliveryRcpId]/mirrorPageRcpId"
)
);
// Execute the new queryDef and loop through the results
var result = newQueryDef.ExecuteQuery();
for each (var row in result) {
var mirrorPageRcpId = row.mirrorPageRcpId;
var deliveryId = row.deliveryId;
// Construct the mirror page URL
var url = "https://<your-instance>/nl/jsp/m.jsp?c=" +
escapeUrl(cryptString(mirrorPageRcpId.toString(16) + '|' + deliveryId.toString(16)));
logInfo("Mirror Page URL : " + url);
}
Make sure to replace <your-instance> with your Adobe Campaign Classic instance URL.
The JavaScript activity (with the modified script) should be connected to the Query activity that queries the broadLogRcp table with the condition @address = myEmail@test.com.
Views
Replies
Total Likes
Thank you again for your reply. Created a query on broadLogRcp as targeting dimension and filtered on address. No additional data added.
In JavaScript, I've copy pasted the script provided by you, and edited on only by replacing instance URL.
Error Log received: XFR-180000 The file '/usr/local/neolane/nl6/datakit/xtk/eng/schema/workflowExecutionContext.xml' does not exist on the server. Unable to load the document of identifier 'xtk:workflowExecutionContext' and type 'xtk:schema'.
Views
Replies
Total Likes
Hi @SD_11,
This error message indicates that Adobe Campaign could not locate a specific schema file on the server. This could be caused by various issues, such as a missing or corrupted file or a configuration error.
This error could be caused by a few things, such as a missing file or a permissions issue.
A few reasons-
A. Check that the file workflowExecutionContext.xml is in the correct directory on the Adobe Campaign server. If it is missing, try to replace it with a backup copy.
B. Make sure that the directory containing the schema file is included in the CLASSPATH environment variable on the server.
C. Try restarting the Adobe Campaign server to see if the issue is resolved.
It looks like there is an issue with the server, and it's unable to load the document 'workflowExecutionContext.xml' for some reason.
One thing you could try is to restart the server to see if that resolves the issue.
If the problem persists, you may need to contact implementation team to help with the custom JS.
In the meantime, you can try running the JavaScript code in a different environment or testing it in a sandbox account to see if it works there.
Hi Akshaaga, Thanks for your help.
I had tried running the script in different instances. But had received the same error "Unable to load the document of identifier 'xtk:workflowExecutionContext'".
And we are Hosted system. So we don't have access to server to check the file in the mentioned directory or to restart it.
So as of now, we are trying to fetch mirror page URL in any other way.
Views
Replies
Total Likes
Hi @SD_11 ,
It's possible that the script was executed outside of the context of a workflow or other context where the xtk:workflowExecutionContext is available.
One way to check whether the xtk:workflowExecutionContext is available is to add a try-catch block around the part of the script causing the error.
Hi @SD_11,
Were you able to resolve this query with the help of the given solutions or on your own? Do let us know.
Thanks!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies