Updating XML Additional Data for a Seed Address | Community
Skip to main content
May 10, 2023
Solved

Updating XML Additional Data for a Seed Address

  • May 10, 2023
  • 1 reply
  • 1299 views

Hi all,

 

I would like to ask for some assistance with the following.

Lets assume that an existing Seed address has the below XML data present inside the Additional Data tab

 

 

 

Using a Javascript activity inside a workflow, i'm able to retrieve the value of attribute "attribute_1" and log it successfully in the workflow log.

 

var seed = nms.seedMember.load(My_Test_Seed); //load the seed address record
logInfo(seed.targetData.testData.@attribute_1); //This logs the value "Yes" fine in the workflow log
seed.save(); //save the seed address record

 

What i'm looking to be able to do, again using a Javascript inside a workflow, is to be able to update the value of attribute_1 to "No".

I tried something simple like the below but it doesn't work:

 

var seed = nms.seedMember.load(My_Test_Seed);

seed.targetData.testData.@attribute_1 = "No" //Update value to "No" - This does not work

seed.save(); //save the seed address record

 

Even though the script doesn't through any errors or anything, the value does not update. Anyone has any ideas or knows if/how its possible to achieve this? If its possible, i'm assuming maybe it needs some XML parsing or something, but i'm not sure (not really too familiar with XML in general)

 

Any assistance appreciated.

 

Regards

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by isahore

Hi @vavasol,

Firstly, your xml has two elements with the same name "testData". You might want to club them into one, with two different attributes.

The following script should update the attribute value.

var seed = nms.seedMember.load(Your_seed_id).toDocument(); //load the seed address record seed.getElementsByTagName("testData")[0].setAttribute("attribute_1","No"); seed.root.setAttribute("xtkschema","nms:seedMember"); seed.root.setAttribute("_operation","update"); xtk.session.Write(seed); //save the seed address record

1 reply

isahore
Community Advisor
isahoreCommunity AdvisorAccepted solution
Community Advisor
May 11, 2023

Hi @vavasol,

Firstly, your xml has two elements with the same name "testData". You might want to club them into one, with two different attributes.

The following script should update the attribute value.

var seed = nms.seedMember.load(Your_seed_id).toDocument(); //load the seed address record seed.getElementsByTagName("testData")[0].setAttribute("attribute_1","No"); seed.root.setAttribute("xtkschema","nms:seedMember"); seed.root.setAttribute("_operation","update"); xtk.session.Write(seed); //save the seed address record
vavasolAuthor
May 17, 2023

@isahore much appreciated! This worked.