Dynamic CTX payload | Community
Skip to main content
vraghav
Employee
Dec 27, 2016 1:34 AM UTC
Solved

Dynamic CTX payload

My question is related to Message Center. Is it possible to substitute a ctx node value into another node at the time when our event call is being bound to the delivery template?

Let's say I wish to send a SOAP event to MC using payload like the following: 

<ctx>
    <recipient> 

        <firstName>xxxxx</firstName>
        <fullName>Full Name is equal to: <%= ctx.recipient.firstName%></fullName>

    </recipient>
</ctx>

Inside the template I've used <%= rtEvent.ctx.recipient.fullName %>
When I'm trying to send the SOAP call, the output is coming as "Full Name is equal to: " and the firstName section is blank.

I'm pretty sure that my implementation is wrong and maybe it is not possible at all, but still will look forward to your inputs.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Amit_Kumar
Amit_KumarAccepted solution
Level 10
Jan 3, 2017 3:57 AM UTC

Hi Vipul,

What you doing is not possible as <%= ctx.recipient.firstName%> will not be available in xml object definition of ctx.
this is similar to asking 
var foo = {
    a: 5,
    b: 6,
    c: this.a + this.b  // Doesn't work using a reference inside the definition. this reference will be available outside this definition.
};

and moreover this is against the current XSL for this xml.

Regards,
Amit

3 replies

Level 2
Mar 3, 2021 4:48 PM UTC

Hi

 

I got it to work by doing something like this:

 

var count = 3;

 

<% for (var i = 0; i < count; i++){

 

 var name = "item" + i %>

<%= rtEvent.ctx[name] %>

 

<% } %>

 

 

<ctx>

<item1> a </item1>

<item2> a </item2>

<item3> a </item3>

</ctx>

Translate
vraghav
vraghavAuthor
Employee
Jan 3, 2017 4:05 AM UTC

Hi Amit,

Even I had this understanding but then was curious to know if someone has actually found a workaround to it.

Thanks for taking a look into it.

Regards,

Vipul

Translate
Amit_Kumar
Amit_KumarAccepted solution
Level 10
Jan 3, 2017 3:57 AM UTC

Hi Vipul,

What you doing is not possible as <%= ctx.recipient.firstName%> will not be available in xml object definition of ctx.
this is similar to asking 
var foo = {
    a: 5,
    b: 6,
    c: this.a + this.b  // Doesn't work using a reference inside the definition. this reference will be available outside this definition.
};

and moreover this is against the current XSL for this xml.

Regards,
Amit

Translate