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;

Similar Messages

  • Unable to update this object because the following attributes associated with this object have values that may already be associated with another object in your local directory services

    Getting this error from DirSync
    Unable to update this object because the following attributes associated with this object have values that may already be associated with another object in your local directory services: [UserPrincipalName
    [email protected];].  Correct or remove the duplicate values in your local directory.  Please refer to
    http://support.microsoft.com/kb/2647098 for more information on identifying objects with duplicate attribute values.
    Quick eyeball and couldn't see the cause in the user account so used the script here:
    http://gallery.technet.microsoft.com/office/Fix-Duplicate-User-d92215ef
    And got these outputs:
    PS C:\Windows\System32\WindowsPowerShell\v1.0> Export-OSCADUserPrincipalName -UserPrincipalName "[email protected]" -Path .\outputs.csv
    WARNING: Cannot find objects with specified duplicate user principal name
    [email protected]
    Found 0 user(s) with duplicate user principal name.
    Where to from here?
    Richard P

    Hi,
    Did you talk about the Microsoft Azure Active Directory Sync tool ?
    If yes, this issue occurs if one or more of the following conditions are true:
    An object in the on-premises Active Directory has an SMTP address that's the same as the SMTP address of the object that's reporting the problem.
    An object in the on-premises Active Directory has a mail attribute that's identical to the object that's reporting the problem.
    An object already exists in your organizational account and has the same SMTP address or mail attribute as the object in the on-premises Active Directory
    More detail information, please refer to:
    http://support.microsoft.com/kb/2520976/en-us
    [Troubleshooting] Unable to update this object because the following attributes associated with this object
    http://blogs.technet.com/b/aadsyncsupport/archive/2014/05/20/troubleshooting-unable-to-update-this-object-because-the-following-attributes-associated-with-this-object.aspx
    Regards.
    Vivian Wang

  • I was unable to update my itunes to the latest version.

    I was unable to update my itunes to the latest version.  I tried to uninstall and then reinstall but had this warning: the older version of itunes cannot be removed. Contact your technical support group

    the older version of itunes cannot be removed. Contact your technical support group
    Download the Windows Installer CleanUp utility from the following page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    To install the utility, doubleclick the msicuu2.exe file you downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
    Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • When I update itunes it deletes the library file, and when I restore that file from the previous libraries or my backup, itunes will run but tell me "the iTunes library file cannot be saved. A folder was specified instead of a file" How do I fix this?

    When I update itunes it deletes the library file, and when I restore that file from the previous libraries or my backup, itunes will run but tell me "the iTunes library file cannot be saved. A folder was specified instead of a file" How do I fix this?

    Hi there Br0x,
    You may want to try rebuilding the iTunes library as an initial troubleshooting step. Take a look at the article below for more information.
    iTunes: How to re-create your iTunes library and playlists
    http://support.apple.com/kb/ht1451
    -Griff W.

  • Navigation to update a column in the table jtf.jtf_rs_resource_extns

    Hi All,
    I'm using oracle 11.5.10
    Can somebody tell me the frontend form which is related to the table jtf.jtf_rs_resource_extns
    I need to update a column in the above table from the frontend.
    Please explain me the navigation for doing the same
    Regards,
    Mohan

    I can't tell you the answer to your query but what I can tell you is that you have logged the thread in a wrong forum. As far as my knowledge goes, this table does not delong to HRMS.
    Just check the product in which you are working and then log the thread in the right forum.
    Thanks,

  • ADF 11g Partial Triggers Row Column Update By Column in the Same Row

    Hi.
    I have a situation whereby I have a checkbox in a table row, which has an eventchangelistener, which upon activation, trys to update another column in the same row. I can not get this to work through partial triggers, even though I have set up my ids up correctly. The row though can be updated by a command button outside of the table using the same coding techniques, but I need it updated via the checkbox.
    Is there a limitation in updating a column within a row, from another row column's event change listener.
    Thanks.

    Updating the other rows from the checkbox works fine for me. Here is what I did.
    I DnD Emp table with a new column that says if the emp is new hire. If the checkbox is checked, I set Firstname and Lastname for that row as NewHire. I have partial triggers on Firstname and Lastname columns to update whenever checkbox is checked/unchecked and autosubmit on checkbox to true. Hope this helps.
    Try adding column selection property to single and see if it helps.
    Edited by: asatyana on Jan 16, 2012 12:48 AM
    Edited by: asatyana on Jan 16, 2012 12:49 AM

  • Updating a column in the database

    Hi,
    My requirement is to update a column in the database just before calling
    OAException.raiseBundledOAException(getExceptionList());
    I am calling the above in a method in the AM
    Just before calling this I am Getting the handle of the VO (which is based on an EO, which in turn is based on the table which I want to update) and setting the value of that column as null. But the value is not getting updated at the database level.
    When I query the database I can still see the earlier value and not the updated value.
    In some cases I can see the value on the screen is updated but the value in the database remains same.
    Please let me know how do I update a column in the database and
    Thanks
    Meenal

    Hi,
    I guess, since an excpetion is raised the transaction is not commited automatically by the framework.
    Try commiting the transaction explicity after the update and before the exception. But i dont think, its a good design... anybody any idea ?!

  • How to automatically update InfoPath Form fields(Design) when a new Column is created in SharePoint list?

    Hi All , 
    We have a scenario to automatically update the Infopath form(List Form) fields(Field Name and Control) when ever a new Column is created in the SharePoint list. Is it possible to do this? any options or suggestions?
    Thanks and Regards,
    Nandini

    Hi Nandini,
    I am not very sure will this be going to help you. Ideally, it's not so easy to communicate with infopath using object model. But still you can give it a try using below link :
    http://social.msdn.microsoft.com/forums/sharepoint/en-US/00125fdc-2115-47ea-8e8b-1ca9e5942f83/update-infopath-form-field-in-event-receiver
    I think the above solution is trying to update the field. Addition to that you can try creating a field and control.
    Let me know if it helps  !!
    Thanks

  • Two Infopath forms to submit or update the same sharepoint list

    Hi, I'm building a request SharePoint site so users can submit a request from a simplified InfoPath form (with only 5 out of 10 fields), but support personnel can open the form and then see all 10 fields.  For the list view, I know I can create custom
    views when user's see the list.  But when they open an item, I only want them to see the fields they entered and not the other fields the support personnel can see.  So I guess my question is: can I create two InfoPath forms to update one list or
    can I create an InfoPath form that has two views so one view suppresses fields and the other does not (based on permissions perhaps).

    Hi Darby,
    I would suggest creating two views, instead of two forms. Views can be shown/hidden based on the logged in users, takes few rules to configure based on the logged in users. you can also explore web service to get the users from groups to show/hide based
    on the user group, little overhead but give more control due to the fact of one single form.
    Two forms will be bit complex, if you want to update the same rows of information.
    here are some references -
    http://blogs.technet.com/b/anneste/archive/2011/11/02/how-to-create-an-infopath-form-to-auto-populate-data-in-sharepoint-2010.aspx
    http://claytoncobb.wordpress.com/2009/06/21/userprofileservice-extended/
    http://sharepoint911.com/blogs/laura/Lists/Posts/Post.aspx?List=daba3a3b%2Dc338%2D41d8%2Dbf52%2Dcd897d000cf3&ID=80&Web=dbb90e85%2Db54c%2D49f4%2D8e97%2D6d8258116ca0
    http://office.microsoft.com/en-us/infopath-help/add-delete-and-switch-views-pages-in-a-form-HA101732801.aspx
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • Modify Existing InfoPath Forms Programmatically

    Greetings,
    I have a SharePoint library of approximately 1,000 InfoPath documents. The data types of several columns were changed. Now the columns are blank since their values are read from fields within the InfoPath document. Is there away to programmatically open,
    save and close each individual document so the column values appear in the library rather than doing so manually?
    Thank you for your help.

    Hi,
    Here is a blog for your reference:
    Update InfoPath 2010 form Programmatically
    http://suneet-sharma.blogspot.com/2011/10/update-infopath-2010-form.html
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Create Infopath forms for Renewals, Inactivation and ReHire

    Hi All,
    I need suggestions on the approach i should follow for the following requirement: I'm helping HR develop a hiring database. I can use Infopath 2010, SPD 2010 and OOTB features only with minimal JScript. HR will initiate a contractor hire request. This will
    go through an approval workflow. Till here it is fine as its basic.
    Inactivation: At any point of time they can Inactivate the contract. They need to populate the details like why they are inactivating and others. This is part of the same Infopath form with a different view for Inactivation.
    Renewal: Near the end date of the contract, HR should be notified to Renew the contract which i have achieved by adding Retention stage and initiating a workflow. There will be multiple renewals for the same contractor.
    Re-hire: If a contractor has been inactivated, he can be re-hired. This should allow HR to create a form and send for approvals again, similar to Hiring process.
    My issue: How do I link multiple renewals in the same Infopath form? I tried utilizing Content Types for various scenarios, but I do not have a way to link these. If Renewal is a different content type than main request, then I need to automatically
    populate field from the main request form onto the Renewal content type form. The ID of this form will be different from the main request. Even if i'm able to do this for first Renewal, how to accomplish when second Renewal comes up? For Re-hire, if it is
    a separate content type, then again, how do I link it to the main request?
    Any suggestions would be greatly appreciated.
    Regards, Kapil ***Please mark answer as Helpful or Answered after consideration***

    Content types are overcomplicating this. Use a single content type and multiple views: Initiated, Active, Inactive.
    Id do all of the state changes through workflows. That way you can have a 'De-activate' workflow that prompts your HR team for the details needed, a 'Renewal' workflow which you've already got, a 'Re-hire' workflow to capture the new data etc.
    To make it a little more pleasant to use you can create custom actions to add the workflows to the edit menu so it's nice and easy to get to for your users.

  • Create infopath form contain all records of particular table

    Hi,
    It has resolved my above issue.
    I want to create one sharepoint list connected with database and when i click on add new item, it should display infopath form. 
    I am able to show infopath form on click of 'Add new item' but sharepoint list not containing all records of that particular table.So how can i get all the records of my table.It is possible using external list. But in that case, can i show infopath form?
    Please suggest.
    Please help to solve the issue.
    Thanks & Regards
    Rajni

    Hi Stark,
    Thanks for your response.
    Actually here i am talking about rows in the particular table.
    I want to show all rows in sharepoint list.
    So,is it possible in sharepoint?
    Please guide.
    Thanks in advance!
    Regards
    Rajni

  • 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

  • Creating a form to Add List Item and to a Document Library

    Hi,  I'm super new to sharepoint , and have what is probably a newbie question.
    I have a list and a document library.  The documents are linked to the items in the list. (1 list item may have one or moe documents associated with it).
    I need to create a form to add new list items that will at the same time upload documents to the document library.
    Do I use infopath for that?
    Thanks

    Hi,
    According to your description, when adding a new item to the current list, you might want to upload the attachments of this item to other Document Library as well.
    As a workaround, you can create an Event Receiver to capture the event when there is “An item was added”. In the Event Receiver, we can write C# code to copy the attachments
    from a list item to a Document Library.
    About how to create a simple Event Receiver in SharePoint 2013:
    https://msdn.microsoft.com/en-us/library/ff398052.aspx
    Here is the related code I use in this scenario, you can use it as a reference:
    using System;
    using System.Security.Permissions;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Utilities;
    using Microsoft.SharePoint.Workflow;
    namespace SharePointProject13.EventReceiver1
    /// <summary>
    /// List Item Events
    /// </summary>
    public class EventReceiver1 : SPItemEventReceiver
    /// <summary>
    /// An item is being updated.
    /// </summary>
    public override void ItemUpdating(SPItemEventProperties properties)
    //base.ItemUpdating(properties);
    /// <summary>
    /// An item was added.
    /// </summary>
    public override void ItemAdded(SPItemEventProperties properties)
    // base.ItemAdded(properties);
    using (SPSite site = new SPSite("http://sp/"))
    SPList docDestination = site.RootWeb.Lists["Document"];
    SPList lstAttachment = site.RootWeb.Lists["List1"];
    SPFolder fldRoot = site.RootWeb.Folders[docDestination.Title];
    SPFileCollection flColl = null;
    if (properties.ListItem.Attachments != null && properties.ListItem.Attachments.Count > 0)
    foreach (String strName in properties.ListItem.Attachments)
    flColl = fldRoot.Files;
    SPListItem listtem = docDestination.Items.Add();
    SPFile FileCopy = properties.ListItem.ParentList.ParentWeb.GetFile(properties.ListItem.Attachments.UrlPrefix + strName);
    string destFile = flColl.Folder.Url + "/" + FileCopy.Name;
    byte[] fileData = FileCopy.OpenBinary();
    SPFile flAdded = flColl.Add(destFile, fileData, site.RootWeb.CurrentUser, site.RootWeb.CurrentUser, Convert.ToDateTime(properties.ListItem[SPBuiltInFieldId.Created]), Convert.ToDateTime(properties.ListItem[SPBuiltInFieldId.Modified]));
    SPListItem item = flAdded.Item;
    item[SPBuiltInFieldId.Created] = Convert.ToDateTime(properties.ListItem[SPBuiltInFieldId.Created]);
    item[SPBuiltInFieldId.Modified] = Convert.ToDateTime(properties.ListItem[SPBuiltInFieldId.Modified]);
    flAdded.Item.Update();
    How it works in my environment:
    Add an item with attachment in List1:
    In the Document Library, we can see the uploaded attachment there:
    Best regards
    Patrick Liang
    TechNet Community Support

  • Create edit form based on view with multiple column key

    Hi
    I have a requirement to create a form to update some tables columns based on a view.
    The problem is that the view has a primary key of 4 columns.
    I have tried to create a rowid key based on one underlying table but this does not work.
    I am calling the form from an interactive report but can only pass 3 keys to the form, so only get 3 fields populated.
    Is there some way i can create the form manually as the wizards cannot cope with this requirement?
    My view is here:
    CREATE OR REPLACE FORCE VIEW "DMOADMIN"."MO_STATUS_LOG_VIEW" ("MONEY_ORD_NO", "STATUS_CODE", "DESCRIP", "STATUS_DATE_TIME", "TXN_DATE_TIME", "LLOG_ID", "LINE_SEQ_NO", "CANCEL_IND", "PROCESS_ID", "PBU_ID", "TXN_SEQ_NO", "CANCEL_REASON", "CONDITION_ID", "ADMIN_DATE_TIME", "ADMIN_LLOG_ID") AS
    SELECT a.money_ord_no,
    b.status_code,
    b.descrip,
    a.status_date_time,
    c.txn_date_time,
    c.llog_id,
    c.line_seq_no,
    c.cancel_ind,
    c.process_id,
    c.pbu_id,
    c.txn_seq_no,
    c.cancel_reason,
    c.condition_id,
    d.txn_date_time admin_date_time,
    d.llog_id admin_llog_id
    FROM mo_status a,
    mo_status_desc b,
    host_txn_log c,
    host_admin_log d
    WHERE a.status_desc_id = b.id
    AND a.money_ord_no = c.money_ord_no(+)
    AND a.status_date_time = c.txn_date_time(+)
    AND a.money_ord_no = d.money_ord_no(+)
    AND a.status_date_time = d.txn_date_time(+)
    WITH CHECK OPTION;
    I have tried to populate the data using with an on load process using a plsql query but it is not working. I get no data found error message. Help!

    Hi Erwin,
    I have a similar situation.
    Tabular form based on a view. The view contains a table in a another instance via dblink and everything works fine.
    The only one difference between my and your view is that my "instead of" view is only for UPDATE. You must to have "intead of" trigger only for UPDATE. Insert and delete works fine withoust "instead of" trigger.
    So, try to delete INSERT and DELETE words from your "INSTEADOFBUBA" trigger.
    hope it helps,
    Mzz

Maybe you are looking for

  • How can i save music and pictures so all users can access them?

    how can i save music and pictures so all users can access them?

  • IPod Shuffle will not download music

    I just purchase an iPod shuffle and it will not download the music from iTunes. My computer sees it as well as iTunes, however after the iPod syncs with iTunes the files to not tranfer. I tried dragging them in, still won't work. I have reset, restor

  • Budget Approver for Purchase Requisition

    Hi, In MM setup for purchase requisition, 4 levels has been setup for approving based on amount. The person who will approve is configured to be determined based on user exit (value - 9) in TCode OMGQ. My question here is where is this user exit and

  • Guest access with CWA on ISE

    Hi support community we just implemented CWA for wireless guest access using ISE. however we have an issue, the redirect URL is a name, not an IP address, and the guest dhcp scope use public DNS servers, so CWA doesn't work unless we set the company

  • Using adapter 24/7

    Any downside to using a/c adapter 24/7 in my new Macbook?