Submitting data to secondary data source - InfoPath Dev
in

InfoPath Dev

Submitting data to secondary data source

Last post 05-07-2019 08:15 AM by Hilary Stoupa. 21 replies.
Page 1 of 2 (22 items) 1 2 Next >
Sort Posts: Previous Next
  • 05-13-2010 02:27 PM

    Submitting data to secondary data source

    I know this is not natively supported in InfoPath, but there has got to be a way to be able to update a secondary data source (Sharepoint list).

    I have two lists. One comprised of all our servers and their stats. A second list that I am using to collect stats of our Virtualization effort. I want to collect things like how long it is taking each server to virtualize and how many issues arise. I also want to capture whether or not a server is virtualized. In sharepoint I then want to display a stacked bar chart showing each regions total server count with the stacked bar showing how many are virtual. I do not want to have to capture this data in separate forms if possible. I am very green with infopath and coding (all I know is vbscript and some powershell). That being said I am looking to learn some new things here! I have been trying this out with little success.

     Here is a capture of the checkbox in question on the form. I have a formatting rule on the repeating field to only show if servername matchs the rows server name field.

  • 05-13-2010 03:07 PM In reply to

    Re: Submitting data to secondary data source

    Found this article. http://blog-sharepoint.blogspot.com/2009/07/summary-how-to-programmatically-update.html

     Here are points I am struggling with right now.

     I have List A and List B

     List A contains all servers and their stats (CPU, Mem, etc)

    List B is for collecting stats of employees P2V process.

    The form I am working with is created from List B. I have a drop down which is populated from List A's Server Names. When I submit the form it creates a new entry in List B with all the details I want no problem (using the basic submit form options).

    List A has a column "Virtualized". On the form in List B I have a checkbox (pictured above) that I want to update this field (Virtualized) in List A. I am stuck here and I am not even sure the CAML path is right for this. At this point all that has done is confuse me.

    Filed under:
  • 05-13-2010 03:33 PM In reply to

    Re: Submitting data to secondary data source

    I think you would be able to use the CAML approach, since this is an existing list item -- it would have it's ID when you query your list for it. So, when the user selects Virtualized, you could create the CAML to update the list item so that the value is submitted to your List A.

    Check out the U2U CAML query builder -- it really helps me get my head around correct CAML.

    Hilary Stoupa

  • 05-14-2010 08:23 AM In reply to

    Re: Submitting data to secondary data source

    Thankyou for the reply! How does the CAML know which record that needs to be updated? Here is my first go at creating a update CAML. I should also note that I am using Sharepoint 2010 in case there is any repercusion with that. TIA fo any help!

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
        <Method ID="1" Cmd="Update">
            <Field Name='Virtualized_x003f_'></Field>
        </Method>
    </Batch>

    Filed under:
  • 05-14-2010 03:16 PM In reply to

    Re: Submitting data to secondary data source

    You'll need to include the ID field, so <Field Name='ID'></Field> with the ID for the item populating that node. You'll also need to change the ID attribute for the Method.

    Hilary Stoupa

  • 05-17-2010 02:31 PM In reply to

    Re: Submitting data to secondary data source

    Thanks again for your reply!

     Here is my current CAML I have injected some questions. Thanks so much for your time!

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
        <Method ID='ServerID' Cmd="Update"> <--ServerID is a field on the form that I have populate with the chosen row ID of the server selected 
            <Field Name='Virtualized'></Field> <-- Virtualized is the name of the field on the form that is the checkbox. The name of the field on the secondary data source is Virtualized_x003f_
        </Method>
    </Batch>

    So my understanding is that the "Method ID=" Tells the CAML what row to update on the specified list (Identified by GUID in the Web Service DS) Could I also say <Method Title='ServerName' Cmd="Update"> also work?

    "Name=" refers to the field in the form that you want to capture. How does it know which field in the secondary DS to update? Or do the names need to match verbatim?

     Am I even close?

  • 05-17-2010 03:37 PM In reply to

    Re: Submitting data to secondary data source

    I think I may not have been clear. When you change the value in Virtualized, you will want to use rules in InfoPath to set the value of the method's ID attribute to the correct ID for that row. I suppose you could also have the rule on your ServerID field.... Name refers to the field in the SharePoint list that you want to update -- and the names have to be exactly right (sometimes tricky with SharePoint). You may want to consider giving qRules a try -- we make all this a lot easier.

    Hilary Stoupa

  • 05-18-2010 10:01 AM In reply to

    Re: Submitting data to secondary data source

    I am still just baffled by this method to update a secondary data source. Here is everything I have that is (I think) related to updating a field. Maybe you can see where I have gone wrong.

    List GUID and Field I want to update names ----> List=%7BFAB4BBFC%2D0EAC%2D4BBF%2D87D7%2D1BC8BFFEF76E%7D&Field=Virtualized%5Fx003f%5F

    CAML that I have 

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
        <Method ID="1" Cmd="Update">
            <Field Name='Virtualized_x003f_'></Field>
        </Method>
    </Batch>

    When I change the drop down box for server name these are the rules that apply 

    @ID is the Method ID under the caml Datasource I believe I have it changing to the row ID of the Server List where the server name selected matches the server name in the list. I also set the Virtualized (check box @name in CAML) field to match what the server list already has for that field for that server.

    This shows the form and the checkbox that associates with the Name field on the CAML datasource

     

    Shows the Submit Options 

    Submit rules to submit both main form data and web service submit 

    Showing my data sources 

    Web Service Submit datasource details 

    The field ListName and its default value of the Regional Servers GUID list at the top of this post. 

    Maybe this will help someone see where I have gone wrong. I am not in a position that can buy additional software for this. Thanks for the help, it is much appriciated! Also if I have left any key info out, please let me know!
  • 05-18-2010 03:17 PM In reply to

    Re: Submitting data to secondary data source

    Put a control on your form bound to your update datasource, so you can verify what your resulting CAML looks like after your rules run. You also need to add another Field node to your XML for your update data source -- as I mentioned early on, you need <Field Name="ID"></Field>.

    Your CAML should probably look something like this prior to being submitted:

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
        <Method ID="15" Cmd="Update">
            <Field Name="ID">15</Field>
            <Field Name="Virtualized_x003f_">true</Field>
        </Method>
    </Batch>

    "15" is an ID I just made up. You may or may not have an item with an ID of 15. I really really really encourage you to try the U2U CAML Query Builder -- it is free and can help you get your CAML right.

    Hilary Stoupa

  • 05-18-2010 03:48 PM In reply to

    Re: Submitting data to secondary data source

    When I add a second Field in the CAML and I add a control source on the form it is a repeating field. There is now no way for me update the fields via rules. Is this something that can not be done natively in infopath? When I tell Infopath to update "field" on the update datasource it fills in both ID and Virtualized with the same data.

     

    After selecting a server This is what my form looks like

  • 05-18-2010 04:01 PM In reply to

    Re: Submitting data to secondary data source

    I'm sorry, I forgot about that IP limitation for rules. Here's a blog post that explains how to do this in the manifest.

    Hilary Stoupa

  • 05-19-2010 08:34 AM In reply to

    Re: Submitting data to secondary data source

    Here is the modified (unworking) manifest.xsf. For the first and last assignmentAction I have added in [../@Name='Virtualized'] and [../@Name='ID'] I have also tried without the @ symbol. I understand this as "change the value of the field where the name equals Virtualized" Am I reading this correctly? I am slowly starting to "get it", thanks for your help!

    <xsf:ruleSet name="ruleSet_5">
       <xsf:rule caption="Rule 1" isEnabled="yes">


        <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;update&quot;)/Batch/Method/Field[../@Name='Virtualized']" expression="xdXDocument:GetDOM(&quot;Regional Servers&quot;)/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Virtualized"></xsf:assignmentAction>


        <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;update&quot;)/Batch/Method/@ID" expression="xdXDocument:GetDOM(&quot;Regional Servers&quot;)/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:Title = ../d:Title]"></xsf:assignmentAction>


        <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;update&quot;)/Batch/Method/Field[../@Name='ID']" expression="xdXDocument:GetDOM(&quot;Regional Servers&quot;)/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:Title = ../d:Title]"></xsf:assignmentAction>


       </xsf:rule>
      </xsf:ruleSet>

  • 05-19-2010 09:31 AM In reply to

    Re: Submitting data to secondary data source

    Ok,

     Here is what is mostly working now.

         <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;update&quot;)/Batch/Method/Field[2]" expression="xdXDocument:GetDOM(&quot;Regional Servers&quot;)/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Virtualized"></xsf:assignmentAction>


        <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;update&quot;)/Batch/Method/@ID" expression="xdXDocument:GetDOM(&quot;Regional Servers&quot;)/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:Title = ../d:Title]"></xsf:assignmentAction>


        <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;update&quot;)/Batch/Method/Field[1]" expression="xdXDocument:GetDOM(&quot;Regional Servers&quot;)/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:Title = ../d:Title]"></xsf:assignmentAction>

    Now the ID field is updating but the virtualized always says true...getting closer

  • 05-19-2010 09:38 AM In reply to

    Re: Submitting data to secondary data source

    See how in your expression for the ID field you have a filtered XPath?

    expression="xdXDocument:GetDOM(&quot;Regional Servers&quot;)/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID[xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:Title = ../d:Title]"

    While in your expression for the Virtualized field you do not? So the expression for the Virtualized field will currently always return the first Virtualized node in the Regional Servers data source. I'm going to guess that the same filter in the working expression would work in your expression for the virtualized field.

    Your intial XPaths to the fields were incorrect. Instead of this: Field[../@Name='ID'], you'd want: Field[@Name='ID'].

    Hilary Stoupa

  • 05-19-2010 09:46 AM In reply to

    Re: Submitting data to secondary data source

    So here we are I think I finally have it working!

     At least when I preview in Infopath...

    When I publish and try in the web browser I end up with the ID and Virtualized Fields both changing instead of just one. Can I expect these forms not to work in web format? I am not sure that is a big deal, just would be nice to know for sure.

     BTW thank you so much for your patience with me on this! I am glad I finally have it working definately learned a lot on the way.

Page 1 of 2 (22 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.