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 have a list which has two fields. (Title,EditPermission). The EditPermission is "people and group" field. I can use the following code to compare the current user with the spuser in that field

    var cName = _currentUser.get_title(); 
    var admins = currentItem.get_item('Admins');
                    for (var ii = 0; ii < admins.length; ii++) {
                        var admin = admins[ii].get_lookupValue();
                        if (admin == cName) {

                            return true;
                        }
                    }

What I need here is suggestion to get the spgroup info while traversing and then see if user exists inside it or not.

Another point, Is there any better way to do it, like may be using CAMl query? that will result the list rows that has "Me" in "EditPermission" column.

share|improve this question
1  
var condition = '<Where><Or><Membership Type=\"CurrentUserGroups\"> <FieldRef Name=\"PEOPLE_GROUPS_COLUMN_NAME\"/></Membership><Eq><FieldRef Name=\"PEOPLE_GROUPS_COLUMN_NAME\"></FieldRef><Value Type=\"Integer\"><UserID/></Value></Eq></Or></Where>'; This Query will return the rows belonging to current user, either assigned directly or in group –  Nomi Jul 11 '12 at 7:25
    
Further Reading at msdn.microsoft.com/en-us/library/aa544234.aspx –  Nomi Jul 11 '12 at 7:25
add comment

1 Answer

From OP's comment:

var condition = '<Where><Or><Membership Type=\"CurrentUserGroups\"> <FieldRef Name=\"PEOPLE_GROUPS_COLUMN_NAME\"/></Membership><Eq><FieldRef Name=\"PEOPLE_GROUPS_COLUMN_NAME\"></FieldRef><Value Type=\"Integer\"><UserID/></Value></Eq></Or></Where>';

This Query will return the rows belonging to current user, either assigned directly or in group.

Further Reading at http://msdn.microsoft.com/en-us/library/aa544234.aspx

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.