SharePoint任务父母及其子女

编程入门 行业动态 更新时间:2024-10-14 18:20:18
本文介绍了SharePoint任务父母及其子女的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要提供一个传入任务名称的函数,该函数返回其子ID的列表.我看到子任务有父ID.但是它们的值像1; 1代表多个; 2; 2代表多个,但是所有项目的ID都始于 在我的示例中,从5开始.我希望那些ParentID可以这样做,但显然不会.

I need to come up with a function that I pass in a Task Name and it returns a list of it's children IDs. I see that there are parent IDs for the subtasks. But they have values like 1;1 for several and 2;2 for several, but the IDs of all the items start at in my example start at 5. I had hoped that those ParentID would do it, but apparently not.

这在C#SharePoint控制台应用程序中都是必需的.

This is all needed in a C# SharePoint Console application.

任何对此的建议,将不胜感激.

Any advise on this would be greatly appreciated.

推荐答案

子任务的父ID将被格式化为"1;#1",前1是父任务项ID,另一部分是#1".表示特定父任务下的子任务ID.

Parent ID for a sub task will be formated like "1;#1", the first 1 means the parent task item id, the other part "#1" means the sub task id under the specific parent task.

因此,我们可以拆分父级ID,然后与我们需要查询的给定项目ID进行比较,如果它们相同,则这是我们要获取的子任务:

So we can split the Parent ID and then compare with the given item id we need to query, if they are the same, then this is the sub task we want to get:

static void getChildTask(string itemid) { SPSite site = new SPSite("sp/sites/dev"); using (SPWeb web = site.OpenWeb()) { SPList spList = web.Lists.TryGetList("task1"); if (spList != null) { SPQuery qry = new SPQuery(); qry.ViewFields = @"<FieldRef Name='ParentID' />"; SPListItemCollection listItems = spList.GetItems(qry); foreach (SPListItem item in listItems) { if (item["ParentID"] != null) { string parentitemid = item["ParentID"].ToString().Split(';')[0]; if (parentitemid==itemid) { //do logic here } } } } } }

谢谢

最好的问候

更多推荐

SharePoint任务父母及其子女

本文发布于:2023-10-28 04:00:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535453.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:子女   父母   SharePoint

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!