示例#1
0
        } // EndMethod: getInternalFieldName

        internal static int getListItemID(List cList, string keyVal, string keyID, ClientContext ctx)
        {
            int rtnID = 0;

            try
            {
                var query = new CamlQuery
                {
                    ViewXml = Q.oView +
                              Q.oQuery +
                              Q.oWhere +
                              Q.oEq +
                              Q.oFieldRef.Named(keyID) + Q.cFieldRef +
                              Q.oValue.Typed("Text") + keyVal + Q.cValue +
                              Q.cEq +
                              Q.cWhere +
                              Q.cQuery +
                              "<RowLimit>1</RowLimit><ViewFields><FieldRef Name='ID' /></ViewFields><QueryOptions />" +
                              Q.cView
                };
                var rtn = cList.GetItems(query);
                ctx.Load(rtn);
                SPA.Execute(ctx);
                rtnID = rtn[0].Id;
            }
            catch (Exception ex)
            { GeneralLogging.LogEntries.Add("Event => ErrorMessage: " + ex.Message + " ErrorSource: " + ex.Source); }
            return(rtnID);
        } // EndMethod: getListItemID
示例#2
0
        internal static string getInternalFieldName(string strList, string field, ClientContext ctx)
        {
            string internalName = "";
            Field  fc           = null;

            try
            {
                field = field.Trim();
                var cList = ctx.Web.Lists.GetByTitle(strList);
                fc = cList.Fields.GetByInternalNameOrTitle(field);
                ctx.Load(cList);
                ctx.Load(fc);
            }
            catch (Exception ex)
            { SPL.LogEntries.Add("Event => ErrorMessage: " + ex.Message + " ErrorSource: " + ex.Source); }

            SPA.Execute(ctx);
            if (fc != null)
            {
                internalName = fc.InternalName;
            }
            return(internalName);
        } // EndMethod: getInternalFieldName