21 December 2013

An error occurred while processing this request

I recently started to develop a web form with knockout JS. The system is running on SharePoint 2010. The data given / taken  to  the form with JSON through WCF services.

I had a problem, I did not want that the service will be expose to web. To prevent exposure, created casing in the SharePoint an Application Page.

The WCF data services and any entity framework written in framework 4.5, and as you know that SharePoint 2010 and with the Application Page written in 3.5.

This means that every reference to in the form of entity framework like linq or lambda expressions written in framework 3.5 - which created (and still creates) a lot of problems.

I will present you one example of the problem we encounter - but Google unfortunately did not help.

The following code in FW3.5 not working in Client Data Service

if (ctx != null && ctx.UsersContext != null)
{
    string username = "username";
    var userList = ctx.UsersContext.Where(z => z.Code ==                      username).AsEnumerable().ToList();
}

I even tried Windows Application purpose to see that the SP does not hurt me



The Error Massage was:

An error occurred while processing this request

"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"><code></code><message xml:lang=\"en-US\">The MaxDataServiceVersion '1.0' is too low for the response. The lowest supported version is '2.0'.</message></error>"






I'll not go with you all the way I went through hardships

The problem is development server and production server does not always match (which always advisable to have :)).
One Development server was windows Server 2008 R2 which was the error. And another was a windows server 2008 R2 SP1

Of course I did not notice until the solution - I only need to install Windows 2008 r2 SP1

Soon I will try to give you a few more problems cropped up this complex project,
Roi

22 September 2013

How to open a PDF file (or any file) in the sharepoint site

Not long ago, I had to view a PDF file from sharepoint. But I got the following message:


Do you want to save file-name from yours-site

Who does not know this message? But I've  target 'self' in 'a' tag html????

It turns out that SharePoint having your code to protect customers. They can only give you their familiar software like Office, but a pdf file - Microsoft unfamiliar terms.

To resolve, you need to make a change in Central-Admin

Go to your Web Application manage - General Setting


Find Browser File Handling and Change the default to Strict.


It all friends, now you can view any file on the portal (at your own risk).

Your,
Roi

29 August 2013

Service Pack 2‏ (SP2) for Microsoft SharePoint 2010 and Office 2010

Last month came new version (Service Pack 2) for Office 2010, SharePoint 2010,  Project server 2010 and the Fast 2010.

Here are some links that will help you

Service Pack 2 for Microsoft Office 2010 (KB2687455) 32-Bit Edition
http://www.microsoft.com/en-us/download/details.aspx?id=39667

Service Pack 2 for Microsoft Office 2010 (KB2687455) 64-Bit Edition
http://www.microsoft.com/en-us/download/details.aspx?id=39647

Note: In addition to the products in the Office 2010 suite, service pack 2687455 also updates Microsoft Project 2010, Microsoft Visio 2010, and Microsoft SharePoint Designer 2010

Service Pack 2‏ (SP2) for Microsoft SharePoint Server 2010 (KB2687453)
http://www.microsoft.com/he-il/download/details.aspx?id=39672

Service Pack 2‏ (SP2) for Microsoft SharePoint Foundation 2010 Language Pack (KB2687466)
http://www.microsoft.com/he-il/download/details.aspx?id=39674

Service Pack 2‏ (SP2) for Microsoft FAST Search Server 2010 for SharePoint (KB2687446)
http://www.microsoft.com/he-il/download/details.aspx?id=39670

Service Pack 2 for Microsoft Office Web Apps (KB2687470)
http://www.microsoft.com/en-us/download/details.aspx?id=39659

Service Pack 2 for Microsoft SharePoint and Project Server 2010 (KB2687452)
http://www.microsoft.com/en-us/download/details.aspx?id=39657

Service Pack 2 for Microsoft Search Server 2010 (KB2687461)
http://www.microsoft.com/he-il/download/details.aspx?id=39656

Yours,
Roi

23 August 2013

Which w3wp process belongs to which App Pool

Often you wonder which process belongs to which site (in my case usually SharePoint site)? Or maybe you just want to debug only your website on the development server .

For this we have the appcmd.

all you need is to run this command:

%windir%\system32\inetsrv\appcmd.exe list wp



Now you can see who is gobbling sites memory from is id (pid)



Yours,
Roi

04 August 2013

Speedup Powershell at SharePoint 2013

If you worked in stsadm in MOSS 2007 and even if it worked in SharePoint 2010, you saw it slow.
In 2010 we also added the powershell - who was sometimes slow.

It turns out that in sharepoint 2013 not made significant changes - is suggested

The solutions are
  1. Add crl.microsoft.com to your hosts file and point it to your local machine
    Go to Start -> Run
    Click "Drivers" (It need to open "C:\Windows\System32\drivers" - in not go to it)
    Go to folder "etc" and open "hosts" file with notepad
    and add this line
    127.0.0.1       crl.microsoft.com
    Disclosure: this solution find a lot on Google - but my no significant change
  2. Disable the CRL check by modifying the registry for all user accounts that use STSADM and all service accounts used by SharePoint.
    Go to Start -> regedit and fund this location

    [HKEY_USERS\<userid>\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing]

    Yon need to change all yours users to “State”=dword:00023e00 
    Click Modify and change it.


Yours.
Roi

04 July 2013

Message presented you leave your site

This time,I present in JavaScript (Jquery) code that checks whether you leave your domain. If so - popup alert to informing you that you are leaving the domain

$(document).ready(function () {
    $("a").click(function(event) {
        // check if the target link is your.domain.com
        // if not will show alert message
        if (this.href.indexOf("your.domian.com") == -1) {
            if (this.href.startsWith("http")) {
                event.preventDefault();
                var linkLocation = this.href;
                alert('Note that you are directed to an external site does not belong to this site');
                window.open(linkLocation, '');
                return false;
            }
        }
    });

});


Of course, change the code from "your.domian.com" to your site.

thanks,
Roi

17 June 2013

How to set as Secure Store Service in SharePoint 2010

This time I'll introduce how to install  SSS (Secure Store Service) in SharePoint 2010 in 9 Easy Steps (tutorial)

1. Go to Central Admin -> Application Management
On Service Applications link  Manage services on server

2. Start Secure Store Service



3. Now, Click Applications Management then Manage Service Applications



4. Click New and then Secure Store Service



5. Write Your Data


6. Click OK and you get this screen


7. On Manage Service Applications you can see your service


8. Now you can create a new key - click Generate New Key


9. Write your key


It all my friends,
Roi

11 May 2013

Value does not fall within the expected range


Time introduced some strange problem.

I needed to build a list with a lookup field.
So build fields.. Then create content type.. and than a list detention....
Just.. Piece of cake.
As you know, Lookup field problem must be linked to an existing list.

So checking founder of the source list and then create the field.

Something that looks like the following code plus or minus

<Field Type="LookupMulti" DisplayName="Your List" Required="FALSE" EnforceUniqueValues="FALSE" Direction="None" List="Lists/YourList"      ShowField="Title" Mult="TRUE" Sortable="FALSE" UnlimitedLengthInDocumentLibrary="FALSE" Group="YourGroup" ID="{448f00a7-6cb5-4340-985f-990dd354f135}" SourceID="{1ce2cabb-bea1-4137-aee8-b4f12b17abcc}"      StaticName="YourName" Name="YourName" Version="3" />



The code worked fine until .... I had to create a new site with the list above ..

I got the following error



System.ArgumentException: Value does not fall within the expected range. at Microsoft.SharePoint.Library.SPRequestInternalClass.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) at Microsoft.SharePoint.Library.SPRequest.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) at Microsoft.SharePoint.SPFieldCollection.AddFieldAsXmlInternal(String schemaXml, Boolean addToDefaultView, SPAddFieldOptions op, Boolean isMigration, Boolean fResetCTCol) at Microsoft.SharePoint.SPContentType.ProvisionFieldOnList(SPField field, Boolean bRecurAllowed) at Microsoft.SharePoint.SPContentType.ProvisionFieldsOnList() at Microsoft.SharePoint.SPContentType.DeriveContentType(SPContentTypeCollection cts, SPContentType& ctNew) at Microsoft.SharePoint.SPContentTypeCollection.AddContentTypeToList(SPContentType contentType) at Microsoft.SharePoint.SPContentTypeCollection.AddContentType(SPContentType contentType, Boolean updateResourceFileProperty, Boolean checkName, Boolean setNextChildByte) at Microsoft.SharePoint.SPContentTypeCollection.Add(SPContentType contentType) at Microsoft.SharePoint.ApplicationPages.AddContentTypeToListPage.Update(Object o, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


When I tried to build manually the column with the field ... I got something similar



System.ArgumentException: Value does not fall within the expected range. at Microsoft.SharePoint.Library.SPRequestInternalClass.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) at Microsoft.SharePoint.Library.SPRequest.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) at Microsoft.SharePoint.SPFieldCollection.AddFieldAsXmlInternal(String schemaXml, Boolean addToDefaultView, SPAddFieldOptions op, Boolean isMigration, Boolean fResetCTCol) at Microsoft.SharePoint.SPList.ProvisionField(SPField fld, SPAddFieldOptions op, Boolean bRecurAllowed, Boolean bAddToDefaultView, Dictionary`2 dictAdd) at Microsoft.SharePoint.ApplicationPages.AddFieldFromTemplatePage.ProvisionFieldOnListCore(SPField fld, Boolean bRecurAllowed, Boolean bAddToDefaultView, Dictionary`2 dictAdd) at Microsoft.SharePoint.ApplicationPages.AddFieldFromTemplatePage.Update(Object o, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)




I tried Google's solutions, build console accesses picks up and changes the field from
List="Lists/YourList"
To
List="35ae7ed3-b23f-4f71-a2a3-8ad482ad9ab6"

The list has been changed from path to guid

But interested permissions list kept me fix it

The solution was simpler - I changed the feature in packge and installed again. I've iisreset (that's xml update feature to reset IIS binding)

Now the field looks like this

<Field Type="LookupMulti" DisplayName="Your List" Required="FALSE" EnforceUniqueValues="FALSE" Direction="None" List="35ae7ed3-b23f-4f71-a2a3-8ad482ad9ab6"      ShowField="Title" Mult="TRUE" Sortable="FALSE" UnlimitedLengthInDocumentLibrary="FALSE" Group="YourGroup" ID="{448f00a7-6cb5-4340-985f-990dd354f135}" SourceID="{1ce2cabb-bea1-4137-aee8-b4f12b17abcc}"      StaticName="YourName" Name="YourName" Version="3" />

Good day,
Roi



16 April 2013

side by side div with dynamic width


Often we need to build two divs standing side by side, with their width variable (dynamic)



The following code - will help you do it

<div id="container"> 
   <div id="left"> Div 1 - What is my size</div> 
   <div id="right"> Div 2 -I am the <br />Right DIV</div> 
</div>
<style type="text/css"> 
#left {   background: #aaa;   float: left }
#right {   background: cyan;   overflow: hidden } 
#container {   width :400px; } 
</style>

Yours,
Roi

06 March 2013

Support the HTML5 placeholder Attribute in Browsers that do not support it


HTML5 language gives us the possibility of a Placeholder.
The placeholder Attribute gives us information on the textbox where we are supposed to use.

All you need is to add the same type of input tag.


<input type="text" name="first_name" placeholder="First name">


Browsers that do not support it will show like:



Browsers that support it will show like:



If you want the older browsers will support it, all you have to do is add the following JQuery code:



/* Input Tag Placeholder Support*/
function IsInputPlaceholderSupport() {
    var i = document.createElement('input');
    return 'placeholder' in i;
}
$(document).ready(function () {
    if (!IsInputPlaceholderSupport()) {
        var fields = $('input');
        for (var i = 0; i < fields.length; i++) {
            if (fields[i].attributes['placeholder'] != undefined) {
                fields[i].defaultValue = fields[i].attributes['placeholder'].value;
                fields[i].value = fields[i].attributes['placeholder'].value;
                fields[i].onfocus = function () { if (this.value == this.defaultValue) this.value = ''; };
                fields[i].onblur = function () { if (this.value == '') this.value = this.defaultValue; };
            }
        }
    }
});
/* End Input Tag Placeholder Support*/


Yours,
Roi

15 February 2013

Preventing copy-paste all the rich text editor in SharePoint

As part of an accessible Web sites in SharePoint, this time I will present the code prevents the copy-paste.

The following code prevents copy-paste content editor rich text field


/*  ECM  */
function disablePasteForRTE() {
    Type.registerNamespace("RTE");
    if (RTE) {
        if (RTE.RichTextEditor != null) {
            RTE.RichTextEditor.paste = function () {
                RTE.Cursor.paste(true);
            }
            RTE.Cursor.$3C_0 = true;
        }
    }
}
if (_spBodyOnLoadFunctionNames != null) {
    _spBodyOnLoadFunctionNames.push('disablePasteForRTE');
}
/* End ECM *




Your... Roi

08 February 2013

Construction of correct design patterns in SharePoint

As in the previous post, to avoid content editor put the wrong color and not merit.

You need to built styles for content editor



How do I add style?

Add the following CSS code to the Master-Page

h1.ms-rteElement-YourTitle
{
    -ms-name: "Your Title";
    font-family: arial;
    font-weight: bold;
    font-size: 14.5pt;
    color: #9bbe08;
    height: 33px;
    line-height: 33px;
}


Thanks,
Roi

Prevention design is not good for Accessibility in SharePoint

Often, the editors of the content of Web sites write the content and design they give does not match the colors of the site and do not match the colors of accessibility.

To prevent them from putting bright pink, or to establish rules, remove the redundant design.

Before

After


Put the following CSS code in your Master Page (preferably course file)


#Ribbon\.EditingTools\.CPEditTab\.Font
{
    display: none;
}
#Ribbon\.EditingTools\.CPEditTab\.Paragraph-Large-0-0-0,
#Ribbon\.EditingTools\.CPEditTab\.Paragraph-Large-0-0-1
{
    display: none;
}


Yours,
Roi

Website Accessibility in SharePoint


As part of my work I had to build accessible Web sites
This article explains what is accessible and why we need it.
The following articles explain how accessibility can be applied in practice in SharePoint



What is Website Accessibility?

Accessibility is defined as a need to increase the use of people with disabilities (blind, color blind, deaf, have problems with motor or cognitive) sites and computer systems.
Accessible websites are websites that allow people with disabilities and older people to browse at the same level of efficiency and fun as surfing the Internet. Accessible Web Development is not just a matter of social responsibility and compliance with laws and regulations.
December 2008 announced a new version with accessibility guidelines (version 2.0) - This version is the binding version.
Differences of the three access levels:
• Priority 1 - A basic level of accessibility
• Priority 2 - AA basic level of accessibility
• Priority 3 - highly accessible AAA
Accessible Web site must meet at least Priority 1 guidelines.
Government sites are committed to follow instructions priority level A and AA.

Priorities examples:


Priority 
Description
Section
Class
 1
Until user agents allow users to control flickering, avoid causing the screen to flicker
 7.1
General 
 1
Provide redundant text links for each active region of a server-side image map.
 1.2
Images
 2
 Until user agents allow users to turn off spawned windows, do not cause pop-ups or other windows to appear and do not change the current window without informing the user
 10.1
General 
 2
Do not use tables for layout unless the table makes sense when linearized. Otherwise, if the table does not make sense, provide an alternative equivalent (which may be a linearized version).
 5.3
 Tables
 3
Until user agents render text equivalents for client-side image map links, provide redundant text links for each active region of a client-side image map.
 1.5
 Images
 3
 Provide summaries for tables
 5.5
 Tables

Rules for writing accessible:

Web sites serve the entire population. Therefore, site content writing should be clear and simple, to the result to be understandable to people from all sectors of the population, including people with reading difficulties for various reasons.
Reading difficulties may be due to the following problems:
• lower level of education or language skills are limited.
• difficulties in understanding the language of the content of the site, if it is not language of the user.
• Learning Disabilities
When writing content to the site, be sure to visualize the range of users. Think of a - store received only an elementary education, the child still attends - elementary school, think of a new immigrant, a person with dyslexia and other people like that. Give these people names and faces and ask yourself each time whether they will be able to easily understand the content you write.

Bar Accessories - Accessibility

Icons or Tags arranged together and appear on all or most, pages (Master-Page). Components listed on the aids are often technical aids and tags linked to specific text on the site.
Usually positioned at the top of the screen above the main navigation menu.
The bar should appear on all pages of the site. Only a few cases can give the ruler, for example, windows open (Pop-Up Window).
Information should include the ALT component for each ruler related tags. The information will describe in more detail where the user tag will be leading graphic replacement for restricted users
It has a
Zoom in / out of fonts
Contrast the page
Orientation bar / breadcrumb navigation

In the following articles:


Online you will find many more rules accessible sites.
Roi




04 January 2013

Free Disk Space on SQL Server

We often are needed to develop command and control systems.
What happens if we need to develop a system that tell us about disk space SQL server
Here is the code
Select @@servername as 'SQL Server Name', getdate() as Date 
 EXEC master..xp_fixeddrives


Yours,
Roi