AnsweredAssumed Answered

how to find value with Groovy

Question asked by AlexeyDmitriev6991 on Jun 14, 2016
Latest reply on Jun 15, 2016 by AlexeyDmitriev6991

Hi guys,

please advise how to find and output cust_JiraTaskId. I need the value of cust_JiraTaskId based on the max number of <externalCode> inside node  <cust_JiraTask> . In this example it'll be 111111.

 

<SFOData.cust_JiraReplication>

   <cust_HRISId>J000009</cust_HRISId>

   <externalCode>7</externalCode>

<cust_JiraTask>

      <externalCode>3</externalCode>

      <cust_JiraTaskId>12345</cust_JiraTaskId>

  </cust_JiraTask>

<cust_JiraTask>

      <externalCode>5</externalCode>

      <cust_JiraTaskId>111111</cust_JiraTaskId>

  </cust_JiraTask>

</SFOData.cust_JiraReplication>

I managed to find the max externalCode and now i need cust_JiraTaskId value.

 

My script is below -

 

// Create an XPath statement to search for the element or elements you care about:

  XPath x;

  x = XPath.newInstance("//cust_JiraTask/externalCode");

  myElements = x.selectNodes(doc);

  String maxvalue = "";

 

  for (Element myElement : myElements) {

    if (myElement.getValue() > maxvalue)

    {

      maxvalue = myElement.getValue();

    }

  }

props.setProperty("document.dynamic.userdefined.externalCode", maxvalue);

 

thanks for help.

Outcomes