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

When using content approval the CAML for retrieving (say) just Approved Items is

<Query>
  <Where>
    <Eq>
      <FieldRef Name="_ModerationStatus" />
      <Value Type="ModStat">Approved</Value>
    </Eq>
  </Where>
</Query>

However this will only work in English language sites - for French it would be "Approuvé" for example.

Obviously I can put together resource files for all the different supported languages but is there an easier way, either

a) A hidden field that isn't translated (perhaps a numeric indicator)

b) A way in the object model to get the translated work for each approval status?

share|improve this question
add comment

3 Answers 3

up vote 6 down vote accepted

If you open fieldswss.xml you find the declaration of this field

<Field ID="{fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}"
        Name="_ModerationStatus"
        SourceID="http://schemas.microsoft.com/sharepoint/v3"
        StaticName="_ModerationStatus"
        Group="_Hidden"
        ColName="tp_ModerationStatus"
        RowOrdinal="0"
        ReadOnly="TRUE"
        Type="ModStat"
        DisplayName="$Resources:core,Approval_Status;"
        Hidden="TRUE"
        CanToggleHidden="TRUE"
        Required="FALSE">
        <CHOICES>
            <CHOICE>0;#$Resources:core,402;</CHOICE>
            <CHOICE>1;#$Resources:core,400;</CHOICE>
            <CHOICE>2;#$Resources:core,401;</CHOICE>
            <CHOICE>3;#$Resources:core,403;</CHOICE>
            <CHOICE>4;#$Resources:core,404;</CHOICE>
        </CHOICES>
        <Default>0</Default>
    </Field>

I think thatt you can use something like this:

string str = "$Resources:402";
string status = SPUtility.GetLocalizedString(str , "core", (uint)culture.LCID); 
share|improve this answer
add comment

Alexanders answer is probably the way to go, but if you're being lazy and you're using 2010 (it doesn't work on 2007) you can use the numeric values.

0 = Approved
1 = Rejected
2 = Pending

So Approved is

<Query>
  <Where>
    <Eq>
      <FieldRef Name="_ModerationStatus" />
      <Value Type="ModStat">0</Value>
    </Eq>
  </Where>
</Query>
share|improve this answer
add comment

And adding on Alexander and Ryan's answers, if you rely on the numeric value, watch out for the "4" value, that's the "scheduled" one when the contributor publishes something but SharePoint keep it in temporary draft mode until it enters its publication time frame.

0 = Approved
1 = Rejected
2 = Pending
3 = Draft
4 = Scheduled

A published and approved item might thus be in draft state just because it is not currently in schedule. Depending on your business case it might or it might not make sense to display them.

For further explanations regarding that unfrequent status : http://blogs.msdn.com/b/sanjaynarang/archive/2009/02/19/relationships-between-moderation-approval-status-scheduling-versions-and-workflows.aspx

Hope it helped as well.

share|improve this answer
add comment

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.