. . .

JavaScript Example

In the example below it will load the Sharepoint item with the title "Aufgaben" (meaning "task" in German) rename the title to "Aufgaben_neu" ("new task") and update the item. In order to do so, the an Apiomat.User needs to be created with the login credentials for Sharepoint, which is needed for the authentication. The variable spListItem will be used to store the loaded Sharepoint item wich is loaded via getSharepointLists wich will return the found entries with the title "Aufgaben". Since there is only one item with such title, the first item that will be used can be found at the index 0 of the array. Once it is loaded the functions setTitle() and save() can be invoked that will update the item.

JavaScript

read an item then update its title
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<script src="com/apiomat/apiomat.js"></script>
<title>ApiOmat test</title>
</head>
<body onload="doStuff()">
<script type="text/javascript">
 
function doStuff() {
/* Create a new user of your app */
var myUser = new Apiomat.User('SP_username', 'SP_password');
 
var spListItem = new Apiomat.SharepointListItem();
 
/* configure datastore with user credentials */
Apiomat.Datastore.configure(myUser);
 
Apiomat.SharepointList.getSharepointLists('title=="Aufgaben"', {
onOk : function(spListItem) {
console.log(spListItem);
spListItem[0].setTitle('Aufgaben_neu');
spListItem[0].save({
onOk : function() {
alert("saved");
},
onError : function(error) {
alert("error: " + error.message);
}
});
},
onError : function(error){
console.log("error "+error);
}
},false);
 
}
</script>
</body>
</html>