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 to check whether _spuserid exists in 10 lists of same structure and columns.

var arrayOfLists=["list1","list2","list3",.......,"list10"];
for(var i=0;i<arrayOfLists.length;i++)
 {
   var context = new SP.ClientContext.get_current();
   var web = context.get_web();
   currentUser = web.get_currentUser();
   currentUser.retrieve();
   var list = context.get_web().get_lists().getByTitle(arrayOfLists[i]);                
   var camlQuery = new SP.CamlQuery();      
   camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name="userid"/><ValueType="Integer">' + _spUserId + '</Value></Eq></Where></Query></View>');
   this.collListItem = list.getItems(camlQuery);                  
   context.load(collListItem);
   context.executeQueryAsync(Function.createDelegate(this, this.getcount), Function.createDelegate(this, this.failcount));
 }
    function getcount() {
    var count=0;
    count = this.collListItem.get_count();
    if (count == 0) {
    //No Data Found..Allow to enter ?here I ma calling my function for registration 

    }
    else
    {
     //dont allow to enter
    }

But my registration function is getting called multiple times ..How to prevent it?Suppose I get count 1 for List3 then unnecessarily 2 times registration function will be called.

Any help/idea?

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.