如何 "Get the Item URL of the SharePoint List Item(On Premise) " 并将其添加到数据中 Table

How to "Get the Item URL of the SharePoint List Item(On Premise) " and to add it in the Data Table

我正在尝试获取 SharePoint(内部部署)列表中项目的列表项目 URL。请问项目 URL 在 "Look Up" 中。如果它存在于 Look Up 中,那么保存 Item URL(value) 的查找的名称(键)是什么。帮助我按照我的要求将 URL 添加到数据 Table 中。

我已经检查了作为获取 SP List 项目的结果而获得的 List Item Collection。有什么方法可以获取列表项URL。

 System.Data.DataTable DT = new DataTable();
                SP.List oList = SP_List.Web.Lists.GetByTitle(ListName);
                CamlQuery cQuery = new CamlQuery();
                cQuery.ViewXml = "@<View><RowLimit>10</RowLimit></View>";
                ListItemCollection ListCollection = oList.GetItems(cQuery);
                SP_List.Load(ListCollection);
                SP_List.ExecuteQuery();

                for (int i = 0; i < ColumnName.Length; i++)
                    DT.Columns.Add(ColumnName[i], System.Type.GetType("System.String"));

                for (int i = 0; i < LookUp.Length; i++)
                    DT.Columns.Add(LookUp[i], System.Type.GetType("System.String"));

                foreach (ListItem value in ListCollection)
                {
                    DataRow dr = DT.NewRow();
                    for (int i = 0; i < ColumnName.Length; i++)
                        dr[ColumnName[i]] = value[ColumnName[i]].ToString();
                    for (int i = 0; i < LookUp.Length; i++)
                        dr[LookUp[i]] = (((Microsoft.SharePoint.Client.FieldUserValue)value[LookUp[i]])?.LookupValue).ToString();
                        DT.Rows.Add(dr);

这是目前的代码,我必须获得我需要的值。我也在尝试在此数据 Table 中添加 "Item URl",帮助我获取并将值添加到数据 Table。

如果我没理解错的话,你想要的只是列表项 url?您可以通过访问 ServerRelativeUrl SP.ListItem.File.ServerRelativeUrl

ctx.load(listItem.File)
ctx.executequery()
console.log(listITem.File.ServerRelativeUrl)

(抱歉我是用jsom写的而不是csom,虽然代码几乎一样)

您的代码对于您要执行的操作来说看起来过于复杂。我可能会考虑简化它。