Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web services Sharepoint列表中列表项的正确显示名称/字段(使用Web服务)_Web Services_Sharepoint_List - Fatal编程技术网

Web services Sharepoint列表中列表项的正确显示名称/字段(使用Web服务)

Web services Sharepoint列表中列表项的正确显示名称/字段(使用Web服务),web-services,sharepoint,list,Web Services,Sharepoint,List,我正在创建一个程序,该程序使用SharePoint Web Services向用户查询和显示SharePoint列表。我一次只能显示一列,因此我需要找到要显示的“默认列”或“显示列”。我知道“Title”常用于许多内容类型,但我希望它对任何类型的自定义内容类型或列表都具有鲁棒性,因此我想找到一些查询列表的方法来发现此字段 例如:我在这里使用SharePoint Manager 2010,查看一个链接库(没有标题字段),但不知怎的,它知道列表项名为“”。这是怎么推断的? (来源:)看起来Disp

我正在创建一个程序,该程序使用SharePoint Web Services向用户查询和显示SharePoint列表。我一次只能显示一列,因此我需要找到要显示的“默认列”或“显示列”。我知道“Title”常用于许多内容类型,但我希望它对任何类型的自定义内容类型或列表都具有鲁棒性,因此我想找到一些查询列表的方法来发现此字段

例如:我在这里使用SharePoint Manager 2010,查看一个链接库(没有标题字段),但不知怎的,它知道列表项名为“”。这是怎么推断的?

(来源:)

看起来DisplayName背后有相当多的逻辑。以下是我使用Reflector获得的代码:

public string DisplayName
{
    get
    {
        if (!this.IsNew)
        {
            if ((!this.ParentList.AllowContentTypes && (this.ParentList.BaseType == SPBaseType.DocumentLibrary)) || (this.ParentList.AllowContentTypes && (this.ContentTypeId.IsNonDiscussionFolder || this.ContentTypeId.IsChildOf(SPBuiltInContentTypeId.Document))))
            {
                string str = (string) this.GetValue("BaseName", false);
                if (!string.IsNullOrEmpty(str))
                {
                    return SPHttpUtility.HtmlDecode(str);
                }
            }
            SPField fieldByInternalName = this.Fields.GetFieldByInternalName("Title", false);
            if (fieldByInternalName != null)
            {
                string fieldValueAsText = fieldByInternalName.GetFieldValueAsText(this.GetValue(fieldByInternalName, -1, false));
                if (!string.IsNullOrEmpty(fieldValueAsText))
                {
                    return fieldValueAsText;
                }
            }
            if (this.ParentList.AllowContentTypes)
            {
                if (this.ContentTypeId.IsChildOf(SPBuiltInContentTypeId.Link))
                {
                    SPFieldUrlValue value2 = new SPFieldUrlValue((string) this.GetValue("URL", false));
                    if (!string.IsNullOrEmpty(value2.Description))
                    {
                        return value2.Description;
                    }
                    if (!string.IsNullOrEmpty(value2.Url))
                    {
                        return value2.Url;
                    }
                }
                if (this.ContentTypeId.IsChildOf(SPBuiltInContentTypeId.Message))
                {
                    Guid discussionTitleLookup = SPBuiltInFieldId.DiscussionTitleLookup;
                    SPField fld = this.Fields[discussionTitleLookup];
                    string str3 = fld.GetFieldValueAsText(this.GetValue(fld, -1, false));
                    if (!string.IsNullOrEmpty(str3))
                    {
                        return str3;
                    }
                }
            }
            if (this.ParentList.BaseType != SPBaseType.Survey)
            {
                using (IEnumerator enumerator = this.Fields.GetEnumerator())
                {
                    SPField field3;
                    string str5;
                    while (enumerator.MoveNext())
                    {
                        field3 = (SPField) enumerator.Current;
                        if (field3.GetFieldBoolValue("TitleField"))
                        {
                            goto Label_00C6;
                        }
                    }
                    goto Label_016F;
                Label_00BB:
                    if (!(field3 is SPFieldMultiLineText))
                    {
                        return str5;
                    }
                    goto Label_00ED;
                Label_00C6:
                    str5 = field3.GetFieldValueAsText(this.GetValue(field3, -1, false));
                    if (string.IsNullOrEmpty(str5))
                    {
                        goto Label_016F;
                    }
                    goto Label_00BB;
                Label_00ED:
                    if (str5.Length <= 0xff)
                    {
                        return str5;
                    }
                    return str5.Substring(0, 0xff);
                }
            }
            SPContext context2 = SPContext.Current;
            if ((context2 == null) || (context2.FormContext.FormMode != SPControlMode.Edit))
            {
                return SPResource.GetString("ViewResponseTitle", new object[] { this.ID.ToString("N0", this.Web.Locale) });
            }
            return SPResource.GetString("ToolBarMenuRespondToSurvey", new object[0]);
        }
        SPContext current = SPContext.Current;
        if (this.ParentList.BaseType != SPBaseType.Survey)
        {
            if ((current != null) && current.FormContext.IsNonDiscussionFolder)
            {
                return SPResource.GetString("ButtonTextNewFolder", new object[0]);
            }
            return SPResource.GetString("NewFormTitleNewItem", new object[0]);
        }
        return SPResource.GetString("ToolBarMenuRespondToSurvey", new object[0]);
    Label_016F:
        return SPResource.GetString("NoTitle", new object[0]);
    }
}
公共字符串显示名称
{
得到
{
如果(!this.IsNew)
{
如果(!this.ParentList.AllowContentTypes&&(this.ParentList.BaseType==SPBaseType.DocumentLibrary))|&(this.ParentList.AllowContentTypes&&(this.ContentTypeId.IsNonDiscussionFolder | | this.ContentTypeId.IsChildOf(SPBuiltInContentTypeId.Document)))
{
string str=(string)this.GetValue(“BaseName”,false);
如果(!string.IsNullOrEmpty(str))
{
返回sphttputability.HtmlDecode(str);
}
}
SPField fieldByInternalName=this.Fields.GetFieldByInternalName(“Title”,false);
if(fieldByInternalName!=null)
{
字符串fieldValueAsText=fieldByInternalName.GetFieldValueAsText(this.GetValue(fieldByInternalName,-1,false));
如果(!string.IsNullOrEmpty(fieldValueAsText))
{
返回字段valueastext;
}
}
if(this.ParentList.AllowContentTypes)
{
if(this.ContentTypeId.IsChildOf(SPBuiltInContentTypeId.Link))
{
SPFieldUrlValue value2=新的SPFieldUrlValue((字符串)this.GetValue(“URL”,false));
如果(!string.IsNullOrEmpty(value2.Description))
{
返回值2.说明;
}
如果(!string.IsNullOrEmpty(value2.Url))
{
返回值2.Url;
}
}
if(this.ContentTypeId.IsChildOf(spbuildincontenttypeid.Message))
{
Guid discussionTitleLookup=SPBuiltInFieldId.discussionTitleLookup;
SPField fld=这个.Fields[discussionTitleLookup];
字符串str3=fld.GetFieldValueAsText(this.GetValue(fld,-1,false));
如果(!string.IsNullOrEmpty(str3))
{
返回str3;
}
}
}
if(this.ParentList.BaseType!=SPBaseType.Survey)
{
使用(IEnumerator enumerator=this.Fields.GetEnumerator())
{
SPField字段3;
字符串str5;
while(枚举数.MoveNext())
{
field3=(SPField)枚举器。当前;
if(field3.GetFieldBoolValue(“TitleField”))
{
转到标签_00C6;
}
}
转到标签_016F;
标签_00BB:
如果(!(字段3是SPFieldMultiLineText))
{
返回str5;
}
转到标签上;
标签\u 00C6:
str5=field3.GetFieldValueAsText(this.GetValue(field3,-1,false));
if(string.IsNullOrEmpty(str5))
{
转到标签_016F;
}
转到标签_00BB;
标签编号:

if(str5.Length)极好的问题-不知道答案,但参考可能会有所帮助-列出web服务,它将以CAML格式提供列表模式,包括字段