Check authorization rules if the sharepoint central admin prompts even if you give correct credentials to open

This is a silly issue we face related to athorization. sometime we cannot login into any sharepoint site with correct credentials also.

Please check authorization rules in IIS.

Step 1: Open the IIS and go to the site authorization rules as shown below.

Autho1

Step 2: If there is no rules available. Click on Allow Rule from the right side pane as shown below:

Autho2

Now you can able to browse without any issues.

Posted in Common | Tagged , | Leave a comment

Easy way to Check in Multiple SharePoint files inside multiple folders

When we have folder structure inside a document library, it is difficult to check all the files at single time. because it shows all the folder instead of files to users, by default SharePoint takes the items(folders) to check in without the items inside it. There is a very nice way to achieve this by creating another view. so that views can be switched whenever the users wants to check in multiple files. Here is the way:

Step 1: Go to document Library. Create a new view:

Documents1

Documents2

Step 2: Create standard View:

Documents3

Step 3: Give a unique name to the view:

Documents4

Step 4: Scroll down and give the folders filter as shown below and then save it.

Documents5

Step 5: Now you can switch the view to find all the items without folder:

Documents6

Step 6: Now all multiple files can be checked in without any issues inside  folders:

Documents7

Posted in SharePoint | Tagged , , , | 31 Comments

Pass Querystring value from SharePoint Page to App Part(Client web part)

As we know an App Part generates an Iframe when it is added into a SharePoint page, so we face difficulty to pass query string value from page to app part.

Here is the simple way to handle this. Using below information we can pass information from SharePoint page/webpart to our app part.

Step 1: 

In your App part go to element.xml file and add one dummy property which you only be using to pass Query string values. Keep Property name same as Query String Name as shown below:

AppProperty

Step 2: On your page where you have added App part, add a script editor or content editor web part just below the app part and add below script:

<script>
var arrFrames = document.getElementsByTagName(“iframe”);
for(i = 0; i< arrFrames.length; i++)
{
var iFrame=arrFrames[i];
var clientID=”QueryStringIDValue”;
if(iFrame.src.indexOf(clientID) != -1)
{
alert();
var queryStringValue=getQuerystring(‘QueryStringID’);
if(queryStringValue != null)
{
iFrame.src=iFrame.src.replace(clientID,queryStringValue);
}
}
}

function getQuerystring(key)

{
key = key.replace(/[\[]/,”\\\[“).replace(/[\]]/,”\\\]”);
var regex = new RegExp(“[\\?&]”+key+”=([^&#]*)”);
var qs = regex.exec(window.location.href);
if(qs == null)
return null;
else
return qs[1];
}

</script>

Above code will find out all the iframes and see where the QueryStringIDValue exists on scr of each Iframe as shown in below figure and replace with QueryString value of the page:

Here is the iframe generated by the app part from the page view source:

IframeViewPage

Our JavaScript will replace the property value with the query string value and the query string value can be used within app page load.

Happy Coding!!!

Posted in SharePoint | Tagged , , , , | 9 Comments

Upload large size documents using Client side object model(SharePoint Office 365 online)

SharePoint 2013 Auto hosted Apps:

When you create a SharePoint app and try to upload a large size document through client side object model, you face some issue related to maximum size limit.

You try below code which works for me:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.Client;
using COM = Microsoft.SharePoint.Client;
using System.Data;
using System.IO;
using System.Web.UI.HtmlControls;
using System.Net;

namespace TestMSWeb.Pages
{

public partial class test : System.Web.UI.Page
{
SharePointContextToken contextToken;
string accessToken;
Uri sharepointUrl;
COM.Web web = null;
COM.ClientContext clientContext = null;

protected void Page_Load(object sender, EventArgs e)
{
TokenHelper.TrustAllCertificates();
string contextTokenString = TokenHelper.GetContextTokenFromRequest(Request);

if (contextTokenString != null)
{
contextToken =
TokenHelper.ReadAndValidateContextToken(contextTokenString, Request.Url.Authority);

sharepointUrl = new Uri(Request.QueryString[“SPHostUrl”]);
accessToken =
TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;
ViewState[“AccessToken”] = accessToken;
// btnProcessData.CommandArgument = accessToken;

}
else if (!IsPostBack)
{
Response.Write(“Could not find a context token.”);
return;
}

if (IsPostBack)
{
sharepointUrl = new Uri(Request.QueryString[“SPHostUrl”]);
accessToken = ViewState[“AccessToken”].ToString();
}
clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accessToken);
web = clientContext.Web;
clientContext.Load(web);
clientContext.ExecuteQuery();

}

protected void UploadAttachements()
{

//upload proposal documents

List documentsList = clientContext.Web.Lists.GetByTitle(“Documents”);

clientContext.Load(documentsList);

if (attachproposalDoc.PostedFile != null && attachproposalDoc.PostedFile.FileName != string.Empty)
{
using (var stream = attachproposalDoc.PostedFile.InputStream)
{
var fileCreationInformation = new FileCreationInformation();
//Assign to content byte[] i.e. documentStream

fileCreationInformation.ContentStream = stream;
//Allow owerwrite of document

fileCreationInformation.Overwrite = true;
//Upload URL
string[] strArray=attachproposalDoc.PostedFile.FileName.Split(‘\\’);
fileCreationInformation.Url = “ProposalDoc_” + strArray[strArray.Length-1];
Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(fileCreationInformation);

clientContext.ExecuteQuery();

uploadFile.ListItemAllFields[“Title”] = attachproposalDoc.PostedFile.FileName;

uploadFile.ListItemAllFields.Update();
clientContext.ExecuteQuery();
}

}

}

protected void testBtn_Click(object sender, EventArgs e)
{
UploadAttachements();

}

}
}

Update Web.Config Entries of your App:
replace your <httpRuntime> tag with below line:
<httpRuntime targetFramework=”4.5″ executionTimeout=”999999″ maxRequestLength=”2097151″ />
Posted in SharePoint | Tagged , , , | 2 Comments

To check SharePoint version of sharepoint site as end user

 

Example : https://www.sharepoint.com/_vti_pvt/buildversion.cnf

If it starts with 15 : Sharepoint 2013

14: Sharepoint 2010

12: Sharepoint 2007

02

Posted in SharePoint | Leave a comment

How to add multiple hyperlinks to a Custom workflow Task form

We populate the task form values from a custom workflow by ItemMetadata.xml which is a secondary data source.
It is easy to show single hyperlink by using hyperlink field as shown below:

  •   Go to Insert tab and click on Hyperlink to insert the field on your form:

1

  • Choose secondary data source field value for link and display text

2

3

  •  Now your hyperlink is linked to secondary data source field value.

4

  •   Hyperlink text and link can be populated from workflow code like below:

5

Note: createTask_DecissionMaker_TaskProperties1 is workflow task property

Multiple Hyperlinks:

In case of multiple links, it is difficult to handle through Hyperlink field. We need to use Rich Text Box

  •  Add Rich Text box from the control list:

6

  • Set the display text and the value from its property window:

7

8

9

  • Click on insert field or group and choose the appropriate field from secondary data source:

10

11

  •  Make the field read only from the display tab:

12

  •  Also set the border and shading to none:

13

14

Now our Rich text Box ready to show any HTML content which need to be passed from workflow code as shown below:

15

Issue with the above code:

Rich text box control will consider the above value as inner Text instead of Inner HTML as shown in below image:16

To solve the above problem, we need to write custom code which will add the above value as inner HTML.

Follow below steps:

Step1. Enable VSTA for Info path 2010.

  •  Go to Control panel and click on programs and features. Select Office 2010 and click on Change

17

  •   Select “Add or Remove feature” and continue

18

  •  Select visual studio tool for application and click on Continue which will enable VSTA for info path forms

19

Step 2: Set language on Info path form and build the solution

  •  Open Info path form and navigate to Programming tab. Select the language to C#

20

  • Click on loading event to get your visual studio open and write below code

public void FormEvents_Loading(object sender, LoadingEventArgs e)

{

// Write your code here.

 

try

{

XPathNavigator secondaryDataSourceItemMetadata = this.DataSources[“ItemMetadata”].CreateNavigator();

secondaryDataSourceItemMetadata.MoveToFirstChild();

string richTextBoxContents = secondaryDataSourceItemMetadata.GetAttribute(“ows_RichTextBoxContents”, “”);

XPathNavigator mainDataSource = this.MainDataSource.CreateNavigator();

mainDataSource = mainDataSource.SelectSingleNode(“/my:myFields/my:RichTextBox”, NamespaceManager);

mainDataSource.InnerXml = richTextBoxContents;

}

catch (Exception ex)

{

}

}

Note: By default it creates a project under below path:C:\Users\<UserName>\Documents\InfoPath Projects

Step 3: Deploy the DLL to same folder where info path form is deployed.

  •  Add the DLL as an element to the module and make sure the deployment location and deployment Type as per below screen:

21

Step 4: Publish the info path form:

  •  Go to file menu of the info path form. Under Info section click on form option to change the security to Full trust:

22

23

  •  Go to publish section and publish it to Network Location.

24

The published InfoPath form deployed as part of SharePoint package.

Note: the steps for the Info path deployment through Visual studio is not described here

Step 5:

Run the Workflow code and deploy and you will find the multiple hyperlinks on your page:

25

 

Happy Coding….

Posted in SharePoint | Tagged , , , | Leave a comment