Submit InfoPath form through CAML using custom fields - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Submit InfoPath form through CAML using custom fields

Last post 07-14-2015 07:46 AM by Hilary Stoupa. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 07-09-2015 04:41 AM

    Submit InfoPath form through CAML using custom fields

    I have followed this guide to add new items to a list, and have managed to do this using the CAML template as a repeating table.

    However, I would like to design the form - i.e. add some labels and textual explanations between the attributes, arranging them in groups etc. Is it possible to, in the CAML template, refer to custom fields so that the submit uses these and remove the repeating table? I'm thinking something like this:

    <Batch OnError="Continue">
        <Method ID="1" Cmd="New">
            <Field Name='Title'></Field>
            <Field Name="FirstName">[/my:myFields/my:customField]</Field>
        </Method>
    </Batch>

    But it just sends it as text. Hoping I might just be getting the syntax wrong, but cant seem to find the right key words to find an example of, or maybe this is simply not possible.

    So, my question is - is it possible to refer to a custom field's value (and not use the CAML template as a repeating table) in the XML? I'm trying to avoid any custom code in the form's implementation.

    Thank you for your time.

  • 07-09-2015 11:00 AM In reply to

    Re: Submit InfoPath form through CAML using custom fields

    OK never mind, I figured out how to do it. But in my opinion it just ludicrous that such basic functionality requires you to modify the source of the form - it should be readily available in the GUI. It is however very clear, even in InfoPath 2013, that this software has been completely neglected by MS - both in terms of quality assurance and usability. Must be the worst software in the Office-suite by far..
  • 07-10-2015 02:43 AM In reply to

    Re: Submit InfoPath form through CAML using custom fields

    OK so I am making some headway, with a LOT of trial and error.. But now I've hit a wall again - submitting Persons or Groups. 

    Using the following rules dont work

    <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;AddBusinessNeedTemplate&quot;)/Batch/Method/Field[@Name = &quot;ProjectOrderer&quot;]" expression="my:ProjectOrderer"></xsf:assignmentAction>

    <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;AddBusinessNeedTemplate&quot;)/Batch/Method/Field[@Name = &quot;ProjectOrderer&quot;]" expression="my:ProjectOrderer/pc:Person"></xsf:assignmentAction> 

    But specifying e.g. DisplayName or AccountID

    <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;AddBusinessNeedTemplate&quot;)/Batch/Method/Field[@Name = &quot;ProjectOrderer&quot;]" expression="my:ProjectOrderer/pc:Person/AccountID"></xsf:assignmentAction>

    allows the submit to go through. But the column is not populated in the list.

    I found this post but cannot seem to apply this to the CAML expression.

    Any ideas? 

  • 07-10-2015 03:24 AM In reply to

    Re: Submit InfoPath form through CAML using custom fields

    <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;AddBusinessNeedTemplate&quot;)/Batch/Method/Field[@Name = &quot;ProjectOrderer&quot;]" expression="xdMath:Eval(my:ProjectOrderer/pc:Person, 'concat(&quot;-1;#&quot;, pc:AccountId)')"></xsf:assignmentAction>

     To save some time for anyone else who finds this syntax baffeling. 

  • 07-10-2015 07:41 AM In reply to

    Re: Submit InfoPath form through CAML using custom fields

    Some column types are trickier than others. Lookups also can use the -1;# syntax to look up the ID of the item - so, if you had a lookup column that displayed the title and you wanted to submit to it, but didn't know the ID, you could use -1;#WhateverAValidTitleValueIs

    Hilary Stoupa

  • 07-11-2015 02:26 AM In reply to

    Re: Submit InfoPath form through CAML using custom fields

    Indeed, I believe that is the current obstacle :-)

    I have a drop-down which is populated by a secondary data source (SharePoint list in same site). I want to submit this value through the CAML, but the target column expects the data type of the secondary data source, not the mere string value of the drop-down. So I'm guessing I need to lookup the string value in the secondary data source to get its ID, and then concatenate as in the previous solution?

    How would the lookup be done within the XPath rule? Using the eval function? I'm having a hard time understanding it, and what the classic "double eval trick" that the other post refers to is.. 

  • 07-13-2015 01:09 AM In reply to

    Re: Submit InfoPath form through CAML using custom fields

    Based on what you are saying here it feels like it should be enough with:

    concat('-1;#', my:CostCenter)

    or maybe like so

    xdMath:Eval(xdXDocument:GetDOM('BU')/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW, "concat('-1;#', /dfs:myFields/dfs:CostCenter)")

    as in the previous solution. But neither of these work. So I've also tried to follow the logic I outlined in the post above

    xdMath:Eval(xdXDocument:GetDOM('BU')/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[d:Title = /my:myFields/my:CostCenter], concat('-1;#', d:ID))

    But to no avail.. So I finally also tried to apply the "double eval trick" previously mentioned

    xdMath:Eval(xdMath:Eval(xdXDocument:GetDOM("BU")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[d:Title = /my:myFields/my:CostCenter], "concat('-1;#', d:ID)"), "..")

    But again without success.

    Not sure which is the correct way to think of the solution here.. Any pointers? 

  • 07-13-2015 07:47 AM In reply to

     Your first concat statement should be correct - unless you are trying to submit multiple values, I'm not sure why you'd use a double eval?

     I'm attaching a zip with the free U2U CAML query builder - it is an older version that has the UpdateListItems method. Test your CAML to make sure you have the syntax right. -1;# indicates you are not submitting the id, but the value that is displayed and SharePoint should lookup the ID. If you have the ID for the item, just submit that directly.

    Hilary Stoupa

  • 07-14-2015 01:41 AM In reply to

    Re: Submit InfoPath form through CAML using custom fields

    Can this application be used to test input as well? I thought it was only for querying data.

    Anyhow, after yet another day of head-against-wall-banging trail and error, mixed with endless dead-end-googling, I finally managed to get it working. The format is:

    ;#ID;#

    The -1 seems to be unnecessary, but the delimiter ;# needs to be added between each value for some reason. Leaving it out resulted in certain values not being added.

    Using the double eval technique to iterative over all of the selected values resulted in the following rule:

    <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;AddBusinessNeedTemplate&quot;)/Batch/Method/Field[@Name = &quot;MaintenanceObject&quot;]" expression="xdMath:Eval(xdMath:Eval(my:MaintenanceObjectGroup/my:MaintenanceObject, 'concat(&quot;;#&quot;, ., &quot;;#&quot;)'), '..')"></xsf:assignmentAction>

    Hopefully this saves someone else some stress.

  • 07-14-2015 07:46 AM In reply to

    Re: Submit InfoPath form through CAML using custom fields

     So you were submitting multiple values - in which case, yes, you need the double eval formula. I don't know about the newer versions of U2U, but the one I attached has the UpdateListItems method - you can test your batch and it can help figure out what you need to submit. That's usually how I figure out some of the trickier edge case stuff...

    Glad you have things working the way you need them - and thanks for the info on "-1" - I'll experiment with leaving that out. 

    Hilary Stoupa

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