How to use CAML in Infopath and how to extract and modify infopath source files

Now I am going to show all the process step by step

  • In infopath go to data connections click add new connections select receive data

On the menu select from XML Document than browse your exported files and find your CAMLGuestNew.xml (your CAML files name might be different any name you give when you create it) file and click add.

  • In Infopath go to data connection click add new connection select submit data

Selection options to Web Service in the URL box past: http://YourServerName/_vti_bin/lists.asmx?WSDL

Click next than select UpdateListItem click next

1

Double click in tns:listName

A window comes like bellow

2

I select GUIDguestList field. This field I have already set the default value to GUID of Guest list

Now I click in tns:updates

3

I change the connection to my CAML Batch file then select Batch and click ok

In the include: I select second options you can see in below image

4

Than next and give the connection a name and close

 

  • Now I click on the button where I want to add action than go to manage rules

Add new action rule

In set field values

5

In fields double click the icon I go to my batch file connection and expand and select the field then click ok

In the value field select the field you want to update.

Once you set all the fields values to be updated by CAML

then add submit using data acconnection

in the data connection select the XML connection which we made at the beginning

I made one http://YourServerName/_vti_bin/lists.asmx?WSDL submit to web service named it web service CAMLGuestNew.

 

Then go to publish again and export source files

Change the manifest.xsf to manifest.xml and open it with Wordpad or any text, xml editor

Find the rule you have created for set fields values

In my button I named my rule set CAML Values

 

In manifest.xml file my rule comes like bellow code:

 

<xsf:rule caption=”set CAML Values” condition=”../my:GuestInfo/my:GuestLastName != &quot;&quot; and ../my:GuestInfo/my:GuestType != &quot;&quot; and ../my:GuestInfo/my:GuestTitle != &quot;&quot;” isEnabled=”yes”>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field” expression=”my:EventNumber”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field” expression=”my:EventDate”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field” expression=”my:EventLocation”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field” expression=”my:EventPurpose”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field” expression=”../my:GuestInfo/my:GuestType”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field” expression=”../my:GuestInfo/my:GuestLastName”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field” expression=”../my:GuestInfo/my:GuestFirstName”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field” expression=”../my:GuestInfo/my:GuestTitle”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field” expression=”my:EventMealType”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field” expression=”my:EventCost”></xsf:assignmentAction>

</xsf:rule>

 

 

After the field which I highlight it in red color past bellow code: [@Name = &quot;FieldName&quot;]

 

 

Than change with your fields name in your Batch xml file

 

 

 

 

 

 

 

 

 

 

 

 

The batch xml file codes are like bellow

 

<?xml version=”1.0″ encoding=”UTF-8″?>

<Batch OnError=”Continue”>

<Method ID=”1″ Cmd=”New”>

<Field Name=”EventGiftRefID”></Field>

<Field Name=”Date”></Field>

<Field Name=”DFAClocation”></Field>

<Field Name=”Purpose”></Field>

<Field Name=”GuestType”></Field>

<Field Name=”LastName”></Field>

<Field Name=”FirstName”></Field>

<Field Name=”PositionTitle”></Field>

<Field Name=”MealType”></Field>

<Field Name=”Cost”></Field>

<Field Name=”DFACvoucherLookup”></Field>

</Method>

</Batch>

 

 

Your code will become like bellow code:

<xsf:rule caption=”set CAML Values” condition=”../my:GuestInfo/my:GuestLastName != &quot;&quot; and ../my:GuestInfo/my:GuestType != &quot;&quot; and ../my:GuestInfo/my:GuestTitle != &quot;&quot;” isEnabled=”yes”>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field[@Name = &quot;EventGiftRefID&quot;]” expression=”my:EventNumber”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field[@Name = &quot;Date&quot;]” expression=”my:EventDate”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field[@Name = &quot;DFAClocation&quot;]” expression=”my:EventLocation”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field[@Name = &quot;Purpose&quot;]” expression=”my:EventPurpose”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field[@Name = &quot;GuestType&quot;]” expression=”../my:GuestInfo/my:GuestType”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field[@Name = &quot;LastName&quot;]” expression=”../my:GuestInfo/my:GuestLastName”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field[@Name = &quot;FirstName&quot;]” expression=”../my:GuestInfo/my:GuestFirstName”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field[@Name = &quot;PositionTitle&quot;]” expression=”../my:GuestInfo/my:GuestTitle”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field[@Name = &quot;MealType&quot;]” expression=”my:EventMealType”></xsf:assignmentAction>

<xsf:assignmentAction targetField=”xdXDocument:GetDOM(&quot;CAMguestNew&quot;)/Batch/Method/Field[@Name = &quot;Cost&quot;]” expression=”my:EventCost”></xsf:assignmentAction>

</xsf:rule>

 

 

To test your code working or not open your manifest.xsf file after modifications in InfoPath designer go to your connections and select the batch file and expand it and add repeating table

 

1- The CAMguestNew.xml file Add new items contains:

<?xml version=”1.0″ encoding=”UTF-8″?>
<Batch OnError=”Continue”>
<Method ID=”1″ Cmd=”New”>
<Field Name=”EventGiftRefID”></Field>
<Field Name=”Date”></Field>
<Field Name=”DFAClocation”></Field>
<Field Name=”Purpose”></Field>
<Field Name=”GuestType”></Field>
<Field Name=”LastName”></Field>
<Field Name=”FirstName”></Field>
<Field Name=”PositionTitle”></Field>
<Field Name=”MealType”></Field>
<Field Name=”Cost”></Field>
<Field Name=”DFACvoucherLookup”></Field>
</Method>
</Batch>

==========================================================

2- The CAMguestUpdate.xml file update item contains:

<?xml version=”1.0″ encoding=”UTF-8″?>
<Batch OnError=”Continue”>
<Method ID=”1″ Cmd=”Update”>
<Field Name=”ID”></Field>
<Field Name=”EventGiftRefID”></Field>
<Field Name=”Date”></Field>
<Field Name=”DFAClocation”></Field>
<Field Name=”Purpose”></Field>
<Field Name=”GuestType”></Field>
<Field Name=”LastName”></Field>
<Field Name=”FirstName”></Field>
<Field Name=”PositionTitle”></Field>
<Field Name=”MealType”></Field>
<Field Name=”Cost”></Field>
<Field Name=”DFACvoucherLookup”></Field>
</Method>
</Batch>

========================================================

3-  CAMDelete.xml file contains:

<?xml version=”1.0″ encoding=”UTF-8″?>
<Batch OnError=”Continue”>
<Method ID=”1″ Cmd=”Delete”>
<Field Name=”ID”></Field>
</Method>
</Batch>

 

One thought on “How to use CAML in Infopath and how to extract and modify infopath source files

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.