Wednesday, 28 December 2011
Monday, 26 December 2011
Infopath Custom Date Validation
Custom Date Pattern:
Type1:
^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))
Type2:
\d{4}-\d{1,2}-\d{1,2}
Type1:
^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))
Type2:
\d{4}-\d{1,2}-\d{1,2}
A correlated subquery is an inner subquery which is referenced by the main outer query such that the inner query is considered as being executed repeatedly.
Example:
----Example of Correlated SubqueriesUSE AdventureWorks;GOSELECT e.EmployeeID FROM HumanResources.Employee eWHERE e.ContactID IN(SELECT c.ContactIDFROM Person.Contact c WHERE MONTH(c.ModifiedDate) = MONTH(e.ModifiedDate))GOHere e.ModifiedDate-->Outer Query field refers in Inner Query.A noncorrelated subquery is subquery that is independent of the outer query and it can executed on its own without relying on main outer query.Example:
----Example of Noncorrelated SubqueriesUSE AdventureWorks;GOSELECT e.EmployeeIDFROM HumanResources.Employee eWHERE e.ContactID IN(SELECT c.ContactIDFROM Person.Contact cWHERE c.Title = 'Mr.')GOHere 'Mr.'--->Outer Query field doesn't refers in Inner Query.How to assign String Values in CAML Query
string pname = TxtProjectName.Text;
query.Query = "<Where><Eq><FieldRef Name=\"ProjectName\"/><Value Type=\"Text\">" + pname + "</Value></Eq></Where>";
SPListItemCollection myListcollection = myList.GetItems(query);
query.Query = "<Where><Eq><FieldRef Name=\"ProjectName\"/><Value Type=\"Text\">" + pname + "</Value></Eq></Where>";
SPListItemCollection myListcollection = myList.GetItems(query);
Wednesday, 16 November 2011
Hiding the Quick Launch in SharePoint 2010
Hiding the Quick Launch in SharePoint 2010
At times one would really feel no need of the Quick Launch section on few pages or sites i.e. the Team Site, one would really love to use the full width of the page for this one. Luckily the Content Editor Web Part trick which worked in SharePoint 2007 still works in 2010.

To hide the Quick Launch
1. Add a new Content Editor webpart. (Doesn’t matter where you add it)
2. Edit the HTML Source for the newly added Content Editor Webpart

3. In the HTML Source add the following and Click OK.

4. Save the Page. The Quick Launch section should not be visible now.
5. Edit the Just added Content Editor web Part and Under Layout Section Tick the Hidden Check box and Click OK, Which will hide the Webpart from Normal View.

6. This works on any SharePoint 2010 or Foundation 2010 Page and site.
To hide the Quick Launch
1. Add a new Content Editor webpart. (Doesn’t matter where you add it)
2. Edit the HTML Source for the newly added Content Editor Webpart
3. In the HTML Source add the following and Click OK.
#s4-leftpanel{[Do not forget to add the style open and close tag as seen in below image due to rendering issues its not showing up]
display:none
}
.s4-ca{
margin-left:0px
}
4. Save the Page. The Quick Launch section should not be visible now.
5. Edit the Just added Content Editor web Part and Under Layout Section Tick the Hidden Check box and Click OK, Which will hide the Webpart from Normal View.
6. This works on any SharePoint 2010 or Foundation 2010 Page and site.
Monday, 31 October 2011
Edit Browser Enabled InfoPath form Ribbon
InfoPath 2010 Advanced Form Options
When you publish InfoPath 2010 form to SharePoint 2010 to open in a web browser Web browser the following options will be applied Show InfoPath commands in Ribbon or toolbar Show the following commands - submit - save - save us - close - views - print preview How to disable or remove save and save us InfoPath 2010 Form features after publishing to SharePoint 2010?
InfoPath form Template Link in Quick Launch Bar
There are four methods for invoking an InfoPath form or a browser-based version of the form on a server that is running InfoPath Forms Services. These methods consist of URLs that reference a form template file (.xsn), URLs that reference a form file (.xml) based on a form template, URLs that reference the built-in FormServer.aspx Web page, and those that contain a reference to a custom page that contains the XmlFormView control. The first three kinds of URL support using query parameters to control aspects of the resulting form that includes whether it will be opened in the InfoPath Filler or rendered in the browser, the location where the form will be saved, and the Web page that the user will be directed to when they close the form.
| By default, InfoPath forms will open in InfoPath Filler even if a browser-enabled form is available. If InfoPath Filler is not installed, the form will open in the browser. In addition to using query parameters to control how forms are opened, SharePoint form library settings are used to control where forms are opened. To always force the form to open in the browser, open the form library, click the Library tab under Library Tools, click Library Settings on the ribbon, and then click the Advanced settings link under General Settings. Under Opening Documents in the Browser, click Open in the browser. |
| Parameter Name | Description | Allowed Values |
|---|---|---|
| XmlLocation | Used to open an existing form. The XmlLocation and XsnLocation properties are mutually exclusive; specifying values for both parameters will result in an error. | A valid URL to a form file (.xml) in the same site collection. |
| XsnLocation | Used to open a new form that is based on a form template. If an XsnLocation is specified in a URL using FormServer.aspx, a SaveLocation should also be specified if the Save and Save As buttons must be displayed. The Source parameter should also be specified or the message "The form has been closed" will appear when the user closes the form. The XmlLocation and XsnLocation properties are mutually exclusive; specifying values for both parameters will result in an error. | A valid URL to a form template file (.xsn) published on the same site collection. |
| OpenIn |
|
|
| Source | The location to which the user will be redirected when the form is closed. The URL must be in the same site collection or an error will be returned. | A valid URL in the same site collection as the form. |
| Options | DisableSave is the only allowed value. It hides the Save and Save As buttons and disables saving the form when it is rendered in the browser. | DisableSave |
| SaveLocation | A Save As dialog box is displayed prompting the user for a file name, and then it is saved in the specified folder. An error is returned if the specified folder does not exist. | Any valid folder location on the site collection. |
| NoRedirect | Does not redirect to FormServer.aspx for client detection or rendering in the browser. Default value is false. If true and an XmlLocation or XsnLocation is specified, a File Download dialog box is displayed when you are using Internet Explorer. |
|
| DefaultItemOpen | The OpenIn parameter should be used instead, and overrides the DefaultItemOpen parameter value. A value of 0 indicates that the request is from a document library and the InfoPath Filler was not detected. A value of 1 indicates that the request is from a document or form library that has the Display as a Web page setting. |
|
| The query parameters and their associated values are not case-sensitive, but the corresponding properties of the XmlFormView control, such as the Options and SaveLocation properties, are case-sensitive. |
The following procedures require a site collection that you can publish form templates to, and the ability to create new sites in the site collection.
Placeholder values are used in the following example URLs. These values represent the following SharePoint and InfoPath items:
- ServerName: A server that is running InfoPath Forms Services.
- SiteCollection: The top-level site in a site collection.
- FormLibrary: A form library or document library that contains a browser-enabled form template.
- Form1.xml: A form that is based on the template.xsn in FormLibrary.
- NewFolder: A folder within the FormLibrary.
- NewSite: A site within the SiteCollection.
The ~sitecollection value that is used in the following URLs is not a placeholder value. It is a special token that is used with InfoPath Forms Services that enables relative links and site collection-scoped URL addresses.
To use a URL with the XmlLocation parameter
- Create a form template and upload it to a new form library.
- Create a form that is based on that form template and save it as "Form1" in the library.
- Enter the following URL, inserting actual values for the placeholder values:
http://ServerName/sites/SiteCollection/_layouts/FormServer.aspx?XmlLocation=~sitecollection/FormLibrary/Form1.xml
Note
Note that "Form1" is rendered in the browser.
To use a URL with the XsnLocation, SaveLocation, and Source parameters
- Create a form template and upload it to a new form library.
- Enter the following URL, inserting actual values for the placeholder values:
http://ServerName/sites/SiteCollection/_layouts/FormServer.aspx?XsnLocation=~sitecollection/FormLibrary/Forms/template.xsn&SaveLocation=~sitecollection/FormLibrary&Source=~sitecollection/FormLibrary
Note
A new form that is based on the form template is rendered in the browser. - Save the new form.
Note
The form is saved in the form library specified by the SaveLocation parameter. - Close the form and you will be returned to the form library specified by the Source parameter. In this case, the form library is also where the form is saved because the SaveLocation and Source parameters point to the same location.
To use a URL with the SaveLocation and Source parameters
- Create a form template and upload it to a new form library.
- Create a form that is based on that form template and save it as "Form1" in the library.
- Create a new folder in the form library by using the new folder name to replace NewFolder in the following URL.
- Create a new site under the existing top-level site collection by using the new site name to replace NewSite in the following URL.
- Enter the following URL, inserting actual values for the placeholder values:
http://ServerName/sites/SiteCollection/_layouts/FormServer.aspx?XmlLocation=~sitecollection/FormLibrary/Form1.xml&SaveLocation=~sitecollection/FormLibrary/NewFolder/&Source=~sitecollection/NewSite - Save the existing form, typing a new name in the Save As dialog box. The form will be saved in the new folder.
- Close the form and you will be redirected to the new site.
To use a URL with the OpenIn=Browser parameter
- Create a form template and upload it to a new form library.
- Create a form that is based on that form template and save it as "Form1" in the library.
- Enter the following URL, inserting actual values for the placeholder values:
http://ServerName/sites/SiteCollection/FormLibrary/Form1.xml?OpenIn=Browser
or
http://ServerName/sites/SiteCollection/_layouts/FormServer.aspx?XmlLocation=~sitecollection/FormLibrary/Form1.xml&OpenIn=Browser
Note
Even if you have Microsoft InfoPath 2010 installed, the URL forces the form to render in the browser.
To use a URL with the NoRedirect parameter
- Create a form template and upload it to a new form library.
- Create a form that is based on that form template and save it as "Form1" in the library.
- Enter the following URL, inserting actual values for the placeholder values:
http://ServerName/sites/SiteCollection/FormLibrary/Form1.xml?NoRedirect=true
and
http://ServerName/sites/SiteCollection/FormLibrary/Forms/template.xsn?NoRedirect=true
Note
The form file (.xml) and the form template (.xsn) will not be redirected to FormServer.aspx. Instead, you will be presented with the File Download dialog box (if using Internet Explorer) to download the file from the SharePoint site.
It is sometimes necessary to return a content stream of the XML representing the form. This is possible using the following methods.
To use a content stream
- Use a URL with the NoRedirect parameter.
- Insert a "Translate:f" header in the HTTP GET request, such as the following example:
- Use the appropriate InfoPath user agent in the HTTP GET request, InfoPath.1 or InfoPath.2.
Cascading Drop-Down List in SharePoint 2010 using InfoPath 2010(Filter)
Cascading Drop-Down List in SharePoint 2010 using InfoPath 2010
Cascading drop-down is a common business requirement. SharePoint 2007 does not support cascading drop-down list by default. User have to write custom SharePoint field and it’s not easy to implement. With SharePoint 2010, User able to customize SharePoint form in easy way by using the powerful of InfoPath Designer. Following is the step guides to create a cascading drop-down list solution in SharePoint 2010 without require a lot of IT knowledge.
Scenario: We build a cascading for Address List. We have three list: City, District and Ward
1. Create City List
- In SharePoint 2010, create a custom List and named as “City”
- Add Two Item to this list: Hanoi and TP HCM
2. Create District List
- In SharePoint 2010, create a custom List and named as “District”
- Create a Lookup column named as “City”. This column get information from City List in the column Title.
- Add 4 items to District list
3. Create Ward List
- In SharePoint 2010, create a custom List and named as “Ward”.
- Create a Lookup column named as “City”. This column get information from City List in the column Title.
- Create a Lookup column named as “District”. This column get information from District List in the column Title.
- Create on Add new Item link you will see. When we choose City, District still have 4 item.
4. Customize Ward form to meet cascading requirement
- In Ward List, click on Customize Form ribbon button
- System will automatically open the form template of Ward list in InfoPath Designer
- Right click on District drop-down list control then select Drop-Down List box Properties from menu to open the properties windows
- In Data Source. Click on Add button
- In Data Connection Wizard, click on Next button
- In Select the source of your data, choose SharePoint library of list then click Next button
- In SharePoint Site details screen, click on Next button
- In Select a list of library, choose District the click on Next button
- In select fields: Choose Title, City, ID then click on Next button
- In next screen, choose Next button
- Leave the default name for the connection as “District1” then click Finish button
- Now, You will see the Data Source of Drop-Down list box is District1
- In Entries section, click on the tree button to select XPath
- In Select a Field or Group dialog, click on Filter Data… button
- In Filter Data click on Add… button
- In specify Filter Conditions, in the first drop-down list choose Select a field or group
- Select a Field or Group opened. Select District1 as Data Source, choose City in dataFields then click OK
- In specify Filter Conditions, in the last drop-down list choose Select a field or group
- Select a Field or Group opened. Select Main as Data Source then choose City in dataFields then click OK
- Click on OK to close specify Filter Conditions dialog
- Click on OK to close Filter Data dialog
- Click on OK to close Select a Field or Group
- In Drop Down List box properties, choose d:ID in Value: section then click OK to close this
- In InfoPath Designer, close the Windows then choose the Save and Publish button
- After Publishing complete, back to Ward list then click on Add new item link. You will see the result
Two drop-down list has been cascading.
Conclusion
SharePoint 2010 provides a easy way for none IT to custom the look and feel of SharePoint by using InfoPath Designer, SharePoint Designer. Customize form in InfoPath Designer 2010 is a great new feature of SharePoint 2010. It’s cool!
Scenario: We build a cascading for Address List. We have three list: City, District and Ward
1. Create City List
- In SharePoint 2010, create a custom List and named as “City”
- Add Two Item to this list: Hanoi and TP HCM
2. Create District List
- In SharePoint 2010, create a custom List and named as “District”
- Create a Lookup column named as “City”. This column get information from City List in the column Title.
- Add 4 items to District list
3. Create Ward List
- In SharePoint 2010, create a custom List and named as “Ward”.
- Create a Lookup column named as “City”. This column get information from City List in the column Title.
- Create a Lookup column named as “District”. This column get information from District List in the column Title.
- Create on Add new Item link you will see. When we choose City, District still have 4 item.
4. Customize Ward form to meet cascading requirement
- In Ward List, click on Customize Form ribbon button
- System will automatically open the form template of Ward list in InfoPath Designer
- Right click on District drop-down list control then select Drop-Down List box Properties from menu to open the properties windows
- In Data Source. Click on Add button
- In Data Connection Wizard, click on Next button
- In Select the source of your data, choose SharePoint library of list then click Next button
- In SharePoint Site details screen, click on Next button
- In Select a list of library, choose District the click on Next button
- In select fields: Choose Title, City, ID then click on Next button
- In next screen, choose Next button
- Leave the default name for the connection as “District1” then click Finish button
- Now, You will see the Data Source of Drop-Down list box is District1
- In Entries section, click on the tree button to select XPath
- In Select a Field or Group dialog, click on Filter Data… button
- In Filter Data click on Add… button
- In specify Filter Conditions, in the first drop-down list choose Select a field or group
- Select a Field or Group opened. Select District1 as Data Source, choose City in dataFields then click OK
- In specify Filter Conditions, in the last drop-down list choose Select a field or group
- Select a Field or Group opened. Select Main as Data Source then choose City in dataFields then click OK
- Click on OK to close specify Filter Conditions dialog
- Click on OK to close Filter Data dialog
- Click on OK to close Select a Field or Group
- In Drop Down List box properties, choose d:ID in Value: section then click OK to close this
- In InfoPath Designer, close the Windows then choose the Save and Publish button
- After Publishing complete, back to Ward list then click on Add new item link. You will see the result
Two drop-down list has been cascading.
Conclusion
SharePoint 2010 provides a easy way for none IT to custom the look and feel of SharePoint by using InfoPath Designer, SharePoint Designer. Customize form in InfoPath Designer 2010 is a great new feature of SharePoint 2010. It’s cool!
Wednesday, 12 October 2011
Friday, 16 September 2011
Developing SharePoint 2007 Webparts using Visual Studio 2010
Developing SharePoint 2007 Webparts using Visual Studio 2010
December 16, 2010
Written by Trent Allday
3 Comments
Today I had a client that came to me that liked a web part that I had developed and wanted me to install it for them with some slight mods. No problem… Ohh wait, we developed that for SharePoint 2010 using Visual Studio 2010.
I am a huge fan of Visual Studio 2010 and its tight integration with SharePoint 2010 in its ability to quickly create features and write code like its supposed to be written (without the major headache!). Although WSPbuilder was the tool of chose for SP 2007, VS 2010 is now my new favourite weapon. With new functions like creating Visual Web Parts in a couple of clicks, features, deploy & debug with F5, control over deployment and much more. Its fantastic, well done to Microsoft for making what should be a simple job easy again!
Since the release of SharePoint 2010 I now do a lot my development in SharePoint 2010 even if my client is running on SharePoint 2007. Why? Well because the API’s for SP 2007 & 2010 are very similar, and really haven’t effected much of my development to date. I find it so much easier to development in SP 2010 with Visual Studio 2010 especially when I run Windows 7 64-bit with SharePoint Foundation 2010 installed. Having this setup means that i can deploy directly from my local PC to a SharePoint environment for basic testing. No need to manually create project structure, manifiest files, signing of assembly, building wsps, manually deploying, attach to debug etc. Once I’m all done with development I package it up and deploy the wsp to the Sharepoint 2007 development for thorough testing. Provided I haven’t used any deprecated methods in the API, ill be all sweet. Good thing is if you have used and deprecated methods you wont be able to build solution, so you wont be doubt when deploying to SP 2007.
So for the purposes of this article I am going create a basic visual web part, something that was difficult to do in SharePoint 2007 development. This process should work for most project types available…
I am a huge fan of Visual Studio 2010 and its tight integration with SharePoint 2010 in its ability to quickly create features and write code like its supposed to be written (without the major headache!). Although WSPbuilder was the tool of chose for SP 2007, VS 2010 is now my new favourite weapon. With new functions like creating Visual Web Parts in a couple of clicks, features, deploy & debug with F5, control over deployment and much more. Its fantastic, well done to Microsoft for making what should be a simple job easy again!
Since the release of SharePoint 2010 I now do a lot my development in SharePoint 2010 even if my client is running on SharePoint 2007. Why? Well because the API’s for SP 2007 & 2010 are very similar, and really haven’t effected much of my development to date. I find it so much easier to development in SP 2010 with Visual Studio 2010 especially when I run Windows 7 64-bit with SharePoint Foundation 2010 installed. Having this setup means that i can deploy directly from my local PC to a SharePoint environment for basic testing. No need to manually create project structure, manifiest files, signing of assembly, building wsps, manually deploying, attach to debug etc. Once I’m all done with development I package it up and deploy the wsp to the Sharepoint 2007 development for thorough testing. Provided I haven’t used any deprecated methods in the API, ill be all sweet. Good thing is if you have used and deprecated methods you wont be able to build solution, so you wont be doubt when deploying to SP 2007.
Problem.
So i presume your reading this because you love the new Visual Studio 2010 but need to develop web parts for SharePoint 2007. Although the interface within Visual Studio doesn’t directly enable you to develop for 2007, it is possible with some minor changes to your project.So for the purposes of this article I am going create a basic visual web part, something that was difficult to do in SharePoint 2007 development. This process should work for most project types available…
- Start New Project, select Visual Web Part
- Select – Deploy as a farm solution
- Write your custom web part. I have just created a simple web part that contains some text and a button. When the user clicks the button the button text will change.
- I now press F5 on the keyboard and Visual Studio will automatically build & deploy my web part to SharePoint 2010.
- I confirm it all works by adding the web part to the page. Great! But there is nothing special so far.
- Now to get it into SharePoint 2007! First lets try deploying the current wsp as it is…
- So we need to package up the solution.
- Grab the wsp from the bin folder
- Copy to SharePoint 2007 server.
- Deploy to 2007 env and we get an error. The error tells us that it found a version number in the manifest that it doesnt understand.
“Solution manifest for solution ’48cae4c9-68ba-cccf5a89304′ failed validation, file manifest.xml, line 2, character 110: The ‘SharePointProductVersion’ attribute is not declared.
Solution
After the steps above:- Go back into Visual Studio 2010.
- Double click the “Package.package” file
- Select “Manifest” down the bottom. Notice where is reads SharePointProductVersion=”14.0” in the xml file.
- In the properties panel, clear out 14.0 in the SharePointProductVersion field. This removes the property all together from the manifest file.
- We also need to change the assembly reference in the project from Microsoft.SharePoint.dll 14.0 to 12.0.
To do this you will need to click the show all files icon in the solution explorer panel.-Next, delete out Microsoft.SharePoint & delete out Microsoft.SharePoint.Security as these wont be on the SP 2007 environment.-Then you want to add a reference to Microsoft.SharePoint.dll but make sure its the 12.0 version found in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll
- Because we have built a ‘Visual Web Part’, Visual Studio 2010 automattically adds some imports into the ascx user control file which wont exists in SP 2007. Therefore you need to comment these references out. Obviously if we were doing a coded web part or a event receiver we would not need to do this step.Mine currently looks like this.
- Package up your solution again and deploy on SP 2007 environment.
- Active, test and your good to go.
- You will need Asp.Net 3.5 installed on your SharePoint 2007 environment.
- This may not always be the right solution for you (depending on your project) but it certainly saves me a lot of time for those basic web parts
-37.814251 144.963169
Subscribe to:
Comments (Atom)
