2013-05-22 41 views
0

如何使用SPservices將多個用戶添加到具有多個用戶的項目?在JQuery中可能嗎?如何使用SPservices將多個用戶添加到項目

我有下一個的jquery:

//Users ID, who shoud be located in the field "Users" 
var us1 = 110; 
var us2 = 113; 
var uw3 = 115; 


$().SPServices({ 
     operation: "UpdateListItems", 
     async: false, 
     batchCmd: "Update", 
     listName: "testList", 
     valuepairs: [["users", us1]], 
     ID: 5, 
     completefunc: function(xData, Status) { 
      alert("yeah, ready!"); 
    }); 
} 

現在領域[ 「用戶」]具有輸入 「多個用戶」,並且此方法僅增加一個用戶(US1)。 那麼,如何添加到字段[「用戶」]幾個用戶(us1,us2,us3)?

+0

*我的意思是,「很多用戶在項目的Sharepoint 2010添加多個用戶」 – reNNN

+1

你嘗試過什麼?當你發佈一些你已經嘗試過讓其他人可以看看它並提出建議的東西時,StackOverflow往往可以發揮最佳效果。 –

+0

好的,謝謝。我是新手,並會嘗試獲取更多信息。 – reNNN

回答

0

據我所知,這個問題是一歲,但我發現它,這是沒有答案,所以:用於更新用戶領域的多種選擇(添加和刪除用戶)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> 
 

 
function UpdateParticipants(listName, itemId, userName, userId, initialData) { 
 

 
    var usersToSet = ""; 
 
    if (!IsStringEmpty(initialData)) { 
 
     usersToSet = initialData + ";#" + userId + ";#" + userName; 
 
    } else { 
 
     usersToSet = userId + ";#" + userName; 
 
    } 
 

 
    $().SPServices({ 
 
     operation: "UpdateListItems", 
 
     async: false, 
 
     debug: true, 
 
     listName: listName, 
 
     ID: itemId, 
 
     valuepairs: [["EventParticipants", usersToSet]], 
 
     completefunc: function (xData, Status) { 
 
      if (Status != "success") { 
 
       alert("Something Went Wrong. You haven't applied for the event, please contact Event Manager."); 
 
      } else { 
 
       alert("You have succesfully applied for the event."); 
 
      } 
 
     } 
 
    }); 
 

 
} 
 

 
function RemoveParticipant(listName, itemId, userName, userId, initialData) { 
 

 
    var usersToDelete = userId + ";#" + userName; 
 
    var usersToSet = initialData.replace(usersToDelete, ""); 
 

 
    $().SPServices({ 
 
     operation: "UpdateListItems", 
 
     async: false, 
 
     debug: true, 
 
     listName: listName, 
 
     ID: itemId, 
 
     valuepairs: [["EventParticipants", usersToSet]], 
 
     completefunc: function (xData, Status) { 
 
      if (Status != "success") { 
 
       alert("Something Went Wrong. You haven't resigned from the event, please contact Event Manager."); 
 
      } else { 
 
       alert("You have succesfully resigned from the event."); 
 
      } 
 
     } 
 
    }); 
 

 
} 
 

 
function IsStringEmpty(inputString) { 
 
    if (inputString != null && inputString != "" && inputString != "undefined" && inputString.length > 0) { 
 
     return false; 
 
    } 
 
    return true; 
 
} 
 

 
    
 
</script>

LISTNAME - 是的,事實上,名單GUID在我的情況... :)

相關問題