Click here to Skip to main content
15,896,606 members
Articles / Desktop Programming / Win32

InfoPath 2007 Helper for MOSS 2007

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
6 Feb 2009GPL31 min read 28K   151   7  
This article is about how to get or set values of an InfoPath form.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Serialization;
using System.IO;
using Microsoft.SharePoint;

namespace DefaultNamespace
{
    class Program
    {

        static void Main(string[] args)
        {
            string sStatus = string.Empty;
            string sFileSource = string.Empty;
            sFileSource = "C:\\ProyectosVisualStudio2008\\ConsoleApplication1\\ConsoleApplication1\\InfoPath\\infopath.xml";

            // Obtenemos el valor del campo Status mediante XML
            InfoPathHelper.FileName = sFileSource;
            sStatus = InfoPathHelper.Value("Status");

            // Guardamos el valor del campo Status mediante XML
            InfoPathHelper.SetValue("Status", "En Progreso ...");

            //// Obtenemos los campos del formulario InfoPath deserializado
            misCampos InfoPathForm = (misCampos)InfoPathHelper.DeserializeFile(sFileSource, typeof(misCampos));
            sStatus = InfoPathForm.Status;


            // Para pobarlo desde un sitio SharePoint
            SPSite site = new SPSite("http://desa.portal.latam.com");
            SPWeb web = site.AllWebs["Sistemas/Incidentes"];
            SPList list = web.Lists["test2222"];
            SPListItem item = list.Items[0];

            InfoPathHelper.SPFileName = item;
            sStatus = InfoPathHelper.Value("Status");
            InfoPathHelper.SetValue("Status", "En Progreso ...");

            misCampos InfoPathFormMoss = (misCampos)InfoPathHelper.DeserializeFile(item.File, typeof(misCampos));
            sStatus = InfoPathFormMoss.Status;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Systems Engineer San Antonio International - Pride
Argentina Argentina
Desde chico mi fasinacion hacia las computadoras marcaron mi camino profesional que iba a recorrer en los proximos dias de mis vida. Ingeniero en Sistemas, recibido en la UADE en el 2005, mi abocacion hacia la programacion en tecnologias de Microsoft hicieron hoy en dia desarrollarme como Arquitecto o Lider Tecnico en proyectos con tecnologias .Net. No solo la programacion es uno de mis pasiones, sino tambien todo lo referente a Infraestructura con productos de Microsoft. Actualmente estoy desenvolviendome como SharePoint Specialisst en una empresa petrolera lideando con sistemas montados sobre dicha tecnologia. Casado con mi hermosa mujer Cecilia quien es el motor que empuja mis ambiciones y ayuda a mejorarme dia a dia.

Comments and Discussions