Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to pull data from Content Management Document library , Äpproval Status is not a actual document library column. It was enabled through Content Management Feature....

How to i access Approval Status Value from my Event Receiver (VS2010) using SPMetal?

share|improve this question

2 Answers 2

You should be able to get the value out using a Parameter file for SPMetal like this:

<?xml version="1.0" encoding="utf-8"?>
<Web xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal">
  <List Name="Images">
     <ContentType Name="Image" Class="ImageWithStatus">
       <Column Name="_ModerationStatus" Member="ModerationStatus" />
     </ContentType>
  </List>
  <ExcludeOtherLists />
</Web>

Run SPMetal like this:

SPMetal /web:http://sp2010 /parameters:param.xml /code:test.cs

share|improve this answer

spmetal will not generate the _ModerationStatus field because the field is not belong to the document contenttype.

you can simply write a partial class to add a ModerationStatus property manually

public partial class YOUR_DOCUMENT_CLASS 
{
    private System.Nullable<SPModerationStatus> _ModerationStatus;
    [Microsoft.SharePoint.Linq.ColumnAttribute(Name = "_ModerationStatus", Storage = "_ModerationStatus", FieldType = "Choice")]
    public System.Nullable<SPModerationStatus> ModerationStatus
    {
        get
        {
            return this._ModerationStatus;
        }
        set
        {
            if ((value != this._ModerationStatus))
            {
                this.OnPropertyChanging("ModerationStatus", this._ModerationStatus);
                this._ModerationStatus= value;
                this.OnPropertyChanged("ModerationStatus");
            }
        }
    }
}

public enum SPModerationStatus: int {

    None = 0,

    Invalid = 1,

    [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="0")]
    Approved = 2,

    [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="1")]
    Rejected = 4,

    [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="2")]
    Pending = 8,

    [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="3")]
    Draft = 16,

    [Microsoft.SharePoint.Linq.ChoiceAttribute(Value="4")]
    Scheduled = 32,
}

this code is write just now and then paste here, without any test, but i think it will works :), i have write some similar code in my project to get the author info, and works.

good luck

share|improve this answer
    
Hi Eric,thanks for the response. I'm always getting Invalid eventhough my Approval Status is Draft. Could you please guide me? –  Jaffar Apr 27 '12 at 13:53
    
Sorry Jaffar, there's some mistake, the Value property of Microsoft.SharePoint.Linq.ChoiceAttribute should be set to the _ModerationStatus field value of SPListItem, (file.Item["_ModerationStatus"]), after check the real data, i changed the SPModerationStatus in the answer –  Eric Apr 28 '12 at 6:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.