14 Kasım 2016 Pazartesi

Internal Value for Approval Status

This post is mainly for my own reference purpose. The internal field name for approval status of a list/library item is _ModerationStatus, which has corresponding values and it is type of ModStat:


Status
Internal Value
Approved
0
Rejected
1
Pending
2
Draft
3


Sample usage for these values in CAML query : Retrieve all Approved documents from a particular document library
CAML query would look something like below:

<Where><Eq><FieldRef Name=’_ModerationStatus’ /><Value Type=’ModStat’>0</Value></Eq></Where>



Referance:
http://sharepointwriting.blogspot.com.tr/2011/10/internal-value-for-approval-status.html

7 Ekim 2016 Cuma

Create Site Columns & Site Content Types by PowerShell


  • Take care all columns Web id & Lookup Filed List id
    If you have Lookup field first create list and get id

18 Aralık 2015 Cuma

Sharepoint Field get ıtem Append Changes to Existing Text

 public static string GetVersionedMultiLineTextAsPlainText(SPListItem item, string key)
        {

            StringBuilder sb = new StringBuilder();

            foreach (SPListItemVersion version in item.Web.Lists[item.ParentList.ID].Items[item.UniqueId].Versions)
            {

                SPFieldMultiLineText field = version.Fields[key] as SPFieldMultiLineText;

                if (field != null)
                {

                    string comment = field.GetFieldValueAsText(version[key]);

                    if (comment != null && comment.Trim() != string.Empty)
                    {

                        sb.Append("");

                        sb.Append(version.CreatedBy.User.Name).Append(" (");

                        sb.Append(version.Created.ToString("MM/dd/yyyy hh:mm tt"));

                        sb.Append(")

");
                        sb.Append("-" + comment);
                        sb.Append("
");
                    }

                }

            }

            return sb.ToString();

        }