Hi Marc, I'm trying to set something up that will display a link on each row of a view, which when clicked will add the current user to a multiple person column for that item, or remove the current user if already there. I'm using it for a feature that allows a user to 'favourite' a document. It looks like your UpdateListItems could be what I need (I already have SPServices installed). I'm quite new to all this and am having trouble understanding the examples above - can you explain a little further how I might go about this (without removing the names that are already there)? I think my code should probably most closely resemble the last example. Something like this (sorry, I know this isn't right at all)?
$(document).ready(function() {
$("#AddRemoveFavourite").click(function() {
var username = $UserId;
UpdateItem(username);
});
});
function UpdateItem(username) {
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "Update",
listName: "Reports",
valuepairs: [["Favourite", username],
completefunc: function(xData, Status) {
alert("completed");
}
});
}
↧