Pages

Wednesday, November 12, 2014

Find if the Date and Time field is empty in SharePoint Designer workflow

Create a WF variable of type String and Set it to 01/01/0001 00:00:00

Compare Date field with WF variable (return field as: Date/Time), returns True if empty.

Update Multiple SharePoint List Items using SPServices (Update SP Hyperlink field using SPServices)

$().SPServices.SPUpdateMultipleListItems({
               listName: “My List”
               CAMLQuery: "<Query><Where><Eq><FieldRef Name='Request'/><Value Type='Text'>"+record_id+"
                                      </Value></Eq></Where></Query>",
               batchCmd:  "Update",
               valuepairs: [["Hyper link1", "http://google.com, Google1"],["Hyperlink2", "http://google.com, Google2"]]
 });
                                      

For additional information and updates on SPServices check Mark D Anderson's http://spservices.codeplex.com.

Thursday, October 30, 2014

Delete list item using SharePoint Client Object Model

function deleteListItem(id){
      var clientContext = SP.ClientContext.get_current();
      var oList = clientContext.get_web().get_lists().getByTitle(list_name);
      this.oListItem = oList.getItemById(id);
      oListItem.deleteObject();
      clientContext.executeQueryAsync(
               Function.createDelegate(this, this.onQuerySucceededs), 
               Function.createDelegate(this, this.onQueryFaileds));  

Create list item using SharePoint Client Object Model (also get the ID of newly created Item)

function createNewItem(){
         var clientContext = SP.ClientContext.get_current();
         var oList = clientContext.get_web().get_lists().getByTitle(List_Name);  
         var itemCreateInfo = new SP.ListItemCreationInformation();
         this.oListItem = oList.addItem(itemCreateInfo);

         oListItem.set_item('Group', group_value);
         oListItem.update();
         clientContext.load(oListItem);
         clientContext.executeQueryAsync(
                  Function.createDelegate(this, this.onQuerySucceed), 
                  Function.createDelegate(this, this.onQueryFailed));
} // createNewItem method ends.

function onQuerySucceed() {
        var newID =  oListItem.get_id();
}

function  onQueryFailed(){
        alert(‘operation failed’);
}

SPServices to get the ID of the last SharePoint list item (to identify the current item's ID in new form)

function findId(){

       var query = "";

       $().SPServices({
            operation: "GetListItems",
            async: false,
            listName: “List Name”,
            CAMLQuery: query,
            CAMLRowLimit:1,
            completefunc: function (xData, Status) {
                               $(xData.responseXML).SPFilterNode("z:row").each(function() {
                                         var last_item_id = $(this).attr("ows_ID");
                                         return last_item_id;
                                 });
           }
      });//SPServices Ends

}//FindId Method Ends.


For additional information and updates on SPServices check Mark D Anderson's http://spservices.codeplex.com .

Sunday, October 16, 2011

Binding a jQuery method to SharePoint Text Field - jQuery

function bindField() {
            $("input[title='Title']").change(function (){
                 getInfo();
             });
}

Friday, September 16, 2011

SharePoint 2010 Web Part Pages to display Quick Launch Section and Custom Logo

SharePoint 2010 Web Part pages do not display quick launch section and custom logo. This could be easily fixed by making changes in Master Page (v4.master). Make sure you always work in the copy of the master page and have original master page for backup.

To make Quick Launch appear in Web Part page, find the following two sections and comment them.




To make custom logo appear in the Web Part page, find the tag whose name property is "onetidHeadbnnr0" and change it to something else, like "onetidHeadbnnr1" in the master page.