Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Thursday, October 25, 2012

Tuesday, October 23, 2012

Http 503 Error Service Unavailable in SharePoint 2010



  1. Go to Run and Type inetmgr
  2. Go to your Application pools.
  3. Click on the SharePoint Site with which you are getting the problem.
  4.  Click on Advanced Settings and go to Process Model Tab and select Identity.
  5. In Application Pool Identity I observe that Custom Account Radio Button is selected.
  6. Select Built in Account Radio Button & select the Smart Tag under the Radio Button.
  7. In the Smart Tag select Network Service and press ok.
  8. Now the problem is solved.

Tuesday, October 09, 2012

Delete the SharePoint ListItem using ECMA Script

Note:-
Use Delete() function in Delete Button onclick event, for DropDown Binding View my Previous article posted before this.


function Delete()
{
                ExecuteOrDelayUntilScriptLoaded(DeleteRecord, "sp.js");
}
function DeleteRecord()
{
                if(document.getElementById("ddlItemID").selectedIndex==0)
                {
                                alert('Please Select UserName');
                                return false;
                }
                var context = new SP.ClientContext.get_current();
    var web = context.get_web();
    var list = web.get_lists().getByTitle('Login');
    var LoginRecord = list.getItemById(document.getElementById("ddlItemID").options(document.getElementById("ddlItemID").selectedIndex).value);
    LoginRecord.deleteObject();
    context.executeQueryAsync(Function.createDelegate(this, this.DeleteSuccess), Function.createDelegate(this, this.DeleteFailed));
}

function DeleteSuccess()
{
                alert('Record Deleted Successfully');
                document.getElementById("tdItemID").innerHTML="";
                Bind();
                document.getElementById("ddlItemID").selectedIndex=0;
               
}

function DeleteFailed(sender, args)
{
                alert('Delete Failed');
}

Binding SharePoint ListItems to DropDownList using ECMA Script

Note:-
Use Bind() function in the Page Load. Before that Create a TD with ID tdItemID.

function Bind()

{

    ExecuteOrDelayUntilScriptLoaded(BindDropDown, "sp.js");

}


function BindDropDown()
{
                var context = new SP.ClientContext.get_current();
    var web = context.get_web();
    var list = web.get_lists().getByTitle('Login');
    var sQuery="<View><Query><OrderBy><FieldRef Name='ID' /></OrderBy></Query></View>";
     var camlQuery = new SP.CamlQuery();
      camlQuery.set_viewXml(sQuery);
      this.myColl = list.getItems(camlQuery);
      context.load(this.myColl, 'Include(Title, ID)');
      context.executeQueryAsync(Function.createDelegate(this, this.BindSuccess), Function.createDelegate(this, this.Bindfailed));
}
Bind();

function BindSuccess()
{
                var listEnumerator = this.myColl.getEnumerator();
                var strDropDown="";
                strDropDown+="<Select id='ddlItemID'>";
                strDropDown+="<Option>";
                strDropDown+="Select Username";
                strDropDown+="</Option>";
                while (listEnumerator.moveNext())
                {
                    var item = listEnumerator.get_current();
                    strDropDown+="<Option value='"+item.get_item('ID')+"'>";
                    strDropDown+=item.get_item('Title');
                    strDropDown+="</Option>";               
    }
   strDropDown+="</Select>";
                if(document.getElementById("tdItemID"))
                {
                                document.getElementById("tdItemID").innerHTML=strDropDown;
                }
}

function Bindfailed(sender, args)
{
    alert('failed. Message:' + args.get_message());
}

Search and Update using Client Object Model

Note:-
Use Edit() Function in Search Button Onclick event  and Update() Function in Update Button Onclick Event.

var strItemID="";
var myColl="";

 function Edit()

{

    ExecuteOrDelayUntilScriptLoaded(SearchRecord, "sp.js");

}

function Update()

{

    ExecuteOrDelayUntilScriptLoaded(UpdateRecord, "sp.js");

}
function SearchRecord()
{
                try
                {
                var context = new SP.ClientContext.get_current();
    var web = context.get_web();
    var list = web.get_lists().getByTitle('Login');
                var sQuery = '<View Scope=\'RecursiveAll\'>'+
                        '<Query>'+
                            '<Where>'+
                            '<Eq>'+
                                '<FieldRef Name=\'Title\'/>' +
                                '<Value Type=\'Text\'>' + document.getElementById("txtUserName").value +'</Value>'+
                            '</Eq>'+
                            '</Where>'+
                        '</Query>'+
                             '</View>';
        var camlQuery = new SP.CamlQuery();
        camlQuery.set_viewXml(sQuery);
        this.myColl = list.getItems(camlQuery);
        context.load(this.myColl, 'Include(Title, Password, ID)');
        context.executeQueryAsync(Function.createDelegate(this, this.SearchSuccess), Function.createDelegate(this, this.failed));
                }
                catch(ex)
                {
                                alert(ex.message);
                }
}

function SearchSuccess()
{
                document.getElementById("divItemID").innerHTML="";
                var listEnumerator = this.myColl.getEnumerator();
                while (listEnumerator.moveNext())
                {
                    var item = listEnumerator.get_current();               
                    document.getElementById("txtPassWord").value = item.get_item('Password');
                    document.getElementById("divItemID").innerHTML=item.get_item('ID');
                    break;
    }
}
function failed(sender, args) {
    alert('failed. Message:' + args.get_message());
}

function UpdateRecord()
{
                var context = new SP.ClientContext.get_current();
    var web = context.get_web();
    var list = web.get_lists().getByTitle('Login');
    var LoginRecord = list.getItemById(strItemID);
    LoginRecord.set_item('Password', document.getElementById("txtPassWord").value);
    LoginRecord.update();
    context.executeQueryAsync(Function.createDelegate(this, this.Updatesuccess), Function.createDelegate(this, this.Updatefailed));
}

function Updatesuccess()
{
                alert("Record Updated Successfully");
                document.getElementById("txtUserName").value="";
                document.getElementById("txtPassWord").value="";
               
}

function Updatefailed()
{
                alert('Update Failed');
}