Showing posts with label SharePoint 2013. Show all posts
Showing posts with label SharePoint 2013. Show all posts

Wednesday, 23 July 2014

Link multiple EditForms or DisplayForms to a sharepoint list

My listitems are opened via an infopath form. Client wants a second aspx form to open the listitems.
(the infopath form only shows a subset of the fields but the aspx form shows all fields).

When opening the aspx form, sharepoint redirects me to the infopath form. Somewhere, a redirect was taking place.
After a lot experimenting, I found that not only do you need hide the original List Form Web Part but you also need to set the ControlMode to Display. Here are the 2 lines of code that need to be modified in the original List Form Web Part:
Change:
<ControlMode xmlns=”http://schemas.microsoft.com/WebPart/v2/ListForm”&gt;Edit</ControlMode>
To:
<ControlMode xmlns=”http://schemas.microsoft.com/WebPart/v2/ListForm”&gt;Display</ControlMode>
Change:
<IsVisible>true</IsVisible>
To:
<IsVisible>false</IsVisible>

Monday, 16 June 2014

SharePoint 2013 Chrome Control Options

Looking through SP.UI.Controls.Debug.js, here are the options:

siteTitle

siteUrl

clientTag

appWebUrl

onCssLoaded

assetId

appStartPage

rightToLeft

appTitle

appIconUrl

appTitleIconUrl

appHelpPageUrl

appHelpPageOnClick

settingsLinks

language

bottomHeaderVisible

topHeaderVisible

Friday, 13 June 2014

Get List Field Internal Name

You can get the internal name for a column by browsing to the List Settings > Edit Column and look at the QueryString. This will be url encoded but is a simple way of retrieving the internal name without writing any code. You will get something like: /_layouts/FldEdit.aspx?List=%7B37920121%2D19B2%2D4C77%2D92FF%2D8B3E07853114%7D&Field=Product%5Fx0020%5FDescription %5F is a '_'. The field name is Product_x0020_Description. The code option is to use: string itemInternalName = item.Fields["Field Display Name"].InternalName;

Thursday, 12 June 2014

Different ways to get user name using javascript

Get user email

_spPageContextInfo.userLoginName

Using REST Service

 $(document).ready(function () {  
 var userid = _spPageContextInfo.userId;  
 function GetCurrentUser() {  
 var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";  
 var requestHeaders = { "accept" : "application/json;odata=verbose" };  
 $.ajax({  
  url : requestUri,  
  contentType : "application/json;odata=verbose",  
  headers : requestHeaders,  
  success : onSuccess,  
  error : onError  
 });  
 }  
 function onSuccess(data, request){  
  //var loginName = data.d.LoginName.split('|')[1];  
  var loginName = data.d.Title; 
  alert(loginName);  
 }  
 function onError(error) {  
  alert(error);  
 }  
 GetCurrentUser();  
 });  

Using JSOM

 $(document).ready(function () {   
 var currentUser;  
 // Ensure that the SP.js is loaded  
 if (SP.ClientContext != null) {  
  SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser, 'SP.js');  
 }  
 else {  
  SP.SOD.executeFunc('sp.js', null, getCurrentUser);  
 }  
 function getCurrentUser() {  
  var context = new SP.ClientContext.get_current();  
  var web = context.get_web();  
  currentUser = web.get_currentUser();  
  context.load(currentUser);  
  context.executeQueryAsync(onSuccessMethod, onRequestFail);  
 }  
 function onSuccessMethod(sender, args) {  
  var account = currentUser.get_loginName();  
  var currentUserAccount = account.substring(account.indexOf("|") + 1);  
  alert(currentUserAccount);  
 }  
 // This function runs if the executeQueryAsync call fails.  
 function onRequestFail(sender, args) {  
  alert('request failed' + args.get_message() + '\n' + args.get_stackTrace());  
 }  
 });  

Thursday, 1 May 2014

SharePoint Search REST API not returning all subsites

This query is not working !!! I have 10 subsites, but it only returns 2 of them.
https://serverURL/_api/search/query?querytext='path:"*********"  contentclass:STS_Web'&rowlimit=20

Solution is to add &trimduplicates=false at the end of the query.
https://serverURL/_api/search/query?querytext='path:"*********"  contentclass:STS_Web'&rowlimit=20&trimduplicates=false




SharePoint Designer Cache Locations

  • %APPDATA%\Microsoft\Web Server Extensions\Cache
  • %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache

Monday, 2 December 2013

SharePoint 2013: Error Creating Web Application in SharePoint 2013

I recently ran into an issue when creating a new sharepoint 2013 web application. After couple of minutes the dialog box displayed "Internet Explorer cannot display the webpage".  I waited another couple of minutes and I found that the web app is actually created in Central Administration. However, when I ​looked in the Virtual Directory I noticed there was nothing in the folder for my newly created port. 
I think it might be a timing out issue and took these steps to solve the problem
  1. Open IIS Manager and select Application Pools
  2. On the right hand side of the window click Select Application Pool Defaults...
  3. Change the following 3 Process Model time settings
    1. Ping Maximum Response Time
    2. Shutdown Time Limit
    3. Startup Time Limit
      1. I changed all of these from 90 to 900
  4. Do an iis reset

Wednesday, 20 November 2013

SharePoint 2013: addanapp page only shows 3 buttons [addanapp page is broken]

It is a bug in the designer manager, you experience this bug if you use the designer manager to create a master page.
The image below shows the correct addanapp page. If the bug happens, you will not be able to see the buttons in the red circle.





















To fix this, add the following code to your custom.master file.

  <SharePoint:AjaxDelta id="DeltaPlaceHolderPageTitleInTitleArea" runat="server">  
  <asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server">  
  <SharePoint:SPTitleBreadcrumb  
    runat="server"  
    RenderCurrentNodeAsLink="true"  
    SiteMapProvider="SPContentMapProvider"  
    CentralAdminSiteMapProvider="SPXmlAdminContentMapProvider">  
  <PATHSEPARATORTEMPLATE>  
   <SharePoint:ClusteredDirectionalSeparatorArrow runat="server" />  
  </PATHSEPARATORTEMPLATE>  
   </SharePoint:SPTitleBreadcrumb>  
  </asp:ContentPlaceHolder>  
  </SharePoint:AjaxDelta>  
  <SharePoint:AjaxDelta BlockElement="true" id="DeltaPlaceHolderPageDescription" CssClass="ms-displayInlineBlock ms-normalWrap" runat="server">  
  <a href="javascript:;" id="ms-pageDescriptionDiv" style="display:none;">  
   <span id="ms-pageDescriptionImage">&#160;</span>  
  </a>  
  <span class="ms-accessible" id="ms-pageDescription">  
   <asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat="server" />  
  </span>  
  <SharePoint:ScriptBlock runat="server">  
   _spBodyOnLoadFunctionNames.push("setupPageDescriptionCallout");  
  </SharePoint:ScriptBlock>  
  </SharePoint:AjaxDelta>  


I added it inside the pageTitle
<h1 id="pageTitle" class="ms-core-pageTitle"> I added it here </h1>

Sunday, 17 November 2013

SharePoint 2013: Where is my dll?

Starting from .NET 4.0, there is a new ‘GAC’ folder “c:\windows\microsoft.net\assembly“.