This project is read-only.

Function
roboCAML.BatchCMD();

Functionality

This method will generate XML for CRUD operations within SharePoint.

Parameters (Properties)

Parameter Name Required
batchCMD *Yes* ~See notes***
 IDs *Yes* ~See Delete example***
 updates *Yes* ~See Update example***
 valuePairs *Yes* ~See New/Update example***


 

 

 

 

 


Examples

Deleting Items

roboCAML.BatchCMD({
	//Required parameter *in this scenario*
	batchCMD: "Delete",

	//Required parameter *in this scenario*
	IDs: [1,2,3]
});

The resulting string will look like:

<Batch OnError='Continue'>
	<Method ID='3' Cmd='Delete'>
		<Field Name='ID'>3</Field>
	</Method>
	<Method ID='2' Cmd='Delete'>
		<Field Name='ID'>2</Field>
	</Method>
	<Method ID='1' Cmd='Delete'>
		<Field Name='ID'>1</Field>
	</Method>
</Batch> 

 

New Items

roboCAML.BatchCMD({
	//Required parameter *in this scenario*
	batchCMD: "New",

	//Required parameter *in this scenario*
	valuePairs: [["PersonnelNameLookup", 1, "ModuleNotes", "ModuleNotes", "Description", "Googly Glop"], ["ListUID", 3]] //Static Column Name, Value
});

The resulting string will look like:

<Batch OnError='Continue'>
	<Method ID='1' Cmd='New'>
		<Field Name='PersonnelNameLookup'>1</Field>
		<Field Name='ModuleNotes'>ModuleNotes</Field>
		<Field Name='Description'>Googly Glop</Field>
	</Method>
	<Method ID='2' Cmd='New'>
		<Field Name='ListUID'>3</Field>
	</Method>
</Batch>

 

Update Items
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// ~ Recommended way to use BatchCMD

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

roboCAML.BatchCMD({
	//batchCMD is optional ~ Update is the default value.

	//batchCMD: "Update",
	//If batchCMD isn't set, it can be passed in individually for each method.

	updates: [
		{
			//Notice batchCMD isn't present...
			//Static Column Name, Value
			valuePairs: ["Title", "Numero Tres", "PercentComplete", 1, "Boolean", 0, "ID", 3]
		},
		{
			//Defaults to Update anyway. No need to pass it.
			batchCMD: "Update",
			valuePairs: ["ID", 4, "Title", "Item4", "Boolean", 0]
		},
		{
			batchCMD: "New",
			valuePairs: ["Title", "Something New", "PercentComplete", 1]
		},
		{
			batchCMD: "Delete",
			ID: 6
		}
	]
});

This will result in:

<Batch OnError='Continue'>
	<Method ID='1' Cmd='Update'>
		<Field Name='Title'>Numero Tres</Field>
		<Field Name='PercentComplete'>1</Field>
		<Field Name='Boolean'>0</Field>
		<Field Name='ID'>3</Field>
	</Method>
	<Method ID='2' Cmd='Update'>
		<Field Name='ID'>4</Field>
		<Field Name='Title'>Item4</Field>
		<Field Name='Boolean'>0</Field>
	</Method>
	<Method ID='3' Cmd='New'>
		<Field Name='Title'>Something New</Field>
		<Field Name='PercentComplete'>1</Field>
	</Method>
	<Method ID='4' Cmd='Delete'>
		<Field Name='ID'>6</Field>
	</Method>
</Batch> 

 

BatchCMD Notes***

The main reason I recommend the last example is for consistency.  It's also more flexible and will allow you to do more than one type of Operation per Web Service call.  If you look over the generated string, all allowed operations are within the generated string ~Update, New, Delete.

There is value in the other examples of this method.  I suggest to use them and determine which you like best.  If there is something you'd like to see here, feel free to post your thoughts in the Discussions.

Last edited Feb 15, 2012 at 6:08 PM by iOnline247, version 16

Comments

No comments yet.