Help needed in extracting values from XML
SAMPLE XML:
- <Form1>
- <Name>
<Ttl>MR</Ttl>
<Fore>ABC1</Fore>
<Sur>XYZ2</Sur>
</Name>
- <Address>
<Line>ADD_LINE_1</Line>
<Line>ADD_LINE_2</Line>
<PostCode>PST CDE</PostCode>
</Address>
<BirthDate>0001-01-01</BirthDate>
- <Details>
<TotalEarnings>1234567.00</TotalEarnings>
<TotalDeduction>12345.00</TotalDeduction>
</Details>
</Form1>
- <Form1>
- <Name>
<Ttl>MR</Ttl>
<Fore>ABC2</Fore>
<Sur>XYZ2</Sur>
</Name>
- <Address>
<Line>ADD_LINE_3</Line>
<Line>ADD_LINE_4</Line>
<PostCode>PST CDE</PostCode>
</Address>
<BirthDate>0002-02-02</BirthDate>
<Gender>female</Gender>
- <Details>
<TotalEarnings>12345.00</TotalEarnings>
<TotalDeduction>123.00</TotalDeduction>
</Details>
</Form1>
There can be any 'n' number of <Form1>'s in one XML.But I want to get only the details of the person whose TotalEarnings>1million. Details include
Name->Ttl,Fore,Sur
which in this case would be MR,ABC1,XYZ1
Address->Line,Line,Postcode
which in this case would be ADD_LINE_1,ADD_LINE_2,PST CDE
Birthdate
which in this case would be 0001-01-01
Gender
which in this case would be "null" as there is no Gender tag present
Details->TotalEarnings,TotalDeduction
which in this case would be 1234567.00,12345.00
The technique I was using is,
1. Convert to clob
2. User dbms_instr find the location of <Form1> in a loop
3. For every occurence of <Form1> I find <TotalEarnings> value and check if this is greater than 1 million.
4. If true, I use dbms_instr to get the values of all the tags inside <Form1>
5. The drawback of using dbms_instr is that it gets the value of first occurence of whatever sting we supply.In this case dbms_instr(xml,'<Gender>',position of Form1) will not return null whereas it will return "Female" from the next form. This is wrong as it doesnt belong to the person who earns more than a million.
Can anyone suggest a way to fetch the values that only belong to the form of the person who earns more than a million?
There can be any 'n' number of <Form1>'s in one
XML.Not if you want the XML to be valid there can't. You would need a root element around all the <Form1>'s to make it valid.
The technique I was using is,
1. Convert to clob
2. User dbms_instr find the location of <Form1> in a
loop
3. For every occurence of <Form1> I find
<TotalEarnings> value and check if this is greater
than 1 million.
4. If true, I use dbms_instr to get the values of all
the tags inside <Form1>
5. The drawback of using dbms_instr is that it gets
the value of first occurence of whatever sting we
supply.In this case
dbms_instr(xml,'<Gender>',position of Form1) will not
return null whereas it will return "Female" from the
next form. This is wrong as it doesnt belong to the
person who earns more than a million.
Can anyone suggest a way to fetch the values that
only belong to the form of the person who earns more
than a million?Why on earth are you using dbms_instr for this? Oracle has built in XML functionality for use against XMLTYPE data, such as the ExtractValue method and the use of XPATH expressions.
I'd suggest you start reading some of the manuals regarding XML functionality in Oracle rather than trying to manually parse it all.
Similar Messages
-
Extracting value from XML tags in Java
Hi all,
I need to extract the value from a string (XML Format). Eg. <Name>Ray</Name> and displaying Name: Ray
The string value is like any other String class object except that it is format with XML tags. I have quite a few examples that shows how a value can be read from a .xml file but none that describe how to get a value from a String object.
Thanks in advance.DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.parse("Your XML Goes here "); -
Extracting Values from XML-Document in pl/sql
Hello!
I need to extract the content of the following extract:
<ns1:OXERPGetArticlesResponse xmlns:ns1="OXERPService">
<ns1:OXERPGetArticlesResult>
<ns1:OXERPType>
<ns1:aResult>
<ns1:ArrayOfString>
<ns1:string>OXID</ns1:string>
<ns1:string>531f91d4ab8bfb24c4d04e473d246d0b</ns1:string>
</ns1:ArrayOfString>
<ns1:ArrayOfString>
<ns1:string>OXARTNUM</ns1:string>
<ns1:string>0601-85-069</ns1:string>
</ns1:ArrayOfString>
<ns1:ArrayOfString>
<ns1:string>OXPRICE</ns1:string>
<ns1:string>100.5</ns1:string>
</ns1:ArrayOfString>
</ns1:aResult>
<ns1:blResult>true</ns1:blResult>
<ns1:sMessage/>
</ns1:OXERPType>
<ns1:OXERPType>
<ns1:aResult>
<ns1:ArrayOfString>
<ns1:string>OXID</ns1:string>
<ns1:string>531a8af7d9a9a5bb53b65a2b9a5356e5</ns1:string>
</ns1:ArrayOfString>
<ns1:ArrayOfString>
<ns1:string>OXARTNUM</ns1:string>
<ns1:string>0601-85-069-1</ns1:string>
</ns1:ArrayOfString>
<ns1:ArrayOfString>
<ns1:string>OXPRICE</ns1:string>
<ns1:string>89.9</ns1:string>
</ns1:ArrayOfString>
</ns1:aResult>
<ns1:blResult>true</ns1:blResult>
<ns1:sMessage/>
</ns1:OXERPType>
</ns1:OXERPGetArticlesResult>
</ns1:OXERPGetArticlesResponse>
The output should be:
OXID OXARTNUM OXPRICE
531f91d4ab8bfb24c4d04e473d246d0b 0601-85-069 100.5
531a8af7d9a9a5bb53b65a2b9a5356e5 0601-85-069-1 89.9
The count of rows and columns is variable.
I want to do this by using xmltype.extract but I found no way to create a loop over the content of the xml document.
Hopefully someone can help me!
Regards
HerbertOK, then you should be able to use something like :
SQL> var xmldoc clob;
SQL> begin
2 :xmldoc := '<ns1:OXERPGetArticlesResponse xmlns:ns1="OXERPService">
3 <ns1:OXERPGetArticlesResult>
4 <ns1:OXERPType>
5 <ns1:aResult>
6 <ns1:ArrayOfString>
7 <ns1:string>OXID</ns1:string>
8 <ns1:string>531f91d4ab8bfb24c4d04e473d246d0b</ns1:string>
9 </ns1:ArrayOfString>
10 <ns1:ArrayOfString>
11 <ns1:string>OXARTNUM</ns1:string>
12 <ns1:string>0601-85-069</ns1:string>
13 </ns1:ArrayOfString>
14 <ns1:ArrayOfString>
15 <ns1:string>OXPRICE</ns1:string>
16 <ns1:string>100.5</ns1:string>
17 </ns1:ArrayOfString>
18 </ns1:aResult>
19 <ns1:blResult>true</ns1:blResult>
20 <ns1:sMessage/>
21 </ns1:OXERPType>
22 <ns1:OXERPType>
23 <ns1:aResult>
24 <ns1:ArrayOfString>
25 <ns1:string>OXID</ns1:string>
26 <ns1:string>531a8af7d9a9a5bb53b65a2b9a5356e5</ns1:string>
27 </ns1:ArrayOfString>
28 <ns1:ArrayOfString>
29 <ns1:string>OXARTNUM</ns1:string>
30 <ns1:string>0601-85-069-1</ns1:string>
31 </ns1:ArrayOfString>
32 <ns1:ArrayOfString>
33 <ns1:string>OXPRICE</ns1:string>
34 <ns1:string>89.9</ns1:string>
35 </ns1:ArrayOfString>
36 </ns1:aResult>
37 <ns1:blResult>true</ns1:blResult>
38 <ns1:sMessage/>
39 </ns1:OXERPType>
40 </ns1:OXERPGetArticlesResult>
41 </ns1:OXERPGetArticlesResponse>';
42 end;
43 /
Procédure PL/SQL terminée avec succès.
SQL> SELECT x1.rec_id
2 , x2.col_name
3 , x2.col_value
4 FROM XMLTable(
5 XMLNamespaces('OXERPService' as "ns1"),
6 '/ns1:OXERPGetArticlesResponse/ns1:OXERPGetArticlesResult/ns1:OXERPType/ns1:aResult'
7 passing xmltype(:xmldoc)
8 columns rec_id for ordinality
9 , rec_xml xmltype path 'ns1:ArrayOfString'
10 ) x1,
11 XMLTable(
12 XMLNamespaces('OXERPService' as "ns1"),'/ns1:ArrayOfString'
13 passing x1.rec_xml
14 columns col_name varchar2(30) path 'ns1:string[1]'
15 , col_value varchar2(30) path 'ns1:string[2]'
16 ) x2
17 ;
REC_ID COL_NAME COL_VALUE
1 OXID 531f91d4ab8bfb24c4d04e473d246d
1 OXARTNUM 0601-85-069
1 OXPRICE 100.5
2 OXID 531a8af7d9a9a5bb53b65a2b9a5356
2 OXARTNUM 0601-85-069-1
2 OXPRICE 89.9
6 ligne(s) sélectionnée(s).You mentioned that the number of column(s) is not known in advance. That's gonna be a problem to present the data column-wise.
Version 11g has the PIVOT feature, but still you have to know how many columns there will be in the result set.
How are you going to use the data after extraction?
Maybe we could advise some other techniques more relevant for your requirement. -
Re: Help needed in passing values from workflow to Approve Forms
Dear Experts,
how do I pass values from a workflow to a step (Form) - approve form?
I am using a customized table structure as my data source (FORMCONTAINERELEMENT) but am stuck on how to access the data when i get to to the screen painter's flow logic... What am i missing? Can you give me a step by step example. the ones i see on the net are input fields that update the screen... nothing that shows value being passed from the outside.
I need to pass an exisitng value in the workflow into the form for approval of the the assigned agent.
Please help!!
Thank you.Hello !
Create a method just before the form step.This method should populate the values for the fields maintained in the form.
Pass the values populated from this method to your customized table structure (data source).In other words, you have to pass all the values to the workflow container.
To the step, pass this workflow container by binding.In the control tab of form step, you have to do the binding.
Regards,
S.Suresh -
Regular expression to extract value from xml
Hi,
I need to extract the value of an XML tag.
<purchaseId>Best-200423</purchaseId>
The result of the expression should be: "Best-200423".
Something like this ([^\\<purchaseId\\>]*[^\\</purchaseId\\>]) does not work.
Does somebody has a soltuion?
I can't get it to work! I want to use the Java Regular Expression functionality.
Best wishes
JochenYou got lucky, is all. Try changing "Best" to "pest" in your example and it won't work. The square brackets are spurious, and you want m.getGroup(1) to get the stuff that matches the () group.
Square brackes mean "match any of the characters in the brackets". [^ means "match any character not in this list"). -
Help needed to merge values from two tables -
We have these three test tables shown, which have a common ID; And amount fields; I want the -------
test1.val = test2.val + test3.val
when they have common ids in them;
I have shown the test data below: And the expected output;
NOTE: In database with real table values - each of them have millions of rows in them. So effeciency is very important here;
SQL> desc test1;
Name Null? Type
ID NUMBER
VAL NUMBER
SQL> desc test2;
Name Null? Type
ID NUMBER
VAL NUMBER
SQL> desc test3;
Name Null? Type
ID NUMBER
VAL NUMBER
SQL> select * from test1;
ID VAL
1 50
2 50
3 55
4 60
5 20
5 rows selected.
SQL> select * from test2;
ID VAL
1 25
1 25
2 5
2 5
4 75
5 rows selected.
SQL> select * from test3;
ID VAL
1 25
1 25
2 5
2 25
2 25
5 10
6 rows selected.
I EXPECT the output to be:
SQL> select * from test1;
ID VAL
1 100
2 65
3 20
4 75
3 20
5 10
6 rows selected.Need help with the update queries - joining three tables -
-
Help needed in extracting data from PCD tables
Hi Friends
I Have a requiremnt for creating custom portal activity report ,even though
we have standard report, the extraced data will be used to create bw reports later.
my part is to find a way to extract the data from PCD tables for creating
custom portal activity reports
i have selected the following tables for the data extraction
WCR_USERSTAT,WCR_WEBCONTENTSTAT,WCR_USERFIRSTLOGON,
WCR_USERPAGEUSAGE.
My questions are
1.Did i select the Exact PCD tables?
2.Can i use UME api for accessing the data from those tables?
3.can i use the data extracted from PCD tables in JSPdynpage or
webdynpro apps?
4.can i Querry the PCD tables from JSPDynpage or Webdynpro
Please help me in finding a solution for this
Thanks
Ashok BattulaHi daniel
Can u tell me weather i can develop the following custom reports from those WCR tables
Report Type
1 Logins
- Unique Count
- Total Count
- Most Active Users (by Partner Name)
- Most Active Users (by Contact Name)
- Entry Point (by page name)
- Session Time
- Hourly Traffic Analysis
2 Login Failures
- Total Count
- Count by error message
- Credentials Entered (by user name and password)
3 Content Views (by File Name)
- Unique Count
- Total Count
- Most requested Files
- Most requested Pages
- File Not Found
4 Downloads (by File Name)
- Unique Count
- Total Count
- Most requested Files
- File Not Found
5 Portal Administration
- Site Content (by file name)
- Site Content (by page name)
- Latest Content (by file name)
- Expired Content (by file name)
- Subscriptions Count (by file name)
6 Login History (by Partner, Contact Name)
- No Login
- First Login
- Duration between registration and first login
- Most Recent Login
- Average Number of Logins
plz help me in find ing a way
thanks
ashok -
Help needed in getting values from the dynamically created text boxes
Hello,
I am developing one jsp page using struts. In the page i m
dynamically adding some rows with two text boxes in each row. and after entering data into
those textboxes , user clicks on save button and page is submitted.
I want to capture all this data of dynamically added
rows so that i can enter those rows into DB.
how can i acheive this using struts?.
Have anyone had tried doing it?. Please help.
Thanx in advance
Deepali NaikHi,
1. If you give these textBoxes the same name, then in your action you can call request.getParameterValues(paramName) - it returns String[ ] of values.
2. You can give form textBox names like "name"+index or something like this in <logic:iterate> tag
Good luck! -
Help needed in converting Excel from XML file
Hi Can anyone help me in converting XML in to Excel.
Thanx,
Ananth.well, that still isn't much to go off of. I give it a try though.
I guess you want to parse out the relevent data out of the xml file and then decide on your favorite delimated file format for Excel. Two popular formats are comma delimated:
"info1","info2","info3","info4"
and tab delimeted:
info <tab> info2 <tab> info3 <tab> info4
Excel should be able to unsestand either of these formats. -
Extract value from XML column .
Hi,
I'm on 11.2.0.3 and got query
select other_xml from v$sql_plan where sql_id=’2y32qkr40b82a’ and other_xml is not null
<other_xml><info type="db_version">11.2.0.3</info>
<info type="parse_schema"><![CDATA["LIU"]]></info><info type="dynamic_sampling">2</info>
<info type="plan_hash">3882242470</info><info type="plan_hash_2">281948136</info>
<peeked_binds><bind nam=":N1" pos="1" dty="2" pre="0" scl="0" mxl="22">c30d51</bind>
<bind nam=":N2" pos="2" dty="2" pre="0" scl="0" mxl="22">c30d51</bind>
<bind nam=":N3" pos="3" dty="2" pre="0" scl="0" mxl="22">c30d51</bind></peeked_binds>
<outline_data><hint><![CDATA[IGNORE_OPTIM_EMBEDDED_HINTS]]></hint>
<hint><![CDATA[OPTIMIZER_FEATURES_ENABLE('11.2.0.3')]]></hint>
<hint><![CDATA[DB_VERSION('11.2.0.3')]]></hint>
<hint><![CDATA[FIRST_ROWS(100)]]></hint>
<hint><![CDATA[OUTLINE_LEAF(@"SEL$1")]]></hint>
<hint><![CDATA[FULL(@"SEL$1" "LIU"@"SEL$1")]]></hint>
</outline_data></other_xml>I want output related to <info type="dynamic_sampling">2</info> :
column name dynamic_sampling
row value 2
on the second thought using dynamic_sampling value as a predicate would be great so:
select * from v$sql_plan
where
dynamic_sampling = 2
how to transform other_xml column to have such results ?
Regards
GregG
Edited by: GregG on Feb 8, 2013 1:14 PMAnd here is an xmltable version:
select p.sql_id, t.val
from v$sql_plan p
, xmltable('for $i in /other_xml/info
where $i/@type eq "dynamic_sampling"
return $i'
passing xmltype(p.other_xml)
columns attr varchar2(50) path '@type',
val varchar2(50) path '/') t
where p.other_xml is not null;This works for me in 11.2.0.3 but crashes in 11.1.0.7 with ORA-00600: internal error code, arguments: [qctVCO:csform], [0], [0], [0], [0], [112], [2], [224], [], [], [], [] -
Need help in extracting value from an xml tag.
Hi ALL,
Good Morning to all, i have problem in fetching a value from a xml tag. I have created a xml schema based on the schema i have created a xmltype table and inserted a value to the table. When i am trying to fetch a value from a particular tag i am unable to do so.. Kindly help me to solve this. Here by i am posting all the workings i have done...
I am using the following client:
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jan 31 11:44:59 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
////////////////////////////////// XML Schema ///////////////////////
begin
dbms_xmlschema.registerSchema(
'http://www.oradev.com/chipsxml.xsd',
'<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.oradev.com/chipsxml.xsd"
xmlns:samp="http://www.oradev.com/chipsxml.xsd"
version="1.0">
<element name="Field1">
<complexType>
<sequence>
<element name="UTI">
<complexType>
<sequence>
<element name = "U01" type = "string"/>
<element name = "U02" type = "string"/>
<element name = "U03" type = "string"/>
<element name = "U03a" type = "string"/>
<element name = "U03b" type = "string"/>
<element name = "U03c" type = "string"/>
<element name = "U04" type = "string"/>
<element name = "U05" type = "string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>',
TRUE, TRUE, FALSE, FALSE);
end;
////////////////////////// Table which has multiple Column //////////////////////////
CREATE TABLE chipsxmltable1 (
id number, XMLDATA XmlType)
XMLTYPE XMLDATA STORE AS OBJECT RELATIONAL
XMLSCHEMA "http://www.oradev.com/chipsxml.xsd"
ELEMENT "Field1";
///////////////////////////////// Insert Query in chipsxmltable //////////////////////////
INSERT INTO chipsxmltable VALUES(
xmltype.createxml('<?xml version="1.0"?>
<samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd" >
<UTI>
<U01>No</U01>
<U02>Y</U02>
<U03>Y</U03>
<U03a>Y</U03a>
<U03b>Y</U03b>
<U03c>Y</U03c>
<U04>Y</U04>
<U05>Y</U05>
</UTI>
</samp:Field1>'));
To show the data as a field with structure:
1. Query:
Select * from chipsxmltable1;
Output:
ID XMLDATA
1 <?xml version="1.0"?>
<samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd">
<UTI>
<U01>No</U01>
<U02>No</U02>
<U03>Y</U03>
<U03a>Y</U03a>
<U03b>Y</U03b>
<U03c>Y</U03c>
<U04>Y</U04>
<U05>Y</U05>
</UTI>
</samp:Field1>
2. Query: (Both the query displays the same Output)
SELECT X.xmldata.getClobVal() "XMLDATA" FROM chipsxmltable1 X;
select extract(XMLDATA, '/Field1').getstringval() "XMLDATA" from chipsxmltable1 x;
Output:
XMLDATA
<?xml version="1.0"?>
<samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd">
<UTI>
<U01>No</U01>
<U02>No</U02>
<U03>Y</U03>
<U03a>Y</U03a>
<U03b>Y</U03b>
<U03c>Y</U03c>
<U04>Y</U04>
<U05>Y</U05>
</UTI>
</samp:Field1>
To show the data as a single string without structure using "getstringval()":
3. Query
select extract(XMLDATA, '//text()').getstringval() "CHIPS - XML" from chipsxmltable1 x;
OUtput:
CHIPS - XML
NoNoYYYYYY
To show the data as a single string without structure using "getclobval()":
4.Query
select extract(XMLDATA, '//text()').getClobVal() "CHIPS - XML" from chipsxmltable1 x;
Output:
CHIPS - XML
NoNoYYYYYY
To show the data in a particular tag with/Without structure (Which is not working) using "EXTRACT" function:
6.Query:
select extract(XMLDATA, '/Field1/text()').getstringval() "XMLDATA" from chipsxmltable1 x;
select extract(XMLDATA, '/Field1/UTI').getstringval() "XMLDATA" from chipsxmltable1 x;
select extract(XMLDATA, '/Field1/UTI/U01').getstringval() "XMLDATA" from chipsxmltable1 x;
select extract(XMLDATA, '/Field1/UTI/U01/text()').getstringval() "XMLDATA" from chipsxmltable1 x;
Output:
CHIPS - XML
The above queries are not fetching the value.
To show the data in a particular tag with/Without structure (Which is not working) using "EXTRACTVALUE" function:
7. Query:
select extractValue(XMLDATA, '/Field1/UTI') "XMLDATA" from chipsxmltable1 x;
select extractValue(XMLDATA, '/Field1/UTI/U01') "XMLDATA" from chipsxmltable1 x;
Output:
X
The above queries are not fetching the value.
My question is:
How to fetch values from xml tag when the value are inserted through xml schema?
Apologies if the description is not clear. Kindly let me know if further details are needed. Many thanks for your help.
Very best regards,
Godwin Jebakumar C.V.Hi,
You need to declare the namespace of each element used in the XPath expression, like this :
SQL> select extractvalue( XMLDATA
2 , '/samp:Field1/UTI/U01'
3 , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"' ) "XMLDATA"
4 from chipsxmltable1 x
5 ;
XMLDATA
No
SQL> select extract( XMLDATA
2 , '/samp:Field1/UTI'
3 , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"'
4 ).getstringval() "XMLDATA"
5 from chipsxmltable1 x
6 ;
XMLDATA
<UTI>
<U01>No</U01>
<U02>Y</U02>
<U03>Y</U03>
<U03a>Y</U03a>
<U03b>Y</U03b>
<U03c>Y</U03c>
<U04>Y</U04>
<U05>Y</U05>
</UTI>
Please see EXTRACT and EXTRACTVALUE documentation :
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions051.htm#i1006712
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions052.htm#SQLRF06173
BTW, "XMLDATA" is a pseudo-column used by Oracle. I don't know if it'll ever cause any conflict but maybe you should rename your column.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns010.htm#SQLRF00256
Regards. -
How to Pass values from XML to JSP??? Urgent Please Help me
Hi guys,
I am new to XML, I want to pass values from XML to JSP. I have a xml file with attributes, I should send this values to a JSP file. How is it??? Please Help guys.... its very urgent. Please send me how to do it with an example or atleast any urls related that....
Looking for ur favourable reply.
Thanks in advance,
Sridharin a servlet :
parse your xml file (see how at the end of the post) and
put the values you want in the request attributes
request.setAttribute("value1", value1);
...redirect to the jsp
in the JSP:
get the wanted attributes:
String value1=(String)request.getAttribute("value1");To learn how to parse a xml file, pay a look at this page, it explains how to read the XML document to build an object representation, and then how to navigate through this object to get the data
http://labe.felk.cvut.cz/~xfaigl/mep/xml/java-xml.htm -
For some business requirements, users want to extract values from a multi-value enabled lookup column
and add items to another list based on each separate value. In contrast, others want to find duplicate values in the list and merge associated values to a multi-value enabled column and then
add items to another list based on the merged value. All of these can be achieved using SharePoint Designer 2013 Workflow.
How to extract values from a multi-value enabled lookup column and add items to another list based
on each separate value using SharePoint Designer 2013.
Important actions: Loop Shape; Utility Actions
Three scenarios
Things to note
Steps to create Workflow
How to merge values to a multi-value enabled column and add item to another list based on the
merged value using SharePoint Designer 2013.
Important actions: Call HTTP Web Service; Build Dictionary
Things to note
Steps to create Workflow
How to
extract values from a multi-value enabled lookup column and
add items to another list based on each separate value using SharePoint Designer 2013.
For example, they have three lists as below. They want to
extract values from the Destinations column
in Lookup2 and add items to Lookup3 based on each country and set Title to current item: ID.
Lookup1:
Title (Single line of text)
Lookup2:
Title (Single line of text), Destinations (Lookup; Get information from: Lookup1 in Title column).\
Lookup3:
Title (Single line of text), Country (Single line of text).
Important action
1. Loop Shape: SharePoint Designer 2013 support two types of loops: loop n times and loop with condition.
Loops must also conform to the following rules:
Loops must be within a stage, and stages cannot be within a loop.
Steps may be within a loop.
Loops may have only one entry and one exit point.
2. Utility Actions: It contains many actions, such as ‘Extract Substring from Index of String’ and ‘Find substring in String’.
Three scenarios
We need to loop through the string returned from the look up column and look for commas. There are three
scenarios:
1. No comma but string is non-empty so there is only one country.
2. At least one comma so there is at least two or more countries to loop.
3. In the loop we have consumed all the commas so we have found the last country.
Things to note
There are two things to note:
1. "Find string in string (output to Variable:index)" will return -1 if doesn't find
the searched for string.
2. In the opening statement "Set Variable: Countries to Current Item:Destinations" set the return
field as "Lookup Values, Comma Delimited".
Steps to create Workflow
Create a custom list named Lookup1.
Create a custom list named Lookup2, add column: Destinations (Lookup; Get information from: Lookup1 in Title column).
Create a custom list named Lookup3, add column: Country (Single line of text).
Create a workflow associated to Lookup2.
Add conditions and actions:
Start the workflow automatically when an item is created.
Add item to Lookup2, then workflow will be started automatically and create multiple items to lookup3.
See the below in workflow History List:
How to merge values to a multi-value enabled column and add item to another list based on the
merged value using SharePoint Designer 2013
For example, they have three lists as below. They want to find duplicate values in the Title column in
Lookup3 and merge country column to a multi-value enabled column and then add item to lookup2 and set the Title to Current Item: Title.
Lookup1:
Title (Single line of text)
Lookup3:
Title (Single line of text), Country (Single line of text).
Lookup2:
Title (Single line of text), Test (Single line of text).
Important actions
"Call HTTP Web Service"
action: In SharePoint 2013 workflows, we can call a web service using a new action introduced in SharePoint 2013 named Call HTTP Web Service. This action
is flexible and allows you to make simple calls to a web service easily, or, if needed, you can create more complex calls using HTTP verbs as well as allowing you to add HTTP headers.
“Build Dictionary"
action:
The Dictionary variable type is a new variable type in the SharePoint 2013 Workflow.
The following are the three actions specifically designed for the Dictionary variable type: Build Dictionary, Count Items in a Dictionary and Get an Item from a Dictionary.
The "Call HTTP Web Service" workflow action would be useless without the new "Dictionary" workflow action.
Things to note
The
HTTP URI is set to https://sitename/_api/web/lists/GetByTitle('listname')/items?$orderby=Id%20desc and the HTTP method is set to “GET”. Then the list will be sort by Id in descending order.
Use Get
d/results(0)/Id form
Variable: ResponseContent (Output to
Variable: maxid) to get the Max ID.
Use Set
Variable: minid to Current List:ID to get the Min ID.
Use Copy from
Variable: destianation , starting at
1 (Output to
Variable: destianation) to remove the space.
Steps to create Workflow
Create a custom list named Lookup1.
Create a custom list named Lookup2, add column: Test (Single line of text).
Create a custom list named Lookup3, add column: Country (Single line of text).
Create a workflow associated to Lookup3.
Add a new "Build Dictionary" action
to define the http request header:
Add a Call HTTP Web Serviceaction, click on
this and paste your http request.
To associate the
RequestHeader variable, select the Call action property,
set the
RequestHeaders property to
RequestHeader:
In the Call action, click on
response and associate the response to a new
variable: ResponseContent (of type Dictionary).
After the Call action add Get item from Dictionary action to get the Max ID.
Add Set Workflow Variable action to get the Min ID.
Add Loop Shape (Loop with Condition) to get all the duplicate titles and integrate them to a string.
Create item in Lookup2.
The final Stage should look like this:
Start the workflow automatically when an item is created.
Add item to Lookup3, then workflow will be started automatically and create item to lookup2.
See the below in workflow History List:
References
SharePoint Designer 2013 - Extracting values from a multi-value enabled lookup column into a dictionary as separate items:
http://social.technet.microsoft.com/Forums/en-US/97d34468-1b53-4741-88b0-958472f8ca9a/sharepoint-designer-2013-extracting-values-from-a-multivalue-enabled-lookup-column-into-a
Workflow actions quick reference (SharePoint 2013 Workflow platform):
http://msdn.microsoft.com/en-us/library/jj164026.aspx
Understanding Dictionary actions in SharePoint Designer 2013:
http://msdn.microsoft.com/en-us/library/office/jj554504.aspx
Working with Web Services in SharePoint 2013 Workflows using SharePoint Designer 2013:
http://msdn.microsoft.com/en-us/library/office/dn567558.aspx
Calling the SharePoint 2013 Rest API from a SharePoint Designer Workflow:
http://sergeluca.wordpress.com/2013/04/09/calling-the-sharepoint-2013-rest-api-from-a-sharepoint-designer-workflow/GREAT info, but it may be helpful to note that when replacing a portion of the variable "Countries" with a whitespace character, you may cause the workflow to fail in a few specific cases (certain lookup fields will not accept this and will automatically
cancel). I only found this out when recreating your workflow on a similar, but much more complex list set.
To resolve this issue, I used another utility action (Extract Substring from Index of List) to clear out the whitespace. I configured it as "Copy from
Variable: Countries, starting at
1 (Output to Variable: Countries), which takes care of this issue in those few cases.
Otherwise, WOW! AWESOME JOB! Thanks! :) -
How to extract data from xml and insert into Oracle table
Hi,
I have a large xml file. which will have hundreds of the following transaction tags having column names and there values.
There is a table one of the schema with coulums "actualCostRate","billRate"....etc.
I need to extract the values of these columns and insert into the table
<Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuUK" chargeCode="LCOCD1" externalID="L-RESCODE_UK1-PROJ_UK_CNT_GBP-37289-8" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-12" transactionType="L" units="11" taskID="5017601" inputTypeCode="SALES" groupId="123" voucherNumber="ABCVDD" transactionClass="ABCD"/>
<Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuEU" chargeCode="LCOCD1" externalID="L-RESCODE_US1-PROJ_EU_STD2-37291-4" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-04" transactionType="L" units="4" taskID="5017601" inputTypeCode="SALES" groupId="124" voucherNumber="EEE222" transactionClass="DEFG"/>Re: Insert from XML to relational table
http://www.google.ae/search?hl=ar&q=extract+data+from+xml+and+insert+into+Oracle+table+&btnG=%D8%A8%D8%AD%D8%AB+Google&meta= -
Extracting data from xml spreadsheet for JSP
Hi,
Currently i am developing a web application where user can upload a MS excel file, then the application will extract data needed and store into database. But facing problems where those excel files may content massive images that make the file size too large to be upload on to the web. Now i try to export those excel files into xml spreadsheet, to get only text data. Need helps on how to extract data from xml spreadsheet. Which API needed?
ThanksWithout getting into too much detail, a DTD defines the elements that can appear in an xml file, the order they can appear in, which elements can be nested within which other elements, what each element can contain, etc, etc. In short, a DTD defines the structure of the xml file and Microsoft defined a DTD for the xml files that are output by Excel.
This is not taken from an xml file produced by Excel but DTDs look a llittle like this very basic example.
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>If you open the one produced for you by Excel in Wordpad or another simple text editor, you may see something like this in there.
However, if you are going to use a parser to access the file for you do not worry about getting to grips with DTDs for a short, simple project.
Maybe you are looking for
-
ServerSocket bind, bug or windows feature
I wanted to check if a TCP socket was already bound before attempting to use it. I had my own ideas, but looked for other ideas as well. While testing these other ideas I stumbled on the following issue. On Windows XP(SP3), its the work platform of c
-
How to insert a standard selection screen on moduled program?
Hi All, Selection screen can be easily done in classic report by just simply invoking the event "SELECTION-SCREEN" SELECTION-SCREEN BEGIN OF ... SELECT-OPTIONS ... PARAMETERS ... In the case of moduled program, there will be a PBO and PAI, I have a r
-
Withholding tax form BIR 2307 ---- very urgent
hi frnds i want to generate withholding tax report in the BIR 2307 form but it just dums up the data but do not distribute to the related filed. BIR 2307 for is SAP standard format for Phillipines withholdign tax reporting. Can you please tell me the
-
Hi All, I am having trouble in dealing with 3 select fields simultaneously . I have three select fields say A,B,C. Based on the selection in select field 'A' a corresponding new list will appear in select field 'B' and then based on seletion in selec
-
Photoshop CS6 3D Workaround for Windows
After much searching for a solition to the problem of Photoshop not displaying, well - anything - under Windows (I did this with Windows 7 32bit, Photoshop CS6 Extended 13.0.1.1) I stumbled upon a workaround that will solve the issue at least until A