How to fill infopath form programmatically using c#?

Hi,
      I have a form library in my share point site. Programmatically i need to fill some fields. Can i do that? If any one know please provide me some sample code. First i need to retrieve the infopath document and then i need to fill the fields. Please help me.
Thanks in advance.

I just made tow rough functions, just add below functions and use it.
// Get the value
public string getNodeValue(string path)
            XPathNavigator root;
            string temp;
            root = this.MainDataSource.CreateNavigator();
            temp = root.SelectSingleNode(path, this.NamespaceManager).Value;
            return temp;
// Set the value
public void setNodeValue(string path, string value)
            XPathNavigator root, infopathNode;
            root = this.MainDataSource.CreateNavigator();
            infopathNode = null;
            infopathNode = root.SelectSingleNode(path, this.NamespaceManager);
            infopathNode.SetValue(value);
where path is the xpath of your node. It looks like "/my:myFields/my:theValue"
where value is the value you'd like to fill
Oh, I can change my signature from My Settings page!!

Similar Messages

  • How to Close InfoPath Form After Submission When Two Buttons Exist?

    I have an browser-enabled InfoPath 2010 form that has two views and a submit button on each view. The form would correctly submit and close the form using one button on the form until the second button was added. After adding the submit button on a second
    view, the second button submitted/closed but the behavior on the first view changed so that the form no longer closes after submission. I’ve researched this and have not yet found a solution to allow closing the form after submission for one of the buttons.
    Things I’ve tried:
     - I’ve attempted creating multiple submit data connections for the different buttons
     - Specifying different Submit Options
     - Try closing the form with the code
     - Add another button to the non-closing view
     - Add duplicate Rule actions to "Close this form: No Prompt"
    Settings:
    Button rules:
     - Submit using data connection: SharePoint Library Submit
     - Close this form: No Prompt
    Button Properties:
     - Action > Rules and Custom Code
    The form Submit Options:
     - Send form to a single destination (a form library)
     - Choose a data connection for submit (SharePoint library submit)
     - Advanced > After Submit: Close the form
    Advanced form options:
     - Filler Features: all items unchecked (not allowing Save, etc.)
     - E-Mail Attachments: uncheck Enable InfoPath e-mail form functionality for this form template
    Resources:
    When considering programmatically submitting and closing the form, I understand from this article that the Rules run before code and I can’t close the InfoPath form programmatically by writing code behind a button that has a rule set on it:
    http://www.bizsupportonline.net/blog/2009/01/how-to-programmatically-run-code-close-infopath-web-form/
    Discussion of creating a custom Save and Submit buttons for InfoPath browser forms:
    http://markhaverty.com/sharepoint/custom-save-and-submit-buttons-for-infopath-browser-forms/

    what if you need to switch views? 
    I have the same problem in a similar situation.  I created a test button to narrow down the cause.  the button submits data & closes the form fine.  however when I add a rule to switch views before the submit & close rule, it
    breaks.  Submit still works but it no longer closes the form.  If I disable the switch-view rule, then it closes fine. 
    I tried added another rule to switch back to the main view but that didn't help. 
    switching views is an integral part of the workflow b/c I want to email the alternate view upon approval & then close the form.  So removing that rule is not a good answer unfortunately. 

  • I HOW I FILL PDF FORM WITH HEBROW ON CHROME ?

    I HOW I FILL PDF FORM WITH HEBROW ON CHROME ?

    Chrome uses its own (incompatible) PDF viewer.
    Download the PDF to your local disk, then fill it from there with Adobe Reader.  Or use a browser that uses the Adobe PDF plugin.

  • How to close infopath form through code?

    Hi All,
    How to close infopath form through code, thanks in advance!

    Hi Sam,
    Please check if the articles below can be help:
    http://www.bizsupportonline.net/browserforms/programmatically-submit-infopath-form-sharepoint-send-email-close-form.htm
    http://www.bizsupportonline.net/blog/2009/01/how-to-programmatically-run-code-close-infopath-web-form/
    Regards,
    Rebecca Tu
    TechNet Community Support

  • How to fill TAX Form W-8IMY for Individual Non-USA developer?

    Hello,
    Firstly: I couldn't find a simple remove-formatting option in the wsiwyg editor of this new post entry box, so the copy paste resulted in a text like this. 
    Now my question: I had never filled up this form TAX Form W-8IMY before and searching internet shows only how to fill up form Form
    W-8 BEN for windowsphone store but not the form W-8IMY which shows up in my account. It has some fields which I don't understand like  Type
    of entity and rest from part 3 onwards.  I am an Individual Non-USA based developer.
    If you have any sample tutorial, blog, etc that can tell me how to fill up this tax form then it will be of great help.
    Thanks,
    AJ

    Hello Adaj2014,
    We recently made some changes to the tax form, please go to
    http://login.live.com and sign out of all services then clear your browser cache.
    If this does not resolve the issue please
    contact developer support.
    -Eric
    Windows and Windows Phone Dev Center Support
    Send us your feedback about the Windows Platform

  • How to save infopath form in XML file

    How to save InfoPath form in XML file.
    I want every new record in InfoPath form save in XML file and also retrieve these records from XML like databases

    Hi,
    Based on your description, my understanding is that you want to save InfoPath form in XML file.
    I have done a test in my SharePoint, Do the following steps:
    Create an form library and publish an InfoPath form into it, Then when we create new document into the form library, it is by default that InfoPath form is saved in XML file.
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

  • How  to do standard form modification using NACE

    hi gurus
    can any one suggest me
    how to modify standard form layout using NAce
    please send any examples if possible.
    thank you
    regards
    kals.

    Hi,
    goto NACE
    there depending on the functionality  select the  application.
    for Sales u have Application V1
    for purchase order u have application EF
    select one application and click on output types pushbutton
    for an example select EF application and click on output types
    now u get different output types select NEU new PO printout
    and double click on the processing routine folder on the left hand side of the screen
    Now u get the different processing routines .
    in that u have print output there u can see form routine and FORM .
    HERE U CAN GIVE UR OWN FORM WHICH IS CREATED IN SE71 BY DELETING THE STANDARD FORM.
    reward if helpful
    raam

  • How to have Infopath form use Sharepoint Domain credentials

    I have built a for in infopath which is published to a library on Sharepoint 2013. This form is filled out by certain users and when its completed it gets moved into a subfolder. We then provide a link to a client who has a domain account with restricted
    access to just this folder of sharepoint. They can view this form and any others we put in this folder.
    The form has 2 views. The first is the view our staff sees when filling it out. There are some hidden sections in there for us that the client does not need to see. So there is a second view which is read only and I have taken away the option for them to
    switch views so they can't go back to our internal view.
    What I would like to happen is that the form can somehow detect by the domain login info from sharepoint, what user is opening the form and switch views based on that. What I can't figure out how to do it to have the form pull domain credentials from the
    sharepoint site and use those a a variable when opening the form to set the view.
    I believe I am on the right path what trying to setup a data connection but I am just missing something. I found this great guide http://www.pointgowin.com/seethepoint/Lists/Posts/Post.aspx?ID=55 but now when I open the form I get a warning stating "You
    do not have permissions to access a SharePoint list that contains data required for this form to function correctly." Also I still can't seem to pull the username.
    Can someone help me out? Point me in the right direction? Thanks.

    Hi,
    According to your post, my understanding is that you wanted to have Infopath form use Sharepoint Domain credentials.
    When you use Claims-based authentication, your user name is prefaced by “0#.w|”.  So for example, if your user name is SuesDomain\jdoe then your Claims-based user token will be, without
    the quotes:     “0#.w|SuesDomain\jdoe”
    InfoPath can’t handle that, or more specifically, the UserProfile.asmx method GetUserProfileByName method can’t handle that.  InfoPath tries to pass in your Claims-based user token instead
    of your domain\User Name.
    You have an authentication problem where the currently logged in user is not allowed to hit the web service, so you get an Access Denied 401 authentication error
    To resolve the issue, you can refer to the great blog:
    SharePoint 2013, InfoPath and Claims – GetUserProfileByName
    More information:
    InfoPath over Claims Authentication (SharePoint 2010 & 2013)
    SharePoint 2013 Business Connectivity Services Search and Profile PageMetroStar Systems Blog
    Thanks,
    Linda Li
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Linda Li
    TechNet Community Support

  • How to create Infopath form that auto populate data from one list to be fill by another user?

    hi.  I would like to ask, how to create form that fill by User A, for example, and then the User A assigned task to User B to complete the form. Next, the form will be approved by approver. May I know how to do
    that? and if possible, I do not want to use any programming code.
    Azuaniza Ariffin

    Hi,
    If your SharePoint environment supports InfoPath Forms, then you can customize the form and add rules to make the list items as read only when user A submits the form.
    you can then write a form load event to check the logged in user using username() function. This logic can be implemented in variety of ways, like setting a flag when User A submits the form, or storing user A username in a form variable etc., else comparing
    User A and User B values within form Load event.
    Another way of doing this is using Views or grouping all of the User A fields within a section etc.,
    The above would take care of Form logic, and for the workflow, you can use SharePoint designer to create a custom workflow, where it will run on onItemCreate and onItemChange events.
    The logic for workflow would be if the form Submitted for the first time, the workflow will start and send an email to User B, and when User B submits the Data then onItemChange change event will start the workflow to send an email to approver to approve
    the data.
    here are some links for your reference -
    http://office.microsoft.com/en-us/infopath-help/add-formulas-and-functions-in-infopath-2010-HA101821255.aspx
    http://office.microsoft.com/en-us/videos/video-create-an-approval-workflow-in-sharepoint-designer-2010-VA101897477.aspx
    http://blogs.technet.com/b/meacoex/archive/2010/11/01/get-manager-approval-in-sharepoint-designer-2010-step-by-step.aspx
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • Customizing infopath form without using infopath designer in SharePoint 2013

    hi friends
    i need to depoly infopath from in client environment. this form fetch data from some lists. 
    they dont have infopath designer in their environment how can i customize my infopath form to link with those list without using infopath designer is there any way to do it.

    You cannot edit Infopath without using Designer.

  • How to fill PDF form programatically

    Hi everyone,
    We are automating a web application using QuickTest Pro. In some scenarios we need to fill a PDF form and click 'submit' button. Is there any way we can use Acrobat SDK to automate this process? I really appreciate your help.
    Thanks and Regards,
    Kumar.

    Why Yes!  There are several ways to pre-fill a PDF.  Which technique depends on where the data comes from and where the PDF is going.
    For example, a PDF can be filled in Acrobat using an Acrobat data file such as FDF, XFDF, or XDP if it's a LiveCycle form.  This can be done manually through the menu items or automated with JavaScript, or with a batch process.  And there are lots of other variations on how data files can be used. Of this methodology assumes that the data file already exists.  The data file can be manually created by exporting data from Acrobat or automatically by some external custom program.
    Acrobat JavaScript can also used to access Excel and database files:
    http://www.pdfscripting.com/public/department48.cfm
    and LiveCycle forms can be connected directly to a DB.
    http://www.pdfscripting.com/public/34.cfm#XFADBForms
    Depending on the kind of data, JavaScript can be used to directly fill in forms.  This method is suiltable for handling a small number of fields, such as customer contact data.
    On the server side there is a whole host of third party tools for filling forms and of course Adobe has tools as well.  In fact PDF form data handling is built into ColdFusion.
    The Acrobat plug-in SDK has a Forms model for just this purpose and there is an ActiveX interface to Acrobat that can access individual form fields.
    Thom Parker
    The source for PDF Scripting Info
    pdfscripting.com
    The Acrobat JavaScript Reference, Use it Early and Often
    http://www.adobe.com/devnet/acrobat/javascript.html
    Then most important JavaScript Development tool in Acrobat
    The Console Window (Video tutorial)
    The Console Window(article)

  • How to enable infopath form service in sharepoint

    Hi,
    I am using Infopath designer 2013.
    When i am opening Sharepoint List, after mentioning its url its giving me following error:
    How can i enable infopath form service.
    please help to solve the issue.
    Thanks in advance!
    Regards
    rajni

    Hello,
    It seems enterprise feature is not activated to your site, not CA. Please go to your site Site Settings/Site Collection Administration/Features and activate the SharePoint Server Enterprise Site Collection features.
    See this thread for your ref:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/5225cb4a-f981-49b5-ac1c-e3c832bcf79d/this-feature-requires-sharepoint-server-2010-or-greater-with-infopath-forms-services-enabled?forum=sharepointgeneralprevious
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to publish infopath forms to open new and old form templates in sharepoint2007

    Hi All,
    My requirement is , we are having a form library with the Infopath form templated(V1) published.
    Then we have added about 300 items using template(v1) into the sharepoint library.
     Then client asked for the changes in form and we deveploped infopath template (V2) and published, able to create the items using the new template(v2).
    But ,the issue is when we open item from the 300 items which are created with template(v1), its is opening using template(v2) and we are loosing the functionality of template(v1).
    Can i know ,how to publish the form template to use both template versions and it should open the form with  wahatever the  template it used for creation.
    Thanks in Advance.
    Anil Kumar K

    Hi,
    If you want the InfoPath forms for displaying the items in the list, then I recommend to click Customize Form button in the ribbon of the list to edit the form in InfoPath and then publish the form back to SharePoint.
    After that, you will see there are three new forms(displayifs.aspx, editifs.aspx, newifs.aspx) when you view the list in SharePoint Designer.
    Then you can create the custom action to navigate to the custom InfoPath form:
    Thanks,
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Victoria Xia
    TechNet Community Support

  • Creating Infopath forms programmatically - unable to update promoted columns in the library

    I referred to the following article and was able to create the forms successfully.
    http://www.codeproject.com/Articles/33228/Programmatically-create-a-browser-enabled-InfoPath
    But, I noticed that the generated Xml looks a bit different than if I'm creating the document through Sharepoint directly,
    for example, a snippet of the generated Xml (through Sharepoint) looks like:
    <my:Employee>
              <my:LastName>Test</my:LastName>
              <my:GivenName>Test</my:GivenName>
              <my:EmployeeNumber>1</my:EmployeeNumber>
    </my:Employee>
    but it looks like the following when I create the document from my C# code:
    <Employee>
          <LastName>Test</LastName>
          <GivenName>Test</GivenName>
          <EmployeeNumber>1</EmployeeNumber>
    </Employee>
    The issue that I'm noticing is that if I chose to publish some of columns (when I publish the form to the sharepoint site) then
    the columns will not show the values (I'm guessing that is due to the missing "my" before the fields).
    Is there a way to work-around that? or am I doing something incorrect on my side?
    Thank you,

    Here is a complete method for creating a new infopath form and updating some columns of the new form using sharepoint client object model:
            public string AddNewForm(string WebUrl, string NewTitle)
                string strMsg = "";
                if (string.IsNullOrEmpty(WebUrl))
                    return "Empty URL!";
                try
                    // Starting with ClientContext, the constructor requires a URL to the server running SharePoint.
                    using (ClientContext client = new ClientContext(WebUrl))
                        //client.Credentials = System.Net.CredentialCache.DefaultCredentials;
                        // Assume that the web site has a library named "FormLibrary".
                        var formLib = client.Web.Lists.GetByTitle("FormLibrary");
                        client.Load(formLib.RootFolder);
                        client.ExecuteQuery();
                        // FormTemplate path, The path should be on the local machine/server !
                        string fileName = @"D:\Projects\FormTemplate.xml";
                        var fileUrl = "";
                        //Craete FormTemplate and save in the library.
                        using (var fs = new FileStream(fileName, FileMode.Open))
                            var fi = new FileInfo("newForm.xml");
                            fileUrl = String.Format("{0}/{1}", formLib.RootFolder.ServerRelativeUrl, fi.Name);
                            Microsoft.SharePoint.Client.File.SaveBinaryDirect(client, fileUrl, fs, true);
                            client.ExecuteQuery();
                        // Now we are going to update new form fields.
                        // Get library columns collection.
                        var libFields = formLib.Fields;
                        client.Load(libFields);
                        client.ExecuteQuery();
                        Microsoft.SharePoint.Client.File newFile = client.Web.GetFileByServerRelativeUrl(fileUrl);
                        ListItem item = newFile.ListItemAllFields;
                        // Here the index of Title column is 9, you may use this form to update any column (even promoted fields).
                        // To find the index of interested column you should inspect libFields at debug mode, look in the libFields.Fields collection to find the index!
                        item[libFields[9].StaticName] = NewTitle ;
                        item.Update();
                        client.ExecuteQuery();
                catch (Exception ex)
                    strMsg = ex.Message;
                return strMsg;

  • How to find Infopath form Libaray Attachment field Saving location?

    Hi All,
     I have Infopath customized form Lib and have 5 attachement fields in it. How can i find location where the attachment are getting stored?
    Velu K

    Hi,
    According to your description, you want to know that
    where the InfoPath form attachments stored.
    InfoPath attachments are stored as pieces of text called base64 encoded strings within the InfoPath form itself.
    Here is a link, you can use as a reference:
    http://www.bizsupportonline.net/blog/2010/04/top-10-questions-infopath-file-attachments/
    Best Regards,
    Lisa Chen
    Forum Support
    Please remember to mark the replies as answers if they help and unmark
    them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]

Maybe you are looking for

  • Which MacBook Pro is the right one for me?

    Hello At the moment I'm using a MacBook Pro 15" early 2011, 2.0 i7, 8GB Ram, AMD 6490M and an SSD. The most used applications are ArchiCAD, Adobe Suite, Rhinoceros, Cinema 4D. Half of the time the MacBook Pro is connected to a Thunderbold Display. My

  • Can't click drag within widgets in Dashboard

    Not sure what caused it, but suddenly I can't click-drag WITHIN a dashboard widget. For example, if I click and hold the pulldown menu in the Dictionary to change to thesaurus, the pull-down menu won't activate. It only activates if I click and relea

  • Expander only works form 2 feet away!!! HELP Please, anyone!!

    Hello, After much fiddling and manual labor, I have finally seem to have a link with my range expander.  The problem:  I can only access the administrative tools and ping when the darn thing is about 2 feet away.  Obviously, this defeats the purpose

  • How do you stop the Radio on Apple TV 3rd gen?

    Ok, I can't believe I can't figure this out... I started listening to a radio station using the Radio app on the Apple TV and now I can't figure out how to shut it down.  I can press play/pause to pause it, but I can't figure out how to stop it entir

  • Steps Required for Deleting Un - Used Company codes

    Hi My client Requirement is Un - Used Company codes need to remove from Production Environment. What is the Steps Require for Remove Company codes. Regards, TML