cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

New question on filtering using Query XML action

Hello. I had a similar question a couple of months ago. Basically I'm trying to pull a certain node's information based on another node. XML below so you can see what I'm referring to. 

<?xml version="1.0"?>

<TICKETS>

   <INCIDENT_NUMBER ID="INC12345678910">

       <CORPORATE_ID>USEID25</CORPORATE_ID>

       <FULLNAME>John Smith</FULLNAME>

       <DIVISION>I.T.</DIVISION>

  </INCIDENT_NUMBER>

</TICKETS>

Now based on the Corporate ID in the file I want to choose the Incident number so I can place that in a variable. 

 Using the below xpath I can do the reverse and pull the corporate ID. 

//INCIDENT_NUMBER[@ID='INC12345678910']/CORPORATE_ID

Since Incident_Number is the parent node I can't seem to figure out how to reverse that. Does anyone have any thoughts?

Thanks in advance.

0 Kudos
Reply
10 Replies
Workflow Hero

Re: New question on filtering using Query XML action

following XPath expression should work

//INCIDENT_NUMBER[./CORPORATE_ID='USEID25']/@ID

<?xml version="1.0"?>
<TICKETS>
   <INCIDENT_NUMBER ID="INC12345678910">
       <CORPORATE_ID>USEID25</CORPORATE_ID>
       <FULLNAME>John Smith</FULLNAME>
       <DIVISION>I.T.</DIVISION>
  </INCIDENT_NUMBER>
   <INCIDENT_NUMBER ID="INC11111111111">
       <CORPORATE_ID>USEID99</CORPORATE_ID>
       <FULLNAME>John Smith</FULLNAME>
       <DIVISION>I.T.</DIVISION>
  </INCIDENT_NUMBER>
   <INCIDENT_NUMBER ID="INC2222222222">
       <CORPORATE_ID>USEID25</CORPORATE_ID>
       <FULLNAME>John Smith</FULLNAME>
       <DIVISION>I.T.</DIVISION>
  </INCIDENT_NUMBER>
</TICKETS>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Accept as Solution Reply
Workflow Hero

Re: New question on filtering using Query XML action

Yes that did it so helpful as always Marian. I was just added another detail to that request. Another node was added. This one is called description. It now looks like below:

<?xml version="1.0"?>

<TICKETS>

   <INCIDENT_NUMBER ID="INC12345678910">

       <CORPORATE_ID>USEID25</CORPORATE_ID>

       <FULLNAME>John Smith</FULLNAME>

       <DIVISION>I.T.</DIVISION>

       <DESCRIPTION>PC Build/Deployment-DRF404Human Resources -HR</DESCRIPTION>

  </INCIDENT_NUMBER>

</TICKETS>

So now on top of your xpath that pulled the Incident Number we further want to narrow it down to find the text in bold. Basically that text is DFR plus the SharePoint list ID. So I can easily pull that into a variable (VAR_DFR) how can I properly plug that into the expression you wrote?

Thanks very much for all your help. 

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: New question on filtering using Query XML action

that should be easy one already, shouldn't it?

//INCIDENT_NUMBER[./CORPORATE_ID='USEID25']/DESCRIPTION

that returns whole description. apply a regular expression to cut out your identifier

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: New question on filtering using Query XML action

Haha yes I did try that exact expression. And you are correct it does pull the whole description. I guess I should completely explain my goal. Using your first expression will get me a number of incident numbers. Of which I need only one. So to be specific I can have the below in two Outputs. But the information in bold is what I would like to specifically pull. So even though I can Regedit and pluck the DFR404 out I would need it associated with it's correct Incident number. I have an advantage that the DFR404 "number" is just the list ID (of the same list I have this workflow on) just with DFR added to the front. So basically I'm sending an email to create a ticket in our ticketing system with that info then placing a pause in my workflow in which an outside SharePoint script generates the XML every hour with that information and when my workflow resumes I want to pluck the relevant info to place into a field in my list. Does that make sense?

Output 1
INC000001234567
INC000001234568
INC000001234569

Output 2
Access Request
DFR404 Human Resources
IDs: reset passwords

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: New question on filtering using Query XML action

to be honest, I'm not quite sure what's exactly your concern.

do you have doubts how to match related content of the same (parent) node out of two result sets (collections)?

if so, then if both result sets are returned by the same action, you can be sure that related data are at the same index position in both result sets.

or do you mean you only want to return incident ID(s) where both corporate and description elements satisfy some condition(s) at same time?

then XPath expression like follows might suit you

//INCIDENT_NUMBER[./CORPORATE_ID='USEID25' and contains(./DESCRIPTION/text(),'DRF')]/@ID

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: New question on filtering using Query XML action

Definitely the second option is what I'm looking for, although I tried your expression and got nothing from my Output. I did copy and paste the XML we've been using in this thread and tried again and it did work. But it's a very shortened version of the XML I'm actually using. I'm wondering if that's the reason why I'm geting nothing in my Output. The full array is below.

<TICKETS>

  <INCIDENT_NUMBER ID="INC12345678910">

       <CORPORATE_ID>USEID25</CORPORATE_ID>

       <FULLNAME>John Smith</FULLNAME>

       <DIVISION>I.T.</DIVISION>

       <STATUS>0</STATUS>

       <DESCRIPTION>PC Build/Deployment-DRF404Human Resources -HR</DESCRIPTION>

        <RESOLUTION>Deployed</RESOLUTION>

        <ASSIGNED_GROUP>Deployment Team</ASSIGNED_GROUP>

        <ASSIGNEE>Jane Doe</ASSIGNEE>

        <LAST_MODIFIED_DATE>Thurs June 14 01:00:40 2018</LAST_MODIFIED_DATE>

        <SUBMIT_DATE> Thurs June 14 01:00:40 2018</SUBMIT_DATE>

        <DESCRIPTION_WORKDETAILS>Lorem Ipsum Dolor</DESCRIPTION_WORKDETAILS>

        <DESCRIPTION_WORKDETAILS>Lorem Ipsum Dolor</DESCRIPTION_WORKDETAILS>

  </INCIDENT_NUMBER>

</TICKETS>

Would that make a difference?

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: New question on filtering using Query XML action

it should work ...

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: New question on filtering using Query XML action

Yes it did!! So sorry to bug you more than I needed to. It turns out it was DFR not DRF. So it now it works. One last thing it seems to care about case. Is there a way to get past that? Because some of the usernames are in upper case others are not. If it's too much of  an issue I'll just create a calculated field to uppercase everything.

Thanks SO much for your help. 

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: New question on filtering using Query XML action

Nevermind to this I just used a Regex to make all lowercase and it's all working happily. Thanks again very much you are the best.

0 Kudos
Accept as Solution Reply