08 December 2012

Update and synchronize user names in SharePoint

Often - people change their names in the organization - getting married, getting divorced, or just decide to change their name because ...

For some reason, SharePoint can not synchronize the new names.



Here's a command  for a version of SharePoint 2007 and up that will help you


stsadm -o migrateuser -oldlogin Domain\OldUserName -newlogin Domain\NewUsername -ignoresidhistory

For a version of SP 2010 and up , With PowerShell


Move-SPUser –Identity "Domain\OldUserName" –NewAlias "Domain\NewUsername"


Enjoy,
Roi

07 December 2012

Procedure links to government sites

Some of the requirements of government Web sites or sites of municipal authority, that if there is an external link, the client will notice that explains to him that the site is directed not belong to the same authority.



Here is a Jquery code that can help you


$(document).ready(function () {

    $("a").click(function(event) {

        // check if the target link is yoursite.gov

        // if not will show alert message

        if (this.href.indexOf("yoursite.gov") == -1) {

            if (this.href.startsWith("http")) {

                event.preventDefault();

                var linkLocation = this.href;

                alert('Please note that you are directed to an external site does not belong to this government ');

                window.open(linkLocation, '');

                return false;

            }

        }

    });

});


Thank you,
Roi

05 November 2012

SharePoint List showed twice

You happen to write a List Definition and of course it Schema.xml file.

I also went a few times :)

But .. What happens that you copy a code that you have before?

It is said that the "copy - paste" is the programmer's best friend (after Google, of course)

I copied DefaultView=true twice, and I see it in "view all site content" the list showed twice (each time for a different view)

<Views>
   ...
   <View>
     ...
     DefaultView = "True"
     ...
   </View>
   <View>
     ...
     DefaultView = "True"
     ...
   </View>
</Views>




All you need to remember is to type only "DefaultView = true" once!

Roi.

 

01 November 2012

Add-SPSolution: Failed to extract the cab file in the solution

Did you happen to get the following error message when you did the command Add-SPSolution at PowerShell (or stsadm -o addsolution ...)?

Add-SPSolution: Failed to extract the cab file in the solution

Add-SPSolution: Failed to extract the cab file in the solution

In my case a file called by graphic artist as q&a.jpg (questions and answers).

Apparently not to use the characters in solution as ~ ! @ # $% ^ & *

Who had written DDF files should know that. I've forgotten :)

Enjoy,
Roi Kolbinger






22 October 2012

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters

When you try to compile a project in visual studio and get this message

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters



All you need is to correct an error that VS created (and I do not know how)
He has written a number of times in the "Deployment Path"

"$ SharePoint.Project.FileNameWithoutExtension $ _ $ SharePoint.Feature.FileNameWithoutExtension $"



Instead of one in "Deployment Path"
It should be like this

"YourValue_ $ SharePoint.Feature.FileNameWithoutExtension $"

Yours,
Roi
 

11 October 2012

Image not rendered at RichImageF​ield

Who has not sat for hours on code and trying to figure out a problem.

This happens to me from time to time.

This time I will share with you in case of building PageLayout allows adding an image (RichImageField).

Microsoft's programmers apparently thought that the "order" is important.
Also does not make any sense.

That's what comes of trying to add RichImageField and rendered no image.
We are in "&#160;" instead of a image.

Now if we reduce the RichImageField down (in my case under RichHtmlField)...

Everything works fine.

Microsoft programmer with a sense that I do not understand - can someone explain to me?

I hope I helped,
Roi

16 September 2012

SharePoint 2013 - view all site content

Finally, after not significantly changed even from SharePoint 2003, SharePoint 2013 at this time, you could say changed the UI screen "view all site content sharepoint"

In SharePoint  2010 it looks like this


In SharePoint  2013 it looks like this



  • Instead of "Create" has "Add an app".
  • Changed shape - more like squares of Windows 8 (Metro)
  • And even the setting is on the top menu and not in the side

I'm just beginning to learn in 2013 - that expects you to much more updates on
It is currently

Thank you all,
Roi Kolbinger

22 August 2012

Familiar programming model using web standards in SharePoint 2013

One of the interesting things I see in this SharePoint 2013 - Familiar programming model using web standards
According to the article - What's new for developers in SharePoint 2013, Although the article does not specifically extends,, But it gives us a big picture of the structure of SharePoint 2013.
Like I said before - the SP 15 gives us the OAuth 2 protocol - available to help us connect to other social like Facebook.



Then of course there is support for HTML, CSS and JavaScript. Also has support for OData (Open Data protocol). and it has a support for ReST ( Represntationl State Transfer).

I will update soon after I will learn it.

Yours,
Roi

02 August 2012

Invalid column name - sql server

This case that happened to me when creating SQL table column

I created a SQL table column.
Then I received the following message on StoredProcedure or even in Select.

Invalid column name


Invalid column name


Invalid column name
What can be problem
  • 2 tables or one table with both columns
  • use Stored procedures to decouple scope
I wrote this query to see if there is a problem with my columns

select   name  from  sys.columns  where  object_id = object_id('Your_Table')

I didn't see any problem with my columns

OK....

What to do
  • Go to the table where they are added to the column, check whether it has a trigger (for each table by columns also have triggers), and if there is a table trigger, stopped him, and suddenly everything starts to work. If you open the trigger you will understand that change is copying the data to another table that there has to add the column and so on.
  • Press CTRL+SHIFT+R  on table !!!
It will solve your problem (I hope :) )

Yours,
Roi



26 July 2012

Why not work with the CSV file and encoding together

The answer is simple - Microsoft excel not support it.
Came to do simple experiments (next exercise does not need to know Development).
Open notepad-  Copy the following text (it is in Hebrew because of the example of the encoding)

עמודה 1, עמודה 2, עמודה 3
טקסט 1, טקסט 2, טקסט 3
טקסט 11, טקסט 22, טקסט 33

Now save it with encoding - Unicode.



The result you receive a Hebrew - but only one column.


Now save it with encoding of UTF-8 Now the columns fine but where the Hebrew?

If you try to open the same file in other programs such as One-Note it will work well.

My recommendation to work less with CSV (with ms. excel).

Yours,
Roi

17 July 2012

Apps for SharePoint 2013

A few days ago out version of the SharePoint  2013  (15) Beta.



An emerging idea of SharePoint 2013 is the Apps.

What is Apps for SharePoint? And how is it different from the Solutions?

To the best of my understanding, App is Package (. App) also contains a WSP course, but also AppManifest.xml and Other files.

While solution (WSP) can build by self-developed or from Third-party.
The app can be obtained from Internal App Catalog (contains apps approved and uploaded by the organization) or from Public SharePoint Store.

Apps can be used in your hosted or on-premises SharePoint App code is installed on a separate web site from your other sites in its own, isolated, domain or in the cloud (cloud-based apps).
While Solutions can be used in your hosted (sandbox solutions only) or on-premises SharePoint Solution code is installed as a full trust solution (in the global assembly cache) or as a sandboxed solution.

For more information. You  can be viewed at …
SharePoint 2013 Preview: App Overview for IT Pro
http://www.microsoft.com/en-us/download/details.aspx?id=30373

Other interesting links:
Download Microsoft SharePoint Server 2013 Preview
http://technet.microsoft.com/en-US/evalcenter/hh973397.aspx?wt.mc_id=TEC_121_1_33
SharePoint Foundation 2013 Preview
http://www.microsoft.com/en-us/download/details.aspx?id=30373

There will be continued on SP 2013...
Yours,
Roi K

08 July 2012

Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.

How to insert/update image column om SQL?

When you try to do this on sql server 2008 you got an error

update [tbl_items] set [ImagePlayer]='C:\Projects\Images\item.jpg' where [ID]=1

The error message was:

Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.


Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query

All you need is to do BulkColumn

Code for update

update [tbl_items] set [ImagePlayer]=BulkColumn FROM OPENROWSET(Bulk 'C:\Projects\Images\item.jpg', SINGLE_BLOB) AS BLOB where [ID]=1


(1 row(s) affected)

Code for Insert

INSERT INTO [ScoutMe].[dbo].[tbl_Players]   ([ID],   [ImagePlayer])   SELECT 1,      BulkColumn FROM OPENROWSET(       Bulk 'C:\Projects\Images\item.jpg', SINGLE_BLOB) AS BLOB

Yours,
Roi Kolbinger :)


01 July 2012

Saving changes is not permitted - Sql server

I got an error message when I try to change my table on sql server 2008 R2


Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.

Saving changes is not permitted 

All you need to is go to:

Options -> Designers -> Table and Database Designers ...
and turn off the "Prevent saving changes that requirde table re-creation"

Prevent saving changes that requirde table re-creation


and click OK Twice

User Chenges


Thanks,
Roi

30 June 2012

An attempt was made to load an assembly with an incorrect format microsoft.sharepoint.search.dll

I recently came across the following error message when I gotten compile the project in release - after success in debug

An attempt was made to load an assembly with an incorrect format microsoft.sharepoint.search.dll


The solution is simple

go to Project Properies -> Build ...
and trun off the Generate serialization assembly

Generate serialization assembly

Yours,
Roi

02 June 2012

OAuth 2.0 protocol

Today to share information of sharepoint with Facebook, Twitter, linkedin, google or live edu you need to create a SSO (single sign-on).
As it seems, in sharepoint 15 (2013) we get a new protocol called OAuth 2.0.

What is OAuth 2.0 protocol?

OAuth 2.0 is an upgrade of Frotokl OAuth from 2006 (a more advanced generation evolution of the protocol). It allows us to authenticate a user and give it a specific and temporary approval of our application. OAuth specification is being developed in IETF WG and shell based on OAuth.
The protocol has been implemented in applications of Android and iPhone user receiving the operating system (Yes. .. Android does not send the details of your gmail any foreign entity).
Think now about a world in which the SP talking to him Ioser of Facebook, and get him to only specific permissions to share some information.

SharePoint  15 will be continued...
Roi

02 May 2012

Enable-SPFeature: The Feature is not a Farm Level Feature and is not found in a Site level defined by the Url

After running the following command

Enable-SPFeature-Identity DocumentSet-URL http://url

I received the following error

Enable-SPFeature: The Feature is not a Farm Level Feature and is not found in a Site level defined by the Url ...

Why ???

It happened to me because I copied some files at the time manually (not using the solution).
The team system locks the files to ReadOnly.
And the command fails (the readonly found only a deep excavation in the log files of sharepoint)



The solution: Disables the ReadOnly for all the files in sub folders.
It can be found here:

Uncheck read only file for all sub folder with PowerShell

I use this code at 14\Template folder
Thanks,
Roi

23 April 2012

Uncheck read only file for all sub folder with PowerShell

This time I'll introduce PowerShell code that disables the read only for all the files in sub folders (Recurse)


The code:

$Path = "your root folder"
$Files = Get-ChildItem $Path -Recurse
ForEach ($File in $Files)
{
   Write-Host "File: " 
$File "IsReadOnly: " $File.IsReadOnly
   if ($File.Attributes -ne "Directory" -and $File.Attributes -ne "Directory, Archive")
   {

      if ($File.IsReadOnly -eq $true )
      {
          try 

          {
               Set-ItemProperty -path $File.FullName -name IsReadOnly -value $false
               write-host "file:" $File.FullName "is now false read only"  -foregroundcolor "magenta"
          }
          catch 
[Exception] 
          {
               Write-Host "Error at file " $Path "\" $File
               Write-Host $_.Exception.Message
          }
      }
    }
}

Code should help you, especially you're working with the team system - which locks the files to ReadOnly



Yours,
Roi

11 April 2012

System.Web​.HttpUnhan​dledExcept​ion: Failed to load viewstate

Event:
Getting error while loading control - the GridView in CreateChildControl that uses ViewState

Error:

System.Web.HttpUnhandledException: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

The solution:
Transfer the load of the ViewState to PreRender (from CreateChildControl)

The lesson:
Better understand the life-sycle of loading (seems that no matter the experience, are always making mistakes of a beginner :) ...)

Cheers,
Roi

09 April 2012

SharePoint 2010: Set session timeout on an FBA enabled site

One of the problems SharePoint 2010 when trying to work on Forms Based Authentication (FBA), all the settings in IIS (and web.config) enable sessions of not working.

After researching on google, I realized it was a problem in SP 2010.
There are many blogs that give code that fixes the problem by correcting the global.asax. I checked and indeed it works, but it does not seem the ultimate solution.

Best solution is (for me) working on SharePoint 2010 SP1. A code of PowerShell.

Code:

$sts = Get-SPSecurityTokenServiceConfig
$sts.LogonTokenCacheExpirationWindow = (New-TimeSpan –minutes 20)
$sts.WindowsTokenLifetime = (New-TimeSpan –minutes 20)
$sts.FormsTokenLifetime = (New-TimeSpan -minutes 20)
$sts.Update()
Iisreset

You can change the 20 minutes, of course.

Hope I helped,
Roi

08 April 2012

Custom Timer Jobs: func FeatureActivated Access denied

Things worked in the past - do not work more
And today issue timer job

At MOSS 2007 on the timer job worked, and Today at SharePoint 2010 the timer job runs on owstimer.exe and get an error that the timer job does not work

The Error Message:

The description for Event ID 0 from source Application can not be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Custom Timer Jobs: func FeatureActivated Access denied.

The solution - PowerShell

Run this code:

$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
# turn off remote administration security
$contentService.RemoteAdministratorAccessDenied = $false
# update the web service
$contentService.Update()

Yours,
Roi

22 March 2012

Short text contents by size on client side

This time I bring code that can help you with working with text.
The following code is the client side (javascript - jquery) and receive text and shortens it. Finally, it adds three dots (...)

// -- Fix width size, add "..." if the size is big --
// Example:
// Before:
// <p id='MyID'>text text text text</p>
// ...
// var el = $('#MyID'); 
// FixWidthSize(el, 10);
// ...
// After: 
// <p id='MyID'>text text ...</p>
function FixWidthSize(el, size) {
    var originalText = el.html();
    var w = el.width();
    var text = originalText;
    while (text.length > 0 && size < el.width()) {
        text = text.substr(0, text.length - 1);
        el.html(text + "...");
    }
}

So it seems, before and after

Yours,
Roi

06 March 2012

A sharepoint list view of the current month

Who has not asked to make view of the current month?
And every time we need to reinvent the wheel.

This time I'll show how to do this:

Need to create two columns
1. Start of the Month
2. End of the Month
Two columns need type -"calculated"

The formula of "Start of the Month"

=DATE(YEAR(Created),MONTH(Created),1)



The formula of "End of the Month"

=DATE(YEAR(Created),MONTH(Created)+1,1)-1

The view definition in the "Filter":

"Start of the Month" is Less than or Equle to [Today]
Or
"End of the Month" is Greater than or Equal to [Today]

Here is the result:
Hope i helped,
Roi

24 February 2012

SharePoint 2013 is here

On the horizon loomed a new version of SharePoint! On the Microsoft site appeared SharePoint 2013 Technical Preview Managed Object Model Software Development Kit.

What is it?
On the download page says that the functionality described in the SDK, only applies to the interaction with other applications, Microsoft. So, what will happen with CAML-queries, receive a further development of Linq to SharePoint is still not clear.

Download here : http://www.microsoft.com/download/en/details.aspx?id=28768

SharePoint App Store
Much points to the fact that the new SharePoint'e appears something like the online application directory (sandbox solutions) that you can download and install on your portal. That such a method SPWeb.LoadAndInstallApp, which takes a parameter of type Stream (ie package) and returns an object of type SPAppInstance (Represents an SPApp object installed to a specific SPWeb site).
We'll have to reconsider plans for boxed portals like Deskwork. All hope of integration with corporate systems and customer-specific software

Facebookable
No less interesting is the class SPOAuth2BearerCredentials (Provides credentials for authentication with a service that supports OAuth 2.0 bearer token authentication). Now you can log in to your account using facebook. Socialization, which appeared in SharePoint 2010, walking out of his father's house.

Resource Management on page
Now you do not have to guess, is registered on the page jQuery or not. For this purpose, a new static class SPPageContentManager, having for this purpose a handful of static methods.

Let's wait for the new version.
Roi

17 February 2012

No need to dispose in 2010 at SPWebInfo object

Who has not encountered during the development toolpart - create a dropdownlist with a list of all sites.

The 2007 version used with SPWeb object and it must to make a Dispose.
 
// 2007
using (SPSite site = new SPSite("http://mysite"))
{
    foreach (SPWeb web in site.AllWebs)
    {
        ddlWebs.Items.Add(new ListItem(web.Title,web.ID.ToString()));
        // ... Continuing operations ...
        web.Dispose();
    }
}

The 2010 version we use object SPWebInfo.
In SPWebInfo we do not we will dispose.

Here is an example (in this case a loop that sets the title and ID for dropdownlist )

// 2010
using (SPSite site = new SPSite("http://mysite"))
{
     foreach (SPWebInfo webInfo in site.AllWebs.WebsInfo)
     {
          ddlWebs.Items.Add(new ListItem(webInfo.Title, webInfo.Id.ToString()));
          // ... Continuing operations ...
     }
}

SPWebInfo object contains:
Properties: Configuration, CustomMasterUrl, Description, Id, Language, LastItemModifiedDate, MasterUrl, ServerRelativeUrl, Title, UIVersion, UIVersionConfigurationEnabled, WebTemplateId
Methods : Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString


Yours,
Roi

28 January 2012

Cannot assign to 'obj' because it is a 'foreach iteration variable'

I asked during a job interview is there a difference between for to foreach are not in terms of performance in terms of working with objects. Can I update the same set of both?
Desalination to see which candidate did not know the answer.
I'm not going to explain who was stronger for or foreach.
That you can read the article by Dustin Campbell - Performance of foreach vs. List.ForEach.
So I'll give a practical example, explain the difference from for to foreach when both cases I'm going to update my system.

Here's the code for example:
Is for or/and  foreach will update the List?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace CheckFor
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> arr = new List<string>();
            arr.Add("aaa");
            arr.Add("bbb");
            arr.Add("ccc");
            arr.Add("ddd");
            arr.Add("eee");
            arr.Add("fff");
            for (int i = 0; i < arr.Count; i++)
            {
                arr[i] = arr[i].ToString() + arr[i].ToString();
            }
            foreach (string obj in arr)
            {
                obj = obj + obj;
            }
        }
    }
} 

Then there are those straight to see a foreach loop can not update items because it actually makes a copy for collection, while a for loop can update the objects because it really is on the objects.

Again, I'm not going to explain what it means by value and by reference.
But if you meet the following message - remember the meaning of objects update

Cannot assign to 'Your object' because it is a 'foreach iteration variable'

Example of the error

Cannot assign to 'obj' because it is a 'foreach iteration variable'

Yours,
Roi

16 January 2012

SharePoint - Export to Spreadsheet (excel) Not Work

Did you have a case where you wanted to work in Excel at sharepoint list view, but you had no some fields (like lookup field)?
Can not "Export to Spreadsheet"?

I had the case!
Two solutions:
1 - Install SPD (is free).
2 - Because not every time we run straight to install the SharePoint Designer.
The solution to install SharePoint.ExportDatabase activeX.

Here's how to install the activeX of the excel
Run from Address Bar this code

javascript: var x =new ActiveXObject("SharePoint.ExportDatabase");


Address bar
To see that it worked, do the following ...

1. Go to (from IE) tools -> Internet Option

Internet Option
2. Programs -> Manage add-ons

Manage add-ons
3. All add-ons

All add-ons
And see that ActiveX is enable :)

There are more activexs needed to operate the sharepoint
javascript: var x = new ActiveXObject("Microsoft.XMLDOM");
javascript: var x = new ActiveXObject("ListNet.ListNet");
javascript: var x = new ActiveXObject("DiagramLaunch.DiagramLauncher");

If it does not help - you have to install SPD :(
Yours.
Roi

08 January 2012

Webpage error details. Object required


Not long ago, I created a new master-page (from scratch) at SharePoint Designer.
I'm done to add all the controls - looks good!
But when I started working with web-parts - had a little problem. Drag and Drop did not work.

I received the following error:

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Timestamp: Sun, 8 Jan 2012 11:46:30 UTC

Message: Object required
Line: 1571
Char: 3
Code: 0
URI: http://yoururl/ie55up.js



Webpage error details. Object required


Google search brought me to the following blog:
Neil Mosafi  - http://neilmosafi.blogspot.com/2007/11/sharepoint-dragging-webparts-causes.html
When I added the code - he really helped me

<script language="javascript" type="text/javascript">
function MSOLayout_GetRealOffset(StartingObject, OffsetType, EndParent)
{
  var realValue=0;
  
if (!EndParent) 
    EndParent=document.body;
  
for (var currentObject=StartingObject; currentObject && currentObject !=EndParent && currentObject != document.body; currentObject=currentObject.offsetParent)
  
{
    
var offset = eval('currentObject.offset'+OffsetType);
   
if (offset)

      realValue+=offset;
  
}
  
return realValue;
}

</
script>

thanks Neil :)

Something I want to emphasize - it put the code as much as possible at the end of the page.

Hope I helped,
Roi