Posts

Showing posts from 2014

Bulk update and delete using SPservice in SharePoint

$().SPServices.SPUpdateMultipleListItems({ listName: "States" , CAMLQuery: "<Query><Where><Eq><FieldRef Name='Status'/><Value Type='Text'>Active</Value></Eq></Where></Query>" , valuepairs: [["Status", "Inactive"]] }); This call to SPUpdateMultipleListItems will update all of the items in the States list which have their Status = "Active", setting their Status = "Inactive". $().SPServices.SPUpdateMultipleListItems({ listName: "States" , CAMLQuery: "<Query><Where><Eq><FieldRef Name='Status'/><Value Type='Text'>Inactive</Value></Eq></Where></Query>" , batchCmd: "Delete" }); This call to SPUpdateMultipleListItems will delete all of the items in the States list which have their Status = "Inactive".

Delete the document using SPServices

function deleteFile ( itemID , fileRef , listName ) { // This is the command needed to delete the specified file. It uses the ID and the URL of the file name. These values must be passed into this function when calling it. var batchCmd = "<Batch OnError='Continue'><Method ID='1' Cmd='Delete'><Field Name='ID'>" + itemID + "</Field><Field Name='FileRef'>" + fileRef + "</Field></Method></Batch>" ; // Use SPServices to delete the file. $ (). SPServices ({ operation : "UpdateListItems" , async : false , listName : listName , updates : batchCmd , completefunc : function ( xData , Status ) { // Check the error codes for the web service call. $ ( xData . responseXML ). SPFilterNode ( 'ErrorCode' ). each ( function (){ responseError = $ ( this ). text (); // If the error codes indicate...

Remove left navigation and chrome controls from Newform, editform and viewform of a Sharepoint List

Image
When you send a query-string IsDlg=1 for list OOTB list forms, then what happen? See below....                                                        Without query-string IsDlg=1 With query-string IsDlg=1

Workaround for upload Image from computer in description field of a list in SharePoint APP

Problem: In the development of SharePoint 2013 APP, we found an issue with upload a image from computer to a description field of a list in the app. Causes:  Whenever we are uploading a image to SharePoint list or page, the image actually stored in an asset library.But in the case of SharePoint app we don't find any such kind of library to store these files.Because of this reason, app wont find any place to store the image file then it will throw an error.​ Work Around : In order to resolve the above issue, we need to include a document library in the SharePoint APP.

Custom News feed web part for SharePoint site feed app.

Use the below code to populate and post the feed in site feed app in SharePoint 2013. Note : Enable/Activate Site feed feature in the list of available features var clientContext; var feedManager; var allfeeds; var website; var websiteurl = ""; function populatePosts() {     try {         SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);     }     catch (ex) {         alert(ex);     } } function sharePointReady() {     clientContext = SP.ClientContext.get_current();     website = clientContext.get_web();     clientContext.load(website);     clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed); } function onRequestSucceeded() {     // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.     websiteurl = website.get_url();     SP.SOD.executeOrDelayUntilScr...

Multiple values into field with Type="UserMulti".

" In order to allow enter multiple values into field with Type="UserMulti" you must set attribute Mult="TRUE" Mult should be TRUE not true or True. for more info:   http://msdn.microsoft.com / en-us/library/ms437580.aspx

Sharepoint 2013 Custom Site Definitions

You can create a site definition with Visual Studio 2012 taking the onet.xml in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\SiteTemplates\PUBLISHING\XML\ as starting point and add your custom features, modules, pages or whatever in it.

Sharepoint 2013 search auto suggest using api.

  Use the below snippet for SharePoint 2013 search suggest.This will only work for authenticated users not for anonymous users.  <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox> <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script type="text/javascript" >         var j$ = jQuery.noConflict();         var siteCollUrl = "";         SP.SOD.executeFunc("SP.js", "SP.ClientContext", function () {             var clientContext = new SP.ClientContext.get_current();             var site = clientContext.get_site();...

Unlock the sharepoint site while powershell command interupted.

Image
1.Execute the below command in content db of a site. UPDATE AllSites SET LifeCycleFlags = 1 WHERE ID = '(your site collection GUID)'   2.In central admin-->management application-->Configure site quotas and lock   Now you can change the option to not locked.    

List attachment link in SharePoint 2013 search.

Issue : List attachments links are not able to show in SharePoint 2013 search. Causes: There is no clear field for the attachments in SharePoint list.So we could not get the property related to attachments in the crawl. Solution:We can manually add the field in list where we have the attachment.This field will have the attachment URL.We can make this by Item added event receiver.Now our custom field will be available in crawl property and we can able to create a new managed property, which will map the custom field crawl property. So we can edit the display template based on new managed property.Display template sample is available in the below snippet. Crawl of the list attachment arguments are given in the below URLs. http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=83 http://sajiviswam.wordpress.com/2011/11/23/are-list-attachments-indexed-in-sharepoint-search/ <html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F...

SharePoint 2013 list item attachment search.

Copy below highlighted content save as .html. Upload into a search template gallery and change the search result webpart template with your custom template which one you created above. <html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">  <head> <title>Product and Datasheet</title> <!--[if gte mso 9]><xml> <mso:CustomDocumentProperties> <mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden> <mso:MasterPageDescription msdt:dt="string">Displays the default result item template.</mso:MasterPageDescription> <mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106603</mso:ContentTypeId> <mso:TargetControlType msdt:dt="string">;#SearchResults;#</mso:TargetControlType> <mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAs...

Create page layout for SharePoint 2013 search result webpart.

Add new module in a under a project. Add new page with web part zone under the module and the ULR in the element.xml should be Pages.  Deploy your solution. Add your web parts in your custom page. Open the same page in designer, now you can find the spsswc:ResultScriptWebPart tag. <spsswc:ResultScriptWebPart runat="server"  DataProviderJSON ="{&quot;QueryGroupName&quot;:&quot;Default&quot;,&quot;QueryPropertiesTemplateUrl&quot;:&quot;querygroup://webroot/Pages/Dummysearch.aspx?groupname=Default&quot;,&quot;IgnoreQueryPropertiesTemplateUrl&quot;:false,&quot;SourceID&quot;:&quot;5ce35ddf-d563-4d32-b850-c45760c9a3bf&quot;,&quot;SourceName&quot;:&quot;Product Catalog&quot;,&quot;SourceLevel&quot;:&quot;Ssa&quot;,&quot;CollapseSpecification&quot;:&quot;&quot;,&quot;QueryTemplate&quot;:&quot;{searchboxquery}&quot;,&quot;FallbackSort&...