Expand my Community achievements bar.

SOLVED

Delete proof seed programmatically from delivery

Avatar

Level 2

I'm trying to programatically remove a proof seed from a delivery.

I can remove the FCPseed from the delivery XML but since the FCPSeeds are not in a node of itself but directly as array under delivery node the write function doesn't remove anything. It only updates or adds.

How can I remove an FCPSeed programmatically?

 

Example of the code I have that does not work:

function removeProofSeedFromDelivery(proofSeedId, deliveryId){
  var deliveryObject = nms.delivery.load(deliveryId); //Load delivery
  var delivery = deliveryObject.toXML(); // Convert object to XML to manipulate with JXON

 
  delivery.@xtkschema = "nms:delivery"; //Add the schema, needed for xtk.session.Write
  delivery.@_operation = "update"; //Add operation, needed for xtk.session.Write

 

  //Iterate FCPSeeds in delivery and delete matching node
  var i = 0;
  for each(fcp in delivery.FCPSeed){
    if(fcp.@id == proofSeedId){
      delete delivery.FCPSeed[i];
      break;
    }
    i++
  }
  NLWS.xtkSession.Write( delivery ); //Save changes to delivery
}

1 Accepted Solution

Avatar

Correct answer by
Level 2

Thanks Manoj,

delivery.FCPSeed.removeAll() works for removing all Seeds.

 

I'm going to try to:

1. load delivery

2. save existing seeds in a variable

3. remove all seeds - with FCPSeed.removeAll()

4. save delivery

5. reload delivery

6. re-add existing seeds (except for the one I wanted removed).

7. save delivery

 

Would wish there was a way to remove just one. But this will be ok as a workaround.

View solution in original post

2 Replies

Avatar

Community Advisor

hello @PLundmark 

 

You can remove the proofs and seeds like this.

 

// Load the delivery data
var delivery=nms.delivery.load(DELIVERY_ID); 

//remove proofs from substitution
delivery.fcpParameters.substitution.removeAll();

//remove seeds from the dynamic conditions
delivery.output.seedList.where.condition.removeAll();

//save the delivery
delivery.save();

     Manoj
     Find me on LinkedIn

Avatar

Correct answer by
Level 2

Thanks Manoj,

delivery.FCPSeed.removeAll() works for removing all Seeds.

 

I'm going to try to:

1. load delivery

2. save existing seeds in a variable

3. remove all seeds - with FCPSeed.removeAll()

4. save delivery

5. reload delivery

6. re-add existing seeds (except for the one I wanted removed).

7. save delivery

 

Would wish there was a way to remove just one. But this will be ok as a workaround.