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

Monday, December 22, 2014

Automate Deployments with PowerShell

I created and enhanced some PowerShell script code snippets for the purpose of fully automating any given SharePoint .WSP artifact deployment

Usual steps for a clean SharePoint deployment as follows:

DisableSPFeature(Disable-SPFeature cmdlet)

Disables a SharePoint Feature at the given scope. If the scope of the Feature is the farm, the URL is not needed. Otherwise, provide the URL at which this Feature is to be deactivated.

clip_image001

Usage: DisableSPFeature($CRMWebPartsFeatureId, $False)

UninstallSPFeature(Uninstall-SPFeature cmdlet)

Removes the specified feature definition from the collection of feature definitions in the farm.

clip_image002

Usage: UninstallSPFeature($CRMWebPartsFeatureId)

UninstallSPSolution($CRMWebPartsSolutionName, $False)

Retracts a deployed SharePoint solution.

clip_image003

Usage: UninstallSPSolution($CRMWebPartsSolutionName, $False)

RemoveSPSolution(Remove-SPSolution cmdlet)

Removes a SharePoint solution from a farm.

clip_image004

Usage: RemoveSPSolution($CRMWebPartsSolutionName)

AddSPSolution(Add-SPSolution cmdlet)

Adds a SharePoint solution package to the farm.

clip_image005

Usage: AddSPSolution($CRMWebPartsSolutionPath)

InstallSPSolution(Install-SPSolution cmdlet)

Deploys an installed SharePoint solution in the farm.

clip_image006

Usage: InstallSPSolution($CRMWebPartsSolutionName, $False)

EnableSPFeature(Enable-SPFeature cmdlet)

Enables an installed SharePoint Feature at the given scope.

clip_image007

Usage: EnableSPFeature($CRMWebPartsFeatureId, $False)

WaitForJobTimerToFinish (The Get-SPTimerJob & Start-Sleep cmdlet)

Reads a specified timer job, timer jobs of a specified type, or timer jobs defined for a specified scope. If no parameters are specified, this returns all timer job definitions for the farm. We will validate the state of the job in a while loop until null (finished) returned. Otherwise suspends the activity in a script or session for the specified period of time in our case 2 seconds.

clip_image008

Usage: WaitForJobToFinish

Please find the fully deployment script. Modify as need to fit your deployment.

Thursday, January 30, 2014

SharePoint Design Workflow: Issue with workflow content type

While I was working with a client, we stumbled across this issue.
They have this request to add/modify existing SharePoint designer workflow task form with new fields. Simple change!
But came across these 2 issues and how I solved it.

Issue: Field Update
Update the form fields (As required)
 
No reflection in InfoPath form

Even after force updated from CT, still no success.

To Fix Field updates:
Remove/rename/delete away the form from workflow

Re-update the CT from Workflow which will generate the new form & fix the issue.

Issue: CT Unable to show up in the task form
While updating the task form for the user collection activity, you will see blank & CT updated with no custom fields

To Fix CT not showing in the form:
Proceed with adding back fields, (here you need to know previous fields, you can track back from previous task forms)

Delete away the existing InfoPath form for that CT

Publish the workflow. Will fix the CT & form.

Tuesday, September 17, 2013

Navigation Link Modal Popup – Add new item with JavaScript

It's cumbersome for user to add new item in a list, which grown huge, he/she need to scroll all the way to get the "+ Add new item" Option and not only that, the user need to navigate to that specific list in order to perform this task.

And I know you all going to say, hey, how about add that as a navigation link. Well, adding the navigation link just give you a quicker way to launch the list but not the "add new item" option. And as you know adding any JavaScript in navigation will fail with below error!

clip_image001

Fix:

Navigate to the quick launch http://<server/site>/_layouts/quiklnch.aspx

Add new like with web address as

"javascript:OpenPopUpPage('<listname>/NewForm.aspx?RootFolder=&IsDlg=1');"

clip_image002

Thursday, October 11, 2012

2nd Popup Issue In SharePoint 2010 Visual Web Part (With Ajax Update Panel)

I need to popup an alert for the user 2 times based on his/her option picked.
 
Business scenario:
If user choose to deleting a master record, 1st popup and alert the user his/her action.
And if (s)he choose to delete, now I have to find if any child records effecting, if so, not to delete the main record but alert the user again for further action.

This is how I solved it: With the help of JavaScript and Server events.
Added two delete buttons on webpart designer
  1. Main Delete:
                   <asp:Button ID="btnDelete" runat="server" Text="Delete" Width="100px" OnClientClick="if(confirm('Are you sure you want to delete this saved record?')==true)return true;else return false;" CausesValidation="false" onclick="btnDelete_Click" class="ms-ButtonHeightWidth" ChildrenAsTriggers="true"/>            
 2. Hidden Delete: (using style to hide)
                        <asp:Button ID="btnDeleteConfirm" runat="server" Text="DeleteConf" Width="100px" CausesValidation="false" onclick="btnDeleteConfirm_Click" class="ms-ButtonHeightWidth" style="display:none" />
 
OnClientClick event of the Main delete button prompt for 1st initial popup. Once he/she choose to say YES, onclick="btnDelete_Click" will fire as coded in javascript function.
Now in the btnDelete_Click event if I find any child records (I am using entity framwork here) I will register and call ConfirmDelete()

protected void btnDelete_Click(object sender, EventArgs e) {
.
.
if(entityList.Count > 0)
{
   RegisterPopupScript();
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "PopupDelete", "ConfirmDelete();", true);
}else
{MasterSalesRepService.Delete(Convert.ToInt32(lblSalesRepId.Text));
RedirectPage();
}
}

private void RegisterPopupScript()
        {
            Type type =
this.GetType();
            if (Page.ClientScript.IsStartupScriptRegistered(type, "
PopupScript"))           
               
return;
                       
            System.Text.
StringBuilder script = new System.Text.StringBuilder();
script.Append("<script language=\"javascript\" type=\"text/javascript\">\n");
script.Append("function ConfirmDelete(){if(confirm('Do you want to delete child record(s) as well?')==true) return document.getElementById('" + btnDeleteConfirm.ClientID + "').click(); else  return false; }");
script.Append("
</script >");                      
           
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "PopupScript", script.ToString(), false);          
        } 

protected void btnDeleteConfirm_Click(object sender, EventArgs e)
        {
            DeleteXrefSalesRep();
            DeleteMasterSalesRep();
            RedirectPage();
        }

In the script I will fire "btnDeleteConfirm_Click" only if user proceed other wise I won't
Note: I won't delete main record as well as child record if user cancels the action as you see from my btnDelete_Click code.

Tuesday, October 9, 2012

Attaching & Debugging to a specific w3wp.exe

Very common thing we developers do or run into is attaching all the w3wp.exe process while debugging.

Simply because we don't know which service a/c or IIS process to be attached while debugging.
Now in my case, as shown below I have to confirm (7 times) attachment of process, right! That's another fold to the debugging process.

 














Save the grief by use this little script to know your exact web application and attach to it irrespective of service A/C.
 
@ECHO OFF
cls
c:\Windows\System32\inetsrv\appcmd list wp

Save the above as wp.bat and store in C:\windows\system32 folder, I am choosing this because the path already added to the Environmental variable's path, which means now I can call this file from any command prompt path/folder location.

I will be invoking the script from H:\> by typing "wp" and enter.
Results shown as below & In my case I will be only attaching to 9044.

Happy debugging!

Wednesday, March 16, 2011

Customizing the Access Denied Message (AccessDenied.aspx)

Request from client to customize the default access denied error message!!
By Default:

After Customizing the accessdenied.aspx page:
Note: If you want to be more fancy, you can replace the simple.master page with your own master page!














Parts been customizable as show:















Achieved by modifying 2 files


1. SharePoint resource file wss.en-US.resx (from Virtual Directory \App_GlobalResources\wss.en-US.resx)







2. AccessDenied.aspx (from C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS)


Note: Please keep the Original file as a backup
















CSS:
<style type="text/css" >

BODY #s4-simple-card H1 {margin-bottom:10px; color:#5b4b3e ; font-size:2em; font-weight:normal;padding-top:3px}

.ms-sectionheader {font-family: Verdana, Arial, sans-serif; color:#595959; font-size:2em }

.ms-descriptiontext {text-align:left; font-family:Verdana, Arial, sans-serif; color:#3f3f3f;font-size:10pt}
A:link, .ms-descriptiontext A:visited, .ms-descriptiontext A:hover { color:#0072BC; font-weight:bold; text-decoration:none; }
.s4-simple-iconcont { z-index:2; background-image: url('/_layouts/images/setcredentials_32x32.png'); HEIGHT: 60px; TOP: 10px;
background-position:left center; background-repeat: no-repeat; }
.s4-simple-iconcont img {display:none;}

</style >

Monday, March 7, 2011

How to Control Hyper Link Attributes to Open In a New Window

Wondering how to control the Hyper Link control behavior! Like STYLE, OPEN , SET FOCUS & ATTRIBUTES

Current project requirement to open the Hyper link with specific browser attributes like With Scroll bar, No Menu bar, Specific Window Position, Height & Width.

Achieved with Java Script as shown below code:

string strURL = "http://rajadandu.blogspot.com/";

//Create Hyper Link
HyperLink h = (HyperLink)e.Row.FindControl("ConfHlink");

// Setting Style
h.Style["margin-left"] = "5px";

//Setting default Hyper Link Navigation to NULL
h.NavigateUrl = "javascript:void(null);";

//Hyper Link Display string
h.Text = "Opening With Controlled Hyper Link";

//Java Script with Open Window with attributes
//Then at last Set Focus
h.Attributes["onclick"] = "javascript:window.open('" + strURL + "','','scrollbars=yes,menubar=no,height=430,width=700,top=0,left=0,resizable=yes,toolbar=no,location=no,status=no'); window.focus();";

Thursday, March 3, 2011

Open PDF makes you save!!

After few Hrs of research find out that this particular setting will now open’s .PDF directly in IE; by default is “Strict” which prompts the user for file download.

Step-By-Step:
You can fix this by navigating in to central admin


Application Management >> Manage web application

Now choose your web application (select the row) which makes ribbon to be active

and you will see general settings (in enabled mode) Now choose general settings from the drop down

find he Browser File Handling section by default it's strict, change it to Permissive click ok and you are done!!

Tuesday, December 28, 2010

Remove Title Header from Webpart

Add this stylesheet elements to the page by using content editor webpart

<style type="text/css">
.ms-viewheadertr {
 DISPLAY: none
}
.ms-vhltr {
 DISPLAY: none
}
</style>

Before:





After:

Friday, December 17, 2010

People Search WebPart Small Font Fix

Here is the CSS to add by throwing the content editor web part or through attaching your own custom style sheet
.s4-search INPUT.ms-sbplain
{
border-bottom: #e3e3e3 1px solid;
border-left: #e3e3e3 1px solid;
padding-bottom: 0px;
padding-left: 3px;
width: 191px !important;
padding-right: 3px;
background: url(/_layouts/images/bgximg.png) #fff repeat-x 0px -511px;
height: 17px;
font-size: 13px;border-top: #e3e3e3 1px solid;
border-right: #e3e3e3 1px solid;
padding-top: 2px;
}
 Before



After







Note: If you just grab and implement font-size, SharePoint always try to over write with default search style sheet

Wednesday, November 24, 2010

SharePoint 2007 to 2010 Migration

1. Run the preupgradecheck
psexec \\SP2007Server -u domain\UserID -p yourPWD -s stsadm -o preupgradecheck
Note: I used psexec sysinternal tool, felt easy working from my Pc rather than RDPing to the server

2. Based on Above check we have 2 options out of 4 options

1. In-place upgrade
○ Use existing hardware – servers/farm offline during upgrade
○ Configuration and all content upgraded
○ Farm-wide settings preserved
○ Customizations available after upgrade
○ Recommended for small or non-production environments

2. Database Attach upgrade
○ New hardware
○ Upgrade multiple DBs at a time
○ Server farm settings not upgraded
○ Customizations must be transferred
○ Can consolidate multiple farms into one
○ Recommended if farm level configurations are minimal

3. Hybrid 1: Read-Only Database upgrade
○ Use Database Attach upgrade to preserve existing farm
○ Existing farm is put in read-only mode
○ Create a new farm and attach all content databases
○ Server farm settings not upgraded
○ Recommended over Database Attach

4. Hybrid 2: Detach Database upgrade
○ Use in-place upgrade for farm settings to preserve configurations
○ Detach and upgrade content databases
○ Alternatively, upgrade content databases in a temporary farm
○ Recommended if farm level configurations are significant

3. Pre Upgrade check will give you possible options for you to migrate, I choose Content Database Attach.

4. Identifying the .WSP files to be removed, Clean up your current 2007 environment before you migrate, so that you have less things to worry.

a. Used Bamboo SharePoint Analyzer http://community.bamboosolutions.com/blogs/bambooteamblog/archive/2008/11/06/introducing-bamboo-sharepoint-analyzer.aspx Choose where solution is used Option. To Identify Solutions and Features that have been deployed, displayed per Web App, Site Collection or Site scope
Now they even have client version, so you can run from your local PC.

5. Downloaded the STSADM Extender for automating the deleting away the unwanted web parts
Please Install the http://stsadm.blogspot.com/2007/10/set-web-part-state.html STSADM Extended commands to strip the web parts from the pages.
 
Download from:
SharePoint 2007 STSADM Extension WSP Files (SP2 is Recommended)
MOSS Only STSADM Extensions (x86, x64)
To install for the first time run the following commands (make sure you are in the directory where you downloaded the file):

stsadm -o addsolution -filename Lapointe.SharePoint.STSADM.Commands.wsp

stsadm -o deploysolution -name Lapointe.SharePoint.STSADM.Commands.wsp -immediate -allowgacdeployment

stsadm -o execadmsvcjobs


6. Stsadm -o gl-setwebpartstate -url "http://SP2007Server/default.aspx" -title "Un wanter WP Title like custom Events" -delete -publishUse the Excel sheet to generate the script for us.
You need Primarily 2 main fields Web Page & Display Web Part You get these 2 values from Bamboo Analyzer.
Formula to get script =CONCATENATE("stsadm -o gl-setwebpartstate -url """,[@[Web Page]],""" -title """,[@[Display Web Part]], """ -delete -publish")OR
Manually Strip web parts:
Find the pages then add the ?contents=1 to go to Manage Web part Page; then remove away the web parts & checked in those are checked out by other user(s) Note: Make sure you check out the Page.

7. Taking DB Offline on 2007 Env.
a. STSADM -o deletecontentdb –url "http://SP2007Server/" -databasename "WSS_Content" -databaseserver "SP\SHAREPOINT"

b. USE master
Go
ALTER DATABASE WSS_Content SET OFFLINE WITH
ROLLBACK AFTER 60 SECONDS

c. USE [master]
GO
EXEC master.dbo.sp_detach_db @dbname = N'WSS_Content',
@keepfulltextindexfile = N'true'
GO
8. My assumption is that you already have or created a new web application and site collection
Taking DB Offline on 2010 Env. (newly created site collection)
a. STSADM -o deletecontentdb –url "http://SP2010Server/" -databasename "WSS_Content_SP2010" -databaseserver "SP\SHAREPOINT"

b. USE [master]
GO
EXEC master.dbo.sp_attach_db @dbname = N'WSS_Content',
@filename1 =N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SHAREPOINT\MSSQL\DATA\SP2007\WSS_Content.mdf'
Note: You can user SQL Manager for attaching the DB, easy too!

c. Run Powershell script
i. Test-SPContentDatabase –name WSS_Content –WebApplication http://SP2010Server

For further identifying the migration issues you may encounter when you attach.

ii. New-SPContentDatabase -Name WSS_Content -WebApplication http://SP2010Server

Thursday, November 18, 2010

Theme Builder for SharePoint 2010

Thinking to creating a cool theme for your site...then download the theme builder from Microsoft http://connect.microsoft.com/ThemeBuilder and you can create cool gradient theme in no time.

Text/Background- Dark 1:
• Page Title Hyperlink Text
• Hover Text
• VB Body Text
• Site Action Menu Text
• Left Navigation Links Text
• Site Setting Page Text Headers
Text/Background - Light 1:
• Body Background
• Toolbar Background
• Quick Launch Borders
• Web Part Header Background
• Site Action Menu Background
• Site Action/Welcome Text Color
• Pop-Up Window Background
Text/Background - Dark 2:
• Top Banner Background
• Left Navigation Header Text
• Recycle Bin/View All Site Content Text
• I Like/Tags Notes Text
• Library Column Text
• Site Action Drop Down Border
• Breadcrumb Current Location Text
• List Description Text
Text/Background - Light 2:
• Browse Tab and hover Background
• Title Container Background
• Top Links/Header 2 Background
• Quick Launch Background
• Web Part Adder Background
Accent 1:
• Quick Launch Hover Text
• Top Link Selected Tab
Accent 2:
• .ms-error
• Rich Text Colored Heading 2 Text Styles
Accent 3:
• Rich Text “Caption” Style Text Color
Accent 4:
• Border Under Web Part Selector
Accent 5:
• Rich Text Colored Heading 4 Text Styles
Accent 6:
• Rich Text Highlight background color
Hyperlink:
• Toolbar Text Color
• VB Body Hyperlink Text
• a:link Class Text Color
Followed Hyperlink:
• .ms-WPBody a:visited

Wednesday, November 10, 2010

Make Links Open In New Window

Well we know, when you add a link to your SharePoint navigation or in a Summary Link Web Part, it gives you the option to "Open link in new window" But when comes to a standard Links list, doesn't give you this option.

Here is The Script to open the link in a new window: (Content Editor web part, or even added to your master page.)

<script language="javascript" type="text/javascript" >

function MakeLinksOpenInNewWindow(){

var tbl = document.getElementsByTagName('table');
for(var i = 0; i < tbl.length; i++)
{
if(tbl[i].getAttribute("summary") == "Links Use the Links list for links to Web pages that your team members will find interesting or useful.")
{
var anc = tbl[i].getElementsByTagName('a');
for(var j = 0; j < anc.length; j++)
{
anc[j].setAttribute('target', '_blank');
}
}
}

}

_spBodyOnLoadFunctionNames.push("MakeLinksOpenInNewWindow");
</script >

Note: You can modify default Summary attribute by editing Links >> List Settings >> General Settings {Title, description and navigation} Description field of that Links list.
Also note that Summary attribute constructed with combination of Name + Description of the List

Friday, October 15, 2010

A Blank, White Web Page Is Displayed in IE

Make sure that LOOPBACK CHECK is disabled, To disable the loopback check. follow these steps:

1. Click Start, click Run, type regedit, and then click OK.
2. In Registry Editor, locate and then click the following registry key:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
3. Right-click Lsa, point to New, and then click DWORD Value.
4. Type DisableLoopbackCheck, and then press ENTER.
5. Right-click DisableLoopbackCheck, and then click Modify.
6. In the Value data box, type 1, and then click OK.
7. Quit Registry Editor, and then restart your computer.

Note: This also helps in fixing calling custom web services in InfoPath form which returns with null/no data

Thursday, October 14, 2010

Web Part Page Maintenance

All I know was use my book marked Manage Web Part Page URL from my IE favorites to bring up maintenance page to fix the web part.

http://<site>/_layouts/spcontnt.aspx?&url=default.aspx

by change the site and url parameter.

But lately found out that if you add the ?contents=1 to your page at the end, system will build the manage webpart maintenance page!! How cool is that?

Tuesday, October 12, 2010

SharePoint 2010 Installation on Windows 7

Fallow this great link http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx
But you need to skip few things:
1. Step 2: Install the Prerequisites for SharePoint 2010: No need to extract etc. once you have your .ISO
Add the following line inside the tag under files\Setup\config.xml


2. Step 3: Install SharePoint 2010: Skip Install SQL Server 2008 KB 970315 x64 if you already have SQL Server 2008. (this will install SQL Express DB Instance "SHAREPOINT")

Note:
1. While Installing SQL Server 2008, Create SQL Instance as "SHAREPOINT"
2. Install right through .ISO file , no need to download single compressed executable file named SharePointFoundation.exe for SharePoint Foundation 2010 and setup.exe for SharePoint Server 2010.
3. Try to avoid installing 64bit office , if you have 64bit Win7, go with 32bit office much stable.