Cloud4MEA … All about cloud


Heads up, we are here finally!
‪#‎Cloud4MEA‬ is the first Arabic channel specialized in cloud computing services
All high quality educational content for all our followers in MEA for free
Watch our tutorials, latest news about cloud, ‪#‎Microsoft‬ ‪#‎Office365‬and more
Subscribe to our channel on YouTube, follow us in twitter and Facebook

#Microsoft #Office365 ‪#‎Cloud‬ #Cloud4MEA

SharePoint Calendar: Specified argument was out of the range of valid values [Exception]


I had a very weird issue when opening a SharePoint calendar

Specified argument was out of the range of valid values [exception]

error

My first doubt was invalid values have been entered by a user at the start or end dates however, i wasn’t able to open the calendar list to check.

I found online that when i add this string to the calendar URL

?CalendarDate=10/10/2011&CalendarPeriod=week” it will open!

Then i found a record like so

Screenshot_1

A user types in End Date year value 9999

By deleting this record everything went fine and calendar now is working properly.

I hope this bite helps you guys

SharePoint 2013 Change Master Page Search Box Watermark Text Value


If you are using SharePoint server 2013 in creating multi-language website, it is highly recommended to use SharePoint variation feature, which allows you to create multi labels for your website. Each label will show different content and regional settings based on required languages.

When it comes to master page customization, many of us struggling in changing some content like; search box watermark text like in picture below:

search En

Here below very simple steps to change this watermark value:

  • Open master page in “Advanced Mode” using SharePoint Designer 2013
  • Search for “SearchWC:SearchBoxScriptWebPart
  • Add the following property with the required value to the “SearchWC” control  InitialPrompt=”بحث…”

Then the result will be as below:

search Ar

Enjoy this bite!

How to Create a SharePoint Site Collection with a Separate Content Database Using PowerShell ISE


Microsoft SharePoint server is having some boundaries and limits in some areas, to read more about these limits please check this article at technet.

In this article let’s focus on web application and site collection limits. When you create a new web application, SharePoint will create a new content database to contain all information about this web application and any site collection under its shield. SharePoint supports 200 GB for every content database which includes the created web application and its babies (site collections and sub-sites).

In many scenarios you will be required to create a site collection for document management purposes, which means more data size to be stored. In this case, creating a site collection with a separate content database is highly recommended approach to achieve this.

Let’s see how to create a SharePoint site collection with a separate content database using a very handy Windows server tool: PowerShell ISE

  • Step 1 – Create a new web application using SharePoint central administration
  • Step 2 – Check created content database

In this step all what you need is to open central administration then from “Application Management” section select “Manage content databases”. Select the web application to show all available content database for this web application, you can notice that by default it contains only one content database for everything.

Content databases

  • Step 3 – Open PowerShell ISE to create the script

In this step which considered the main one, we will see how to manage the whole process from PowerShell ISE console.

To open it, just type the name at start screen and select “Windows PowerShell ISE”  as administrator, DON’T use (x86) version.

ISE

First part of the script will show the required variables we need to set for the process as follow

#this line is to reference Microsoft SharePoint PowerShell namespace
#to be able to use SharePoint commands
Add-PSSnapIn Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue;
#Create command required variables
$siteName = "DMS";
$webAppUrl = "http://intranet.vlabs.local";
#You can select any site collection template code by typing Get-SPWebTemplate
$template = "STS#0";

$ownerAlias = "vlabs\ahmed.moussa";
$secondaryOwnerAlias = "vlabs\ayman.hattab";

#this variable is considering that you have a wildcard manged path "departments"
$siteUrl = "$webAppUrl/departments/$siteName";
$databaseName = "WSS_Content_$siteName";
$databaseServer = "SP2013.vlabs.local";

Second part is to create a new content database inside the selected web application to be assigned to the new site collection

 

#Create new content database for DMS department site collection
New-SPContentDatabase -Name $databaseName -DatabaseServer $databaseServer -WebApplication $webAppUrl;

Then Create the site collection and pass the content database to it as follow

#Create new site collection for DMS department
New-SPSite -Url $siteUrl -OwnerAlias $ownerAlias -SecondaryOwnerAlias $secondaryOwnerAlias -ContentDatabase $databaseName -Template $template -Name $siteName;

Last step is to create the security groups of the new site collection because SharePoint doesn’t create them by default.

#New-SPSite doesn't create default SharePoint security groups
#Create DMS site collection default groups
$web = Get-SPWeb $siteUrl;
# this symbol i:0#.w is presenting windows authentication security mechanism
$web.CreateDefaultAssociatedGroups("i:0#.w|$ownerAlias","i:0#.w|$secondaryOwnerAlias",$siteName);
$web.Update();</pre>
<pre>
  • Step 4 – Navigate to manage content databases

Now you have a new content database (200 GB) limit for the new site collection in your web application.

Enjoy this bite!

Make SharePoint Custom Form Saving Progress Fancy using JQuery BlockUI Plugin


Creating a custom form is a main dish in your SharePoint project menu. After filling the required data and submit the form, users should wait for the browser progress until it finishes loading then shows success message.

This is a very traditional way, let’s see how to make it more modern and fancy using jQuery with SharePoint.
I always say that “jQuery rocks .. when it works”.

In this SharePoint bite i will show you how to make SharePoint custom form modern during posting data to server side.

This feature is using jQuery plugin called BlockUI, it requires jQuery v1.7 or later.
Let’s get started!

  • Create SharePoint List Custom New Form

I am using the following HTML for the form [Title* – Order Number – Price]

form

<div>
    <div class="formLabel">
        <asp:Label ID="lblTitle" runat="server" Text="Title"></asp:Label>
        <span style="color:red">*</span>
    </div>
    <div class="formControl">
        <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="req_Title" runat="server" ControlToValidate="txtTitle" ForeColor="Red"
            ErrorMessage="Required"></asp:RequiredFieldValidator>
    </div>
    <br />
    <div class="formLabel">
        <asp:Label ID="lblCode" runat="server" Text="Order Code"></asp:Label>
    </div>
    <div class="formControl">
        <asp:TextBox ID="txtCode" runat="server"></asp:TextBox>
    </div>
    <br />
    <div class="formLabel">
        <asp:Label ID="lblPrice" runat="server" Text="Price"></asp:Label>
    </div>
    <div class="formControl">
        <asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
    </div>
    <br />
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="btn" OnClick="btnSubmit_Click" />
    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="btn" />
    <br />
    <br />
    <asp:Label ID="lblResult" runat="server" Text="" ForeColor="Green"></asp:Label>
</div>

On submit button click event, insert these values into a SharePoint list.

  • Add BlockUI & jQuery Scripts’ References to the Form

You can download both libraries then add them to SharePoint site collection style library. It is very important to notice the reference sequence to be as below

<script type="text/javascript" src="/Style Library/JS/jquery.min.js"></script>
<script type="text/javascript" src="/Style Library/JS/jquery.blockUI.js"></script>

If you faced any issue in using these references, please check this great article to troubleshoot the issue you may face.

  • Add Script to Button Click Event

To be able to run this scrip during your save or submit button click you have to add the script below

Note: if you have any validation controls on your form, you have to validate the page before running the script. This point is covered in the script below [please notice comments available].
Script timeout will be based on the request closure using last line in this script.

<script type="text/javascript">
 //fire the script with the button click
 //replace button id with the proper id that you use
 $(function (e) {
 $('#<%= btnSubmit.ClientID %>').click(function (e) {
 //this if statement is validating the form required fields
 if (Page_ClientValidate()) {
 $.blockUI({
 message: '<h3>Submitting your request..<h3/>',
 css: {
 padding: '15px',
 margin: 0,
 width: '30%',
 top: '40%',
 left: '35%',
 textAlign: 'center',
 color: '#fff',
 border: '2px solid #aaa',
 backgroundColor: '#fff',
 cursor: 'wait'
 }
 });
 }
 });
 });
 //this line will terminate the blockUI when post event is closed.
 Sys.WebForms.PageRequestManager.getInstance().add_endRequest($.unblockUI);
</script>
  • Full Code Snippet
<script type="text/javascript" src="/Style Library/JS/jquery.min.js"></script>
<script type="text/javascript" src="/Style Library/JS/jquery.blockUI.js"></script>

<script type="text/javascript">
 //fire the script with the button click
 //replace button id with the proper id that you use
 $(function (e) {
 $('#<%= btnSubmit.ClientID %>').click(function (e) {
 //this if statement is validating the form required fields
 if (Page_ClientValidate()) {
 $.blockUI({
 message: '<h3>Submitting your request..<h3/>',
 css: {
 padding: '15px',
 margin: 0,
 width: '30%',
 top: '40%',
 left: '35%',
 textAlign: 'center',
 color: '#fff',
 border: '2px solid #aaa',
 backgroundColor: '#fff',
 cursor: 'wait'
 }
 });
 }
 });
 });
 //this line will terminate the blockUI when post event is closed.
 Sys.WebForms.PageRequestManager.getInstance().add_endRequest($.unblockUI);
</script>
<div>
 <div class="formLabel">
 <asp:Label ID="lblTitle" runat="server" Text="Title"></asp:Label>
 <span style="color:red">*</span>
 </div>
 <div class="formControl">
 <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox>
 <asp:RequiredFieldValidator ID="req_Title" runat="server" ControlToValidate="txtTitle" ForeColor="Red"
 ErrorMessage="Required"></asp:RequiredFieldValidator>
 </div>
 <br />
 <div class="formLabel">
 <asp:Label ID="lblCode" runat="server" Text="Order Code"></asp:Label>
 </div>
 <div class="formControl">
 <asp:TextBox ID="txtCode" runat="server"></asp:TextBox>
 </div>
 <br />
 <div class="formLabel">
 <asp:Label ID="lblPrice" runat="server" Text="Price"></asp:Label>
 </div>
 <div class="formControl">
 <asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
 </div>
 <br />
 <asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="btn" OnClick="btnSubmit_Click" />
 <asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="btn" />
 <br />
 <br />
 <asp:Label ID="lblResult" runat="server" Text="" ForeColor="Green"></asp:Label>
</div>
  • When Clicking Submit … awesome!

Submit

 

 

Enjoy this bite!

SharePoint Date Time Control Important Tips!


In this article i will explain some of the main tips that commonly used with SharePoint date time control.

Set SharePoint Date Time Control Validation:

Most of the cases you will need to set a validation to this control, although it has “IsRequired” property to maintain OTB validation but some times you would need to change this message or use “RequiredFieldValidator” control for some reason.

Assume that SharePoint date time control ID is “dtStart“, using  “RequiredFieldValidator” control with it should be in the following format:

ControlToValidate = [SharePointDateTimeControlID]$[SharePointDateTimeControlID]Date

<asp:RequiredFieldValidator id="RequiredFieldValidator1"
                 ControlToValidate="dtStart$dtStartDate" 
                 Display="Dynamic" runat=server
                 ErrorMessage="Date is Required"> 

 

Disable any Past Dates Values

If you want to prevent user from selecting any past dates less than Today’s date you have to set the following property:

In page load event

 dtStart.MinDate = DateTime.Today;

 
Prevent User from Typing or Changing Selected Date Value

The most important tip is that if you prevent user from selecting past dates, then he can type it or even type some text in this control text box!!

This control is consist of a text box plus date picker button

Date Time

To prevent user from doing this action you can easily make this text box “Read Only” !

On page load event type the following line of code to mark this text box as “Read Only”

((TextBox)(dtStart.Controls[0])).Attributes.Add("readonly", "readonly");

 

Then at the end you have a date time control with validation and you can make sure that selected date value is valid!

Enjoy this bite.

[Arabic] 3. SharePoint 2013 Client Object Model Programming – Part 1


In this lesson you will start learning how to create client side applications that can connect and get data from SharePoint server
Step by step, understand how client object model communicates with SharePoint.