Pages

Thursday, January 26, 2017

System.NullReferenceException: Object reference not set to an instance of an object when deploying SharePoint 2013 workflow solution

Problem

I was trying to deploy a workflow solution using Visual Studio 2013; when I tried I got an exception as “Error occurred in deployment step 'Activate Features': System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.SharePoint.WorkflowServices.WorkflowSubscriptionStorageEventReceiver.ItemUpdating(SPItemEventProperties properties)”.

Solution

We have to configure Workflow Manager on a server that is part of the SharePoint 2013 farm and on which communication takes place by using HTTP.

  Register-SPWorkflowService -SPSite "http://sharepoint-sp:29375/" -WorkflowHostUri "http://localhost:12291/" -AllowOAuthHttp

Reference

https://technet.microsoft.com/en-us/library/JJ658588.aspx

How to create a SharePoint webpart with custom webpart property/properties

Introduction

Recently one of colleague want to create a webpart for SharePoint using C# as programming language. One of his requirements is to that “user wants to pass values through custom webpart property.” So I created a sample for him.

Solution

Here is the code and also you can download the .sln file from my drive by clicking below URL.
https://drive.google.com/file/d/0ByEnOE8DAdvhLTFtd1oxWS1GNUU/edit?usp=sharing

     
namespace CustomProperty.CustomWebPartProperty
{
    [ToolboxItemAttribute(false)]
    public class CustomWebPartProperty : WebPart
    {
        private string _name = "Suhail";//The default value to display
        [WebBrowsable(true),
        WebDisplayName("Label Text"),//WebPart property display name
        WebDescription("Label Text to appear in Label"),//Property discription
        Category("Custom"),//Custom webpart property catogory
        Personalizable(PersonalizationScope.Shared)]
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }

        }
        protected override void CreateChildControls()
        {
            Label name = new Label();
            name.Text = Name;
            this.Controls.Add(name);

        }
    }
}
 


Conclusion

You can see your custom webpart property at the end of the webpart setting.

When you need values which should be able customize don’t save in web.config file; You may use custom webpart properties.

Tuesday, January 24, 2017

“The attribute 'autoeventwireup' is not allowed in this page” issue in SharePoint 2013

Problem

Recently we deployed two wsp solutions in an environment. One wsp consists of master page and the other one consists of a site page with code behind where I use events like onclick and all.

After the deployment when I try to access the aspx page we got the above error.

Solutions

Solution 1.

Remove the code behind file and create a web part and add the web part in the page.You can see my blog post on how to create site page without code behind.

Solution 2.

Go to Site Settings page, under the Site Action section, click Reset to site definition.

01

Then give your page url and click Reset.

Capture

Check your page.

If its still the same give your master page url (which ends with .master) and repeat the above step.

Now your page should work fine.

Tuesday, January 17, 2017

How to disable client side people picker using JQuery in SharePoint 2013 | SharePoint Online

Problem

I had created SharePoint people picker using the example from msdn in my aspx page. I had to disable people picker through JQuery in order to full fill my client’s requirement.

Solution

According to above mentioned msdn post people picker is initiated on.

  <div id="peoplePickerDiv"></div>

So the id of the div is peoplePickerDiv. So with that I will show the solution.

Step 1:

Create an object of people picker.

  var peoplePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan;

Step 02:

Set Enable state to fasle.

peoplePicker.SetEnabledState(false);

This will disable the people picker. But you can remove the people objects with X sign. So in Step three we have to remove X.

Step 03:

Remove the X image.

$('#peoplePickerDiv_TopSpan_ResolvedList').find('.sp-peoplepicker-delImage').hide();

Conclusion

Now the people picker is disabled.

image


Sunday, January 1, 2017

PowerApps for iPhone

Wishing you a Happy New Year with the hope that you will have many blessings in the year to come.

These days I was looking into PowerApps and I installed PowerApps app from iTunes in order to test PowerApps.

Step 01

Search PowerApps in iTunes and Get It.

IMG_5886

Step 02

Your screen will be looking something like below. Sign in with your Office 365 account.

IMG_5883

IMG_5884

Step 03

Once you login you can see all the apps which you have the permission for.

IMG_5888

Then you can navigate through the apps and can use them.

 IMG_5885

IMG_5889

 

I’m looking forward to write more on PowerApps in upcoming days.

Wednesday, December 28, 2016

Save my email attachments to a SharePoint document library using Microsoft Flow

Introduction

I was trying Microsoft Flow and I thought of sharing how I did my first Flow App using the template provided by Microsoft.

The template I’m using is “Save email attachments to a SharePoint document library”.

Steps

Step 01

Go to https://flow.microsoft.com/en-us/ and find the “Save email attachments to a SharePoint document library” using the search box or by navigating through all template.

MicrosoftFlow1

Step 02

Click on the app and you will get a screen as below. Then you have to select “Use this template” option.

MicrosoftFlow1 (1)

Step 03

Click Sign In and then use your Office 365 username and password.

MicrosoftFlow1 (2)

Step 04

The template will be created for you as below.

MicrosoftFlow1 (3)

 

Step 05

Select Inbox for the folder option. You can select the Inbox by clicking on folder icon.

MicrosoftFlow1 (4)

 

Step 06

Site URL: Provide the SharePoint site URL

Folder Path: Give the name of the document library where you would like to store the attachments.

File name: You can give any dynamic value or static value. Please note that you can’t store two documents in the same name. So please make sure the name is dynamic.

File Content: Select “Content”

MicrosoftFlow1 (5)

Step 07

Click on “Create Flow” from the top.

MicrosoftFlow1 (6)

Conclusion

Send a mail with attachment and check your SharePoint Document library. There you can find the attachments.

image

Tuesday, November 1, 2016

Usage of HTML field security in SharePoint Online and SharePoint 2013

Introduction

HTML field security in SharePoint (Office 365 and SharePoint 2013) controls inserting iframes on the pages of the particular site.

You can go to HTML Field Security by going to Setting Page and under “Site Collection Administration” you can find “HTML Field Security” option.

1

You can edit the page and select “Edit Source” from the ribbon in order to add iframe into a page.
3
Options

There are three options
2

Option 1. Do not permit contributors to insert iframes from external domains into pages on this site.

This blocks the contributors from adding iframes from external domains. When the users try to add an iframe through edit form they will get a notification saying “Warning: Some of your markup was stripped out. Try using the Embed command.”
4
Option 2. Permit contributors to insert iframes from any external domain into pages on this site.
This option will lead the contributors to add iframes from any domain.
Option 3. Permit contributors to insert iframes from the following list of external domains into pages on this site: Allow iframes from this domain:
The contributors can add iframes from the domain given in the area. And also the subdomains of the given domain are trusted.

So this is how we use the HTML field security in SharePoint. But again let’s discuss some scenarios on HTML field security.

Scenario 01.

In the setting, Option 1 is selected and can I add an iframe to the page?

Yes you can. Add the iframe through “Script Editor” web part. Edit the page, go to insert and click “Embed Code”.
4
Scenario 02.

What will happen to the exiting iframes if the Option is set to 3?
Nothing will happen to the exiting iframes. It will continue to work.

Scenario 03.

What will happen to sub sites?

The setting in the site collection level will be applied to sub sites as well.