Editing Infopath Form Programatically

T

Txarlie

Hello everybody:

This is my infoPath form.

<my:misCampos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/
dataFormSolution" xmlns:s0="http://microsoft.com/webservices/
SharePointPortalServer/UserProfileService" xmlns:s1="http://
microsoft.com/wsdl/types/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/
mime/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://
schemas.xmlsoap.org/wsdl/http/" xmlns:ns1="http://schemas.xmlsoap.org/
wsdl/" xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata" xmlns:my="http://
schemas.microsoft.com/office/infopath/2003/myXSD/2008-04-14T15:26:14"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"
xml:lang="es-ES">
<my:idForm></my:idForm>
<my:fecModificacion></my:fecModificacion>
<my:user></my:user>
<my:descriptors></my:descriptors>
<my:title></my:title>
<my:RelatedLinksGroup>
<my:RelatedLinks>
<my:Link>http://www.link.net</my:Link>
<my:LinkDescr>(...loturaren azalpena)</my:LinkDescr>
</my:RelatedLinks>
</my:RelatedLinksGroup>
</my:misCampos>

I'm trying to edit it programatically because I need to migrate all my
old data to my Sharepoint lists (developed as InfoPath items). And I
do it. I edit my IP forms nodes and write the values I need.

But I'm having a problem. I need to add more links to my forms. I need
to add from 0 to N links, depending on the original data files. If
there is only a link, I've no problem, because I edit the existing
field (my:link), and everything goes ok.

But, when having 2 or more links, I don't know how I can insert more
links to my form. I'm trying to work with these nodes as XML nodes,
but I always get the same error when working like that: I cannot
insert colon :)) in the XMLPathNavigator. This is because I cannot
insert "my:" in the name of my nodes.

I'm using a code similar to the following:

//XmlNode root = doc.DocumentElement;
XmlNode root = xd.SelectSingleNode("my:misCampos/
my:grupoEnlacesRelacionados", nsmgr);
//Create a new node.
XmlElement elemEnlacesRelacionados =
xd.CreateElement("my:my:enlacesRelacionados");
elemEnlacesRelacionados.InnerText = "http://www.enlace.net";
//Add the node to the document.
root.InsertAfter(elemEnlacesRelacionados, root.FirstChild);

So, I need to use something else, but I don't know what. Can anybody
help me? Or redirect me to any web/blog where I can read about this?
I'm not able to find information about this...

Thanks in advance!!!
 
S

Swathi (GGK Tech)

Hi,
To add more values to a node then that node should be repeating. So change
your ‘enlacesRelacionados’ node to a repeating node. So that you can enter
the number of nodes(links) as you want. Set that node to repeating the by
following the below steps.
1.Open the form in design mode.
2.Go to data source.
3.Right click on enlacesRelacionados node.
4.Click properties.
5.Check repeating check box.
After doing all this publish the form to SharePoint.
Hope this will help to you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top