' Create a two <Field> elements under the new <Method> element,
' which will look like:
' <Field Name="SupplierId">[SupplierId]</Field>
xmlDoc, elementMethod, "SupplierId", Row.SupplierId.ToString())
xmlDoc, elementMethod, "CompanyName", Row.CompanyName)
Catch ex As Exception
1, "Script Component", ex.Message, "", 0, True)
The preceding code is commented, but basically it adds the following CAML statement for every record in
<Method ID="[SupplierId]" Cmd="New">
These should look familiar because they're similar to the Method statements you saw when deleting list items. This
time, though, the Cmd attribute specifies an Insert command (New), and the Field elements specify data to insert
rather than acting as a where clause.
One gotcha is that the Field element's Name attribute should refer to the internal name of the field--and that's not
necessarily the same as the display name. If you are unsure of an internal field name, the easiest way to find it is to
navigate to the list in SharePoint, go to the List Settings
Page, click on the column, and copy and UrlDecode the
value after the Field= parameter of the URL. The most
common problem here is that SharePoint converts
spaces to _x0020_.
Incidentally, don't forget the Try/Catch block, this is even
more important in a Data Flow for debugging if some-
thing goes wrong.
Executing the Batch
The last step is to write the code to execute the Batch of
delete and insert commands in SharePoint. Figure 12
shows the completed code flow:
1. Add a second script task following the instructions
2. Connect the Data Flow Task to it and then open the
3. Under the "ReadOnlyVariables" enter
4. Edit the code, and add a reference to and Imports
Putting SharePoint to Work for You, an Internet.com Developer eBook. Copyright 2008, Jupitermedia Corp.
Putting SharePoint to Work for You
Figure 12: Complete Code Flow: Here's the complet-
ed code flow in the designer.