简体   繁体   English

添加一个共享点列表项,其中包含“人员或组”类型的列

[英]Adding a sharepoint list item, which has column of type "Person or Group" in it

I am trying to add an item to a list.我正在尝试将项目添加到列表中。 The list has 2 columns in it: Title and recipientId (it is of type Person or Group ).该列表中有 2 列: TitlerecipientId (它的类型为PersonGroup )。 Now I am using现在我正在使用

https:<site url>/_api/web/Lists/getbytitle('list name'>)/items

to create the list.创建列表。 Unfortunately I am unable to figure out what value I should be giving to recipientId (some blogs here mentioned we have to provide the user id. If that is right, how do I get that id or what exactly I should give there for the user to get added there?) This is the json I am using in post man to create the item:不幸的是,我无法弄清楚我应该给recipientId什么值( 这里的一些博客提到我们必须提供用户 id。如果这是正确的,我如何获得该 id 或者我应该在那里为用户提供什么在那里添加?)这是我在邮递员中使用的 json 来创建项目:

{ "__metadata": 
   {
       "type": "SP.Data.List3ListItem"
   },
   "Title": "Teams incorporate feedback"
}

在此处输入图片说明

If your column allow mutiple value:如果您的列允许多个值:

{
       "__metadata":{
          "type":"SP.Data.TestListItem"//change this value to yours 
       },
       "Title":"Test",
       "supervisorId":{
          "results":[25,26]//user ids
       }
    }

If your column only allow single value:如果您的列只允许单个值:

{
   "__metadata":{
      "type":"SP.Data.TestListItem"
   },
   "Title":"Test",
   "supervisorId":5
   
}

Hopefully this might save someone's time,希望这可以节省某人的时间,

so to add a value for a column of type "person or Group"(recipientId in my case).所以要为“person or Group”类型的列添加一个值(在我的例子中是recipientId)。 Firstly, we need to have the site users id that you can get from REST API https://<site_url>/sites/<site_name>/_api/web/siteusers .首先,我们需要有可以从 REST API https://<site_url>/sites/<site_name>/_api/web/siteusers获取的站点用户 ID。 Once you have the ID, you can add it as value for "UsernameId" key value获得 ID 后,您可以将其添加为“UsernameId”键值的值

    { "__metadata": 
{
"type": "SP.Data.List3ListItem"
    
},
"Title": "Varun",
"UsernameId":13

 }

this will add the corresponding user name to the column of type "person or Group"(recipientId in my case).这会将相应的用户名添加到“人员或组”类型的列中(在我的情况下为 recipientId)。 在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在具有查阅列的sharepoint列表中插入项 - Inserting an item in a sharepoint list that has a lookup column 如何使用ecmascript或SPServices获取人员或组类型的SharePoint列表字段值? - How to get SharePoint list field value of type person or group using ecmascript or SPServices? 从SharePoint中的人员或组列表字段检索displayName和电子邮件 - Retrieve displayName and email from person or group list field in SharePoint 在多人或小组字段中添加用户时,如何解决SharePoint中的错误(仅限人) - How to fix error in SharePoint while adding users in multi person or group field(people only) SharePoint在javascript中获得多值个人或组 - SharePoint get multiple value person or group in javascript 发出 POST 请求时出现 400 错误(将项目添加到 SharePoint 列表) - 400 error when making POST request (adding item to SharePoint list) 如何在选择列表项时将文本框追加到来自共享点列表的复选框列表项 - how to append a textbox to a checkbox list item which is coming from a sharepoint list on select of a list item 在“ SharePoint列表新项”页面中创建动态查找列 - Create a dynamic Lookup Column in SharePoint List New Item page 如何使用JavaScript将人员选择器数据(DisplayText)添加到“人员或组”类型的列中? - How can I add people picker data (DisplayText) into column of type 'person or group' using javascript? 只需写人姓即可将列表项添加到其他人列表 - Adding List items to other person list by just wrirting person surname
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM