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
BedrockMission!

Learn More

View all

Sign in to view all badges

Modify Delivery content via Workflow

Avatar

Avatar
Give Back
Level 2
supratim320
Level 2

Likes

2 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 1
View profile

Avatar
Give Back
Level 2
supratim320
Level 2

Likes

2 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 1
View profile
supratim320
Level 2

31-05-2021

Hi All,

In my current project, we are using publication template and GA for analytics purpose. Previously, the business users used to put the exact url (https://www.google.com/?utm_campaign=abc...) in all the <a> tags. However, as per the new design the utm tags will be outside the delivery template and via option and js template. For this reason, we are creating a one time workflow which will read these delivery templates and will remove all the utm tags from the hyperlinks.

When I am opening the delivery xml (right click on delivery and right click to look into the xml code-behind), I am able to do it. However, I am using javascript code by loading the delivery object via nms.delivery.load(pk), I am able to read the corresponding xml nodes (as created by the content schema/form), however, delivery.save() is not saving the resulting xml neither gives any error. I have also tried to update the delivery subject in the same code which is working.

 

I know using the delivery script tab or typology this would work. However, is it for a fact that from a workflow, this delivery xml edit will not work?

@wodnicki @CedricRey , @Deb007 @craigthonis 

Thanks everyone, looking for your help!!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 10
Level 3
CedricRey
Level 3

Likes

24 likes

Total Posts

65 posts

Correct Reply

12 solutions
Top badges earned
Boost 10
Applaud 5
Boost 5
Affirm 5
Give Back
View profile

Avatar
Boost 10
Level 3
CedricRey
Level 3

Likes

24 likes

Total Posts

65 posts

Correct Reply

12 solutions
Top badges earned
Boost 10
Applaud 5
Boost 5
Affirm 5
Give Back
View profile
CedricRey
Level 3

03-06-2021

Hello,

I know the situation : you use the embeded content into the delivery (with publishing model linked). Users edit directly the content (ncm:content) with the delivery form.

I just did some test, and yes, the embeded content cannot be modified with standard method '.save()' (or maybe needs something more). Unfortunately you can't just use the load method, modify the xml part of content and save it : it doesn't work.

So, how the console does ?

The console use the xtk:session:Write method, and by this way, it works.

So, you need to get the xml version of your delivery, modify the content and send this xml version of your delivery to xtk:session:Write method.

Here an example :

 

var id = 12345;
var delivery = nms.delivery.load(id);
var deliveryXML = delivery.toXML(); //get the "XML version" of the delivery
deliveryXML.content.content.Content1.@title = "Hello world"; //Change the content part we need to change. Can remove / add blocks, iterate, remove text etc. Here my content root name is 'Content1', change with your.
deliveryXML.@xtkschema = "nms:delivery"; //Add the schema, needed for xtk.session.Write
deliveryXML.@_operation = "update";
//logInfo( deliveryXML );You can check if you want
NLWS.xtkSession.Write( deliveryXML ); //Save the delivery, but not with the classic save() method, with session Write

 

 

The embeded content (the 'schema' with block that user modify with 'forms') is located near the html source : delivery.content.content

 

In addition, the console render the content with the "ncm:publishing:Transform" method and put the result into the delivery.content.html.source part before saving the delivery. It's just for convinience when a user open the delivery after (to get a good preview). But it's not mandatory as the source seems to be recalculated during analysis / preparation.

 

Cedric

supratim320
Another question @CedricRey: I can see that the html/text are not changing and still holding on to the old value. So, I tried to go for ncm.publishing.Transform(), however, for some strange reason, I am getting "Error while excuting and file does not exist (datakit/eng/schema/.xml does not exist)". Is there any working version of this method? I am not able to find if any
supratim320
Another question @CedricRey: I can see that the html/text are not changing and still holding on to the old value. So, I tried to go for ncm.publishing.Transform(), however, for some strange reason, I am getting "Error while excuting and file does not exist (datakit/eng/schema/.xml does not exist)". Is there any working version of this method? I am not able to find if any.
CedricRey

Here what the console send to the server to get the HTML content :

<Transform xmlns='urn:ncm:publishing'> 
  <strPublishingId xsi:type='xsd:string'>cus:Content1</strPublishingId> 
  <strModelName xsi:type='xsd:string'>HTML</strModelName> 
  <elemContent xsi:type='ns:Element'> 
   <Content1 ....... xtkschema="cus:Content1"/> 
  </elemContent> 
</Transform> 

So, you must be sure to have the @xtkschema on the root element of your content, containing the name of your content schema (ns:name). If not present, it throws the same error you had.

Here the same but in JS :

var result = ncm.publishing.Transform(
  'cus:Content1', //ncm:publishing name
  'HTML', //model name of the ncm:publishing
  <Content1 title="test" xtkschema="cusContent1"/>
  );

Answers (4)

Answers (4)

Avatar

Avatar
Give Back
Level 2
supratim320
Level 2

Likes

2 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 1
View profile

Avatar
Give Back
Level 2
supratim320
Level 2

Likes

2 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 1
View profile
supratim320
Level 2

02-06-2021

Hello Everyone and Thanks for your reply. However, I feel I have not been able to articulate enough for you two to see the problem.

I am using publication module in the delivery template. So, I have a content schema, content form and js template. Based on the values the user is providing on the content form, js template will play around those values and create the html source/txt source. Now this user, when is providing the values on the content form, is providing them as "https://www.google.com/?utm_content=abc&utm_source=campaign.." and based on that js template is creating say a <a> tag with this value as "href". My task is to remove the utm tags. As you have mentioned removing those from the resulting html using a workflow (prepared via js template) will only be a temporary solution if I cannot make the changes into the content form values, i.e.- I will also have to change "https://www.google.com/?utm_content=abc&utm_source=campaign.." into "https://www.google.com/" in the content form. If I don't make the change in the content form and change only the html/source (delivery.content.html.source) then the moment user will try to open the delivery and try to check the preview mode, the google link with utm parameters will replace my html source changes. So, I am looking a way out to not change the html/text values, rather directly hitting the content form values. Hope I am able to state the problem clearly, let me know your thoughts

Avatar

Avatar
Boost 10
Level 3
CedricRey
Level 3

Likes

24 likes

Total Posts

65 posts

Correct Reply

12 solutions
Top badges earned
Boost 10
Applaud 5
Boost 5
Affirm 5
Give Back
View profile

Avatar
Boost 10
Level 3
CedricRey
Level 3

Likes

24 likes

Total Posts

65 posts

Correct Reply

12 solutions
Top badges earned
Boost 10
Applaud 5
Boost 5
Affirm 5
Give Back
View profile
CedricRey
Level 3

01-06-2021

Hello @supratim320 

I'm not sure how you try to modify the content (and I can totaly misunderstand the problem...), but when I try to change a delivery html content, It works.

I'm not sure this is an urlconfig problem if I understand well (sorry Laurent) because the urlConfigs is calculated during the personalisation (for the tracking config generation) and might appears when the user want a preview of it (but will be recalulated after).

If I understand well, you want to delete all the utm parameter in the links into the HTML content before the preparation.

Can you give a try to the following code ?

var deliveryId = 123456789 //Replace with your deliveryId
var delivery = nms.delivery.load( deliveryId );
var newContent = delivery.content.html.source.toString().replace(/([?&])?utm=[^&"]*/gi,"");
delivery.content.html.source = newContent;
delivery.save();

This is a very global approach (because It replace all the "utm=xyz", not only in <a> links). I've just tested it and it works.

I'm afraid of misunderstanding your problem....

Let me know.

Cedric

Avatar

Avatar
Give Back
Level 2
supratim320
Level 2

Likes

2 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 1
View profile

Avatar
Give Back
Level 2
supratim320
Level 2

Likes

2 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 1
View profile
supratim320
Level 2

31-05-2021

Thanks @LaurentLam for the reply.

a. urlConfig is actually not visible in the delivery xml unless and until you click on the "Display url" or Open the tracking tab. Also urlConfig is for the final html source/text field. However, in my use case the concerned fields are present in ncm content form. And even if I change the html/text part, in the content form the same button url textbox will contain the actual value (with utm tags)

b. Also, looking at this page, I understood that urlConfig is editable only inside typology/ delivery activity script tab. However, in my case, I am creating a one time data patching workflow, so I thought to go through nms.delivery.load and subsequent save method only (ref: https://experienceleaguecommunities.adobe.com/t5/adobe-campaign-standard/can-we-add-the-variables-in...)

LaurentLam

I've made a test no issue for me:

 

var delivery = NLWS.nmsDelivery.load(1234)

source = delivery.content.html.source

=====

transformation of source through regex

=====

delivery.content.html.source = source

delivery.save();

 

 

just use this to test quickly:

var delivery = NLWS.nmsDelivery.load(1234);

delivery.content.html.source = "my test";

delivery.save();

 

I'm using an old 6.1 ACC version

supratim320
Thanks for the sample code @LaurentLam, however, as stated in the first statement, I am using delivery template via "Publication Template" and not the default html/source palette inside the delivery. And the user is manually filling in the href values inside a textbox. So, by virtue of using a publication template, a js template is playing around those text value and creating the content. Hence, it is not about changing the html/source directly, rather changing the ncm:content based input form values as well
supratim320
I am putting here a sample code for better understanding of what is not working:
supratim320
I am putting here a sample code for better understanding of what is not working:var id = parseInt(result.delivery[0].@id); var deliveryXml = nms.delivery.load(id); var newblocks = <blocks blockId="3693740075" blockType="hero" image-cs="banner" image_alt="google" image_url="https://www.google.com/test1/test2/?utm_campaign=myCampaign" name="3693740075"> <blockConditions schema="nms:recipient"/> <image id="4477570" image-cs="banner_c2h"/> </blocks>; var xml = new XML(newblocks); deliveryXml.content.content.myContent.appendChild(xml); deliveryXml.save();
CedricRey

Hello,

I know the situation : you use the embeded content into the delivery (with publishing model linked)

I just did some test, and yes, the embeded content cannot be modified with standard method (or maybe needs something more). Unfortunately you can't just use the load method, modify the xml part of content and save it : it doesn't work.

So, how the console do ?

The console use the xtk:session:Write method, and by this way, it works.

So, you need to get the xml version of your delivery, modify the content and send this xml version of your delivery to xtk:session:Write method.

Here an example :

 

var id = 12345;
var delivery = nms.delivery.load(id);
var deliveryXML = delivery.toXML(); //get the "XML version" of the delivery
deliveryXML.content.content.Content1.@title = "Hello world"; //Change the content part we need to change. Can remove / add blocks, iterate, remove text etc.
deliveryXML.@xtkschema = "nms:delivery"; //Add the schema, needed for xtk.session.Write
deliveryXML.@_operation = "update";
//logInfo( deliveryXML );You can check if you want
NLWS.xtkSession.Write( deliveryXML ); //Save the delivery, but not with the classic save() method, with session Write

 

In addition, the console render the content with the "ncm:publishing:Transform" method and put the result into the delivery.content.html.source part before saving the delivery. It's just for convinience when a user open the delivery after (to get a good preview). But it's not mandatory as the source is recalculated when sending.

 

Cedric

Avatar

Avatar
Affirm 5
Level 2
LaurentLam
Level 2

Likes

14 likes

Total Posts

52 posts

Correct Reply

5 solutions
Top badges earned
Affirm 5
Boost 10
Contributor
Applaud 5
Affirm 3
View profile

Avatar
Affirm 5
Level 2
LaurentLam
Level 2

Likes

14 likes

Total Posts

52 posts

Correct Reply

5 solutions
Top badges earned
Affirm 5
Boost 10
Contributor
Applaud 5
Affirm 3
View profile
LaurentLam
Level 2

31-05-2021

Hello did you try to update delivery.content.html.urlConfig.url[index].source?

and same thing for delivery.content.text.urlConfig.url[index].source

In any case, be sure to refresh your nlClient local cache before checking