Posts

Showing posts from April, 2011

An Approval Workflow for SharePoint 2010 with Visual Studio 2010 and Infopath 2010

Download Approval Workflow Source Code and Example. I have developed an Approval Workflow that can be deployed on SharePoint 2010 and can be associated to any list or library; it has been developed using Visual Studio 2010. This workflow creates approval tasks for the person who is responsible for the approval, you might think this similar to a usual SharePoint approval workflow, so here we are, to add the touch of spice to this solution, I want to throw some light on the task form, here I am using an InfoPath form when you go and edit this task. This opens up a hell lot of options to play with as InfoPath form is completely customizable. So you can modify the solution and the form as per your needs and requirements very easily. Open property window of State Machine Workflow & add the following values to the properties : Receiver Assembly  = Microsoft.Office.Workflow.Feature, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c Receiver Class  = Micros

Opening a SharePoint 2010 dialog box for list form

If you want to open a window in a dialog from clicking a link then simply use the following JavaScript as the href property. javascript: var options = {url: '/Lists/MyList/NewForm.aspx?IsDlg=1&ContentTypeId=0x001989BCF16D8914CAF8862B0C6C89E091E' , title: 'Showing List' }; void(SP.UI.ModalDialog.showModalDialog(options)) As you can see this is simply taking the script you would usually call and adapting it to work in the href of a hyperlink anchor. It needs to be all on one line and return void when called. So why might you want to do this? Many reasons. Perhaps you have a list with multiple content types and you wish to open the new item form in a dialog AND change the title from the default “[List Title] – New Item” depending on which content type the item is being created from. The snippet above illustrates this. Or perhaps you wish to open a document library in a dialog. Or even an external site. Also you can use following script in your code : p

How to get current logged user information using JavaScript ?

This is post which is simple and not really needed. But when I started writing the code in ECMAScript I have faced problems in getting the logged in user information. So, my readers may feel good after see this post and really most the users are looking for this too. By this time, we have really understood all about ECMAScript Client Object Model and debugging. So, it's easy for us to know it well. Please find the code below to get the current user information. <asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server"> Now copy & paste this JavaScript code after above mentioned tag : <script type="text/ecmascript">         ExecuteOrDelayUntilScriptLoaded(getUserData, "sp.js");              // To Get Current User Name     var context = null;      var web = null;      var currentUser = null;      var currentUserId=''     function getUserData() {             context = new SP.Cli

Get List Items - JavaScript

  var value = SP.ListOperation.Selection.getSelectedList();   var productcollection; function getProducts(title) {     try {         var context = new SP.ClientContext.get_current();         var web = context.get_web();         var list = web.get_lists().getByTitle('product');         var query = '<View Scope=\'RecursiveAll\'>'+                         '<Query>'+                             '<Where>'+                             '<Contains>'+                                 '<FieldRef Name=\'ProductName\'/>' +                                 '<Value Type=\'Text\'>' + title +'</Value>'+                             '</Contains>'+                             '</Where>'+                         '</Query>'+                              '</View>';         var camlQuery = new SP.CamlQuery();         camlQuery.

Hiding fields on NewForm.aspx and EditForm.aspx

First open entry form (NewForm.aspx / EditForm.aspx / DispForm.aspx) in advanced mode in sharepoint designer. Then search for tag : <asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server"> Now copy & paste this JavaScript code after this tag : <script type="text/ecmascript">  ExecuteOrDelayUntilScriptLoaded(runCode, "sp.js");  function runCode()  {   HideField("Expose to Customer / Partner",true);                 HideField("Reported By",true);                               HideField("Reported Date",true);  }  // Function To Hide Fields    function HideField(title,hide){      var header_h3=document.getElementsByTagName("h3") ;      for(var i = 0; i <header_h3.length; i++)      {        var el = header_h3[i];        var foundField ;        if(el.className=="ms-standardheader")        {          for(var j=0; j<el.childNodes.length;

Set default value for People Picker via JavaScript

First open entry form (NewForm.aspx / EditForm.aspx / DispForm.aspx) in advanced mode in sharepoint designer. Then search for tag : <asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server"> Now copy & paste this JavaScript code after this tag : <script type="text/ecmascript">  //Function search for people picker by its no and set default value string type  //If we have 2 people picker in entry form & we want to set value to 2nd no. then "pickerNo=2"  function fillPeoplePickerWithCurrentUser(pickerNo,userLoginName )    {       if(userLoginName != null)       {          var pp = getPickerImputElement(pickerNo);             if(pp != null)          {            pp.innerHTML = userLoginName;          }       }    }   function getPickerImputElement(pickerNo)   {     var result = '';     var divs = document.getElementsByTagName('DIV');     var j = 0;      for(var

SharePoint Interview Questions and Answers

SharePoint Interview Questions and Answers Get More Questions and Answers Q What is SharePoint? Ans SharePoint is a browser based document collaboration platform given by Microsoft. Q What are features of SharePoint 2010? Ans Some features are : ·          Document Collaboration ·          Enterprise Search FAST Search ·          New Enhance Web Part ·          Ready made Silver Light web part ·          Business Connectivity Services ·          Social Media Investments ·          Large lists ·          Enhanced collaboration features ·          Visio Services ·          Usage reporting and logging ·          Better Network Differencing & SharePoint Offline in SharePoint Workspace ·          High Availability/ Disaster Recovery Innovation ·          Admin Insights through the Logging & Usage database, and dev dashboard ·          Service Applications ·          SharePoint Designer Enh