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

Monday, May 14, 2018

Create New SharePoint Web coping sibling site content


Scenario

There are situations when you need to create duplicate the already created web using same site template, language and site structure. This article will cover how to use PowerShell to create new web, export sibling site and restore on new web. This process is dissected in three sections,
.

Create New Web

The basic PowerShell command to create web is following,


New-SPWeb -url "http://spsite/en-us/ACCOUNTING" -Name "Asset Accounting" 

If you want to use specific template for new web you can write following command,
New-SPWeb -url "http://spsite/en-us/ACCOUNTING" -Name "Asset Accounting" -Template BLANKINTERNET#2

You can find the installed templates from following command,
Get-SPWebTemplate

If you want to use specific template and specific language for new web, you can write following command,
New-SPWeb -url "http://spsite/en-us/ACCOUNTING" -Name "Asset Accounting" -Template BLANKINTERNET#2 -Language 1033
Note: 1033 is for English which is default. If we need to create this for arabic, use 1025.

Export Sibling Site

Following is command for exporting sibling site

Export-SPWeb "http://spsite/en-us/Finance" -Path "c:\firstbackup.bak" 

Import Backup to New Site

Now we have new site and backup of sibling site. We will now restore that backup to newly created web,

Import-SPWeb "http://spsite/en-us/ACCOUNTING" -Path "c:\financeaccount.bak" 

Monday, May 9, 2016

Operation is not valid due to current state of the object -- Elevated Privileges


Exception

ExceptionType=System.InvalidOperationExceptionJSON
Message=Operation is not valid due to the current state of the object.

Cause: 

I tried to call SPUtility.SendEmail within the RunWithElevatedPrivileges delegate.

Comments

If i try to run this method out of Elevated delegate, it works fine. All the other things that are working fine in Elevated Privileges (except send email) are,

  1. SPUtility.GetPrincipalsInGroup
  2. spWeb.EnsureUser

Thursday, February 11, 2016

How to set InfoPath field value on dropdown change event in SharePoint 2010 and 2013

Problem

We have a Dropdown in InfoPath which is populated from external data source (SharePoint List. e.g. TimeSheet List having fields ProjectName, %Complete and Type. Dropdown is showing Project Names). We want to populate infopath field (Type) from SharePoint based on selected Project in dropdown.

Solution

I suppose you have already Filled Dropdown from Timesheet List and or applied filtering if required, If not, you can follow my post How to Filter Infopath Dropdown.

Select the Project dropdown that we created in previous article and from the "Home" ribbon, select Add Rule->This Field Changes -> Set a Field's Value option as shown in the below image.

How to Populate and Filter InfoPath Dropdown Populating from SharePoint List

Problem

We have TimeSheet SharePoint List which has information of all the projects, their status and % Complete. We want to populate dropdown with TimeSheet projects whose status is not closed.

Solution

Populating Dropdown

First Create the List as following,


Now in the InfoPath Designer (It does not matter if it is list template or designing new InfoPath document), Add dropdown list from menu bar,

Sunday, May 17, 2015

Could not load file or assembly ‘$SharePoint.Project.AssemblyFullName$’ or one of its dependencies. The system cannot find the file specified.

There are lot of scenarios where you can face this issue. I will explain scenario which i faced.

Scenario

I have all the solution deployed and running already on the production server. My task was to just change an html link in the .ascx control. I changed the control and rather than deploying whole solution, i copied .ascx control and put it in the 14 hive control templates. I restarted IIS and refreshed page, i found following exception,

Could not load file or assembly ‘$SharePoint.Project.AssemblyFullName$’ or one of its dependencies. The system cannot find the file specified.


Solution

Luckily error was pointing towards the new custom control that i deployed. I opened file and searched for "$SharePoint.Project.AssemblyFullName$". Replace this string with the actual assembly name, version and culture (If you deploy with visual studio, it changes it automatically but as it was manual deployment, i needed to copy control's assembly and replace with the "$SharePoint.Project.AssemblyFullName$"). Restart IIS and problem was solved.

Sunday, September 28, 2014

Opening InfoPath Form in Modal Dialog

Question 


How to open InfoPath New and Edit forms in the Modal dialog?


Answer


Let us start with new fresh InfoPath Library. Create an InfoPath Library and call it "AccordionForms". The path of library would be like,


Let us examine new and edit form URLs.


New InfoPath Form:


If you click on the new item link, it would redirect to URL,


Wednesday, September 24, 2014

Create Info Path Accordion (Show Hide Section)

Previously i worked on the project which used InfoPath form. The Form had many sections and each section had scrolling and lot of data. I needed to introduce accordion in the form. I needed to add buttons to show hide any section of the form so that user can focus on what is required. InfoPath is different than the normal JQuery accordion where you can hide or show any thing based on script or just CSS. In InfoPath you need to add behavior and Rules for each button and section which we want to hide or we want to use as changing behavior or variable. Following is the how i achieved it,
1- First thing first, add two picture buttons (Having up and down pictures).  

2- Add Boolean variable ESShow and set its default value as 0 if you want to hide section when InfoPath form loads otherwise set its default value 1.


Content Editor Web Part Example (Writing Custom Web Part

The Content Editor Web Part (CEWP) allows you to add text, html, JQuery or styles to a SharePoint page. It is great to use this if you,

  1. Are good in JQuery or Javascript.
  2. Want to use Web Services, REST API (Introduced in SharePoint 2013) or ECMA script.
  3. Need One or two pages of customization and do not want to touch Visual Studio and going through process of uploading solutions.
  4. Do not have deployment permissions on Central Administration.

Add a Web Part to a page


1. From a page, in the ribbon, click the Page tab, and then click the Edit command.

Image: Edit command of the Edit tab

Display Parent web InfoPath form in child web InfoPath Form Web part

Problem

Yesterday i faced an issue while displaying Info Path form in the web part. My task was to show the Info Path form in the child web but actual Info Path library was on the parent web. The problem was when i tried to edit the Info Path web part, i could not see the list of Info Path library (from parent web) because it was showing only current site Info Path libraries.

Solution

I added new page in Page/Site Pages library of parent website. I added Info Path web part in the page and copied the Page from parent web to child web. Every thing worked fine in the child web Info Path web part page.

Copy Page to Child Site

Tuesday, September 23, 2014

Copying Web Part Page to same / other list of same web or child web

Problem


There are situations when you want to copy the web part page to same/other list in same web/child web. If you copy the page through SharePoint Designer, it will copy the page but the web parts will be removed.


Solution


Use site Content and Structure.

Procedure

Saturday, February 15, 2014

Setting Jquery UI Auto complete on SharePoint Text Filter

Steps,

1- Add Text Filter and List Web Part on the page.
2- Add connection between text filter and List webpart.
3- Open Notepad, Add following script in the Notepad.
4- Change the controlID variable value to the generated client id of Text Filter textbox.
5- Change the List and column names in the SP Service call.
6- Save the file in Site Asset library.
7- Add Content Editor web part on the page and provide link to the text file placed in the Site asset Library.

Enjoy:)