Home

This document is a cache from http://www.spidertg.com/cmsv5/images/stories/eBook_Libarary/Developer/Putting%20SharePoint%20to%20Work%20for%20You.pdf


Putting Share Point toWorkfor You

Document source : www.spidertg.com


' Create a two <Field> elements under the new <Method> element,
' which will look like:
' <Field Name="SupplierId">[SupplierId]</Field>
ListHelper.AppendField( _
xmlDoc, elementMethod, "SupplierId", Row.SupplierId.ToString())
ListHelper.AppendField( _
xmlDoc, elementMethod, "CompanyName", Row.CompanyName)
Catch ex As Exception
Me.ComponentMetaData.FireError( _
1, "Script Component", ex.Message, "", 0, True)
End Try
End Sub
The preceding code is commented, but basically it adds the following CAML statement for every record in
Suppliers:
<Method ID="[SupplierId]" Cmd="New">
<Field Name="SupplierId">[SupplierId]</Field>
<Field Name="CompanyName">[CompanyName]</Field>
</Method>
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
given previously.
2. Connect the Data Flow Task to it and then open the
script task.
3. Under the "ReadOnlyVariables" enter
elementSuppliersBatch.
4. Edit the code, and add a reference to and Imports
27
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.







Summary :

ListHelper.AppendField( _ xmlDoc, elementMethod, "SupplierId", Row.SupplierId.ToString()) ListHelper.AppendField( _ xmlDoc, elementMethod, "CompanyName", Row.CompanyName) Catch ex As Exception Me.ComponentMetaData.FireError( _ 1, "Script Component", ex.Message, "", 0, True) End Try End Sub The preceding code is commented, but basically it adds the following CAML statement for every record in Suppliers: <Method ID="[SupplierId]" Putting SharePoint to Work for You [ ] Figure 12: Complete Code Flow: Here's the complet- ed code flow in the designer.


Tags : code,sharepoint,flow,name,field,list,data,ltfield,insert,task,elements,internal,script





Terms    |    Link pdf-search-files.com    |    Site Map
   |    Content Removal Notice   
   |    Contact   

All books are the property of their respective owners.
Please respect the publisher and the author for their creations if their books copyrighted