Since the new User Profile Batch Update API is not available on all tenants yet I have been using the “User Profile Bulk Property Updater” from the OfficeDevPnP samples at https://github.com/OfficeDev/PnP/tree/master/Samples/Core.BulkUserProfileUpdater

This bulk updates user profile properties in SharePoint Online through the use of a CSV file.

I am a big fan of Office 365 Developer Patterns and Practices and this sample is so usefull.

 

Here is the input format for the CSV fil to update your profiles with hiredate and birthday:

UserName,SPS-HireDate,SPS-Birthday

i:0#.f|membership|atestusr03@unclouded.onmicrosoft.com,01/05/1971,12/04/1971

i:0#.f|membership|atestusr01@unclouded.onmicrosoft.com,11/08/1975,11/22/1975

i:0#.f|membership|atestusr02@unclouded.onmicrosoft.com,12/21/2012,07/03/2012

Tags: | Categories: SharePoint Configuration | SharePoint Development

All of the available out-of-the-box content types and their related columns in SharePoint Server 2013 are listed here in a post @JKevinParker http://www.jkevinparker.com/2014/02/sharepoint-2013-content-types-and.html

You can also find the xml for most of the built in content types at your SharePoint server under the 15 hive folder TEMPLATE\FEATURES\ctypes\

 

Here is the PowerShell to fetch all content types on a web

$site = Get-SPSite http://SharePointSite

$web = $site.RootWeb

foreach ($ctype in $web.ContentTypes) {$ctype.Name}

 

Go here for SharePoint Online content types in Powershell http://social.technet.microsoft.com/wiki/contents/articles/31151.sharepoint-online-content-types-in-powershell-get.aspx

Content Type IDs

Content type IDs uniquely identify the content type and are designed to be recursive. Read more here about the way to construct a valid content type ID: https://msdn.microsoft.com/en-us/library/office/aa543822%28v=office.14%29.aspx

Tags: , | Categories: SharePoint Development | Tips and tricks

Got the error while scripting content type modifications with PowerShell and SharePoint 2010.

 

 

Error System.Management.Automation.MethodInvocationException: Exception calling 
"Update" with "1" argument(s): "The collection cannot be modified." ---> Microso
ft.SharePoint.SPException: The collection cannot be modified.
   at Microsoft.SharePoint.SPContentType.Update(Boolean updateChildren, Boolean
ignoreSealedOrReadOnly, Boolean throwOnSealedOrReadOnly, IList`1 exceptions)
   at Microsoft.SharePoint.SPContentType.Update(Boolean updateChildren)
   at Update(Object , Object[] )
   at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object ta
rget, Object[] arguments, MethodInformation methodInformation, Object[] original
Arguments)

AvailableContentTypes

I was using the AvailableContentTypes[$contentTypeName] to get the content type I wanted to change. But content types retrieved from this collection (as oppose to SPWeb.ContentTypes) are read-only.

$field = $web.Fields[$fieldName]
$cType = $web.AvailableContentTypes[$contentTypeName]
$fLink = new-object Microsoft.SharePoint.SPFieldLink $field
$cType.FieldLinks.Add($fLink)
$cType.Update($true)

The correct way is using the SPWeb.ContentTypes collection as the following code:

$field = $web.Fields[$fieldName]
$cType = $web.ContentTypes[$contentTypeName]
$fLink = new-object Microsoft.SharePoint.SPFieldLink $field
$cType.FieldLinks.Add($fLink)
$cType.Update($true)

 

Tags: , | Categories: SharePoint Development

Here is how to set column validation formula for SharePoint field to contain only numbers and only two symbols (fixed length). You have to use a “single line of text” field because the number field won’t work this way.

Here is the formula:

=IF(LEN(CustomSortOrder)=2,ISNUMBER(CustomSortOrder+0),FALSE)

This works for both SharePoint 2010 and 2013 and can be set in the user interface.

If you are creating a WSP:

Here is the xml for the field called “CustomSortOrder” is a required field with the deafult value set to “00”:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field
        ID="{[id]}"
        Name="CustomSortOrder"
        DisplayName="Sort Order"
        Type="Text"
        Required="TRUE"
        EnforceUniqueValues="FALSE"
        Indexed="FALSE"
        MaxLength="2"
        Group="CustomField">
    <Default>00</Default>
    <Validation Message="The value of this field must be between 01 and 99 and with 2 characters.">
=IF(LEN(CustomSortOrder)=2,ISNUMBER(CustomSortOrder+0),FALSE)
</Validation> </Field> </Elements>

 

In my search for this solution I found some other formulars at The Chris Kent blog:

 

Happy SharePointing.

 

Tags: , | Categories: SharePoint Development | SharePoint Configuration

Trying to filter a list on its workflow status is pretty non-intuitive. You need the special status codes. Theese will work with all workflows in ShaePoint even Nintex workflows.

Status Code

Status Description

0

Not Started

1

Failed on Start

2

In Progress

3

Error Occurred

4

Cancelled (i.e. Stopped by User)

5

Completed

6

Failed on Start (retrying)

7

Error Occurred (retrying)

8

(unknown)

9

(unknown)

10

(unknown)

11

(unknown)

12

(unknown)

13

(unknown)

14

(unknown)

15

Cancelled

16

Approved

17

Rejected

Theese status codes can be used in editing list view query in both the user interface and the CAML in the list schema.xml

image005

 

image006

Another little special SharePoint speciality is that the workflow status field is referenced as the 8 first letters in the workflow instance name and the value type as WorkflowStatus

References:

Tags: , , , , , | Categories: Tips and tricks | SharePoint Development | SharePoint Configuration

Here is a list of web template features to use in your SharePoint 2013 web template projects.

Make sure that each of the features in the table beneath is contained in the WebFeatures section in your ONET.XML

DisplayName

Feature ID

AccSvcAddAccessApp

d2b9ec23-526b-42c5-87b6-852bd83e0364

AnnouncementsList

00bfea71-d1ce-42de-9c63-a44004ce0104

BaseWeb

99fe402e-89a0-45aa-9163-85342e865dc8

BizAppsListTemplates

065c78be-5231-477e-a972-14177cc5b3c7

ContactsList

00bfea71-7e6d-4186-9ba8-c047ac750105

ContactsList

00bfea71-7e6d-4186-9ba8-c047ac750105

CustomList

00bfea71-de22-43b2-a848-c05709900100

DataConnectionLibrary

00bfea71-dbd7-4f72-b8cb-da7ac0440130

DataSourceLibrary

00bfea71-f381-423d-b9d1-da7a54c50110

DiscussionsList

00bfea71-6a49-43fa-b535-d15c05500108

DocumentLibrary

00bfea71-e717-4e80-aa17-d0c71b360101

EventsList

00bfea71-ec85-4903-972d-ebe475780106

EventsList

00bfea71-ec85-4903-972d-ebe475780106

ExternalList

00bfea71-9549-43f8-b978-e47e54a10600

FollowingContent

a7a2793e-67cd-4dc1-9fd0-43f61581207a

GanttTasksList

00bfea71-513d-4ca0-96c2-6a47775c0119

GettingStarted

4aec7207-0d02-4f4f-aa07-b370199cd0c7

GridList

00bfea71-3a1d-41d3-a0ee-651d11570120

HierarchyTasksList

f9ce21f8-f437-4f7e-8bc6-946378c850f0

IPFSWebFeatures

f9ce21f8-f437-4f7e-8bc6-946378c850f0

IssuesList

00bfea71-5932-4f9c-ad71-1557e5751100

LinksList

00bfea71-5932-4f9c-ad71-1557e5751100

MBrowserRedirect

d95c97f3-e528-4da2-ae9f-32b3535fbb59

MDSFeature

87294c72-f260-42f3-a41b-981a2ffce37a

MobilityRedirect

f41cc668-37e5-4743-b4a8-74d1db3fd8a4

MySiteMicroBlog

ea23650b-0340-4708-b465-441a41c37af7

NoCodeWorkflowLibrary

00bfea71-f600-43f6-a895-40c0de7b0117

PictureLibrary

00bfea71-52d4-45b3-b544-b1c71b620109

PremiumWeb

0806d127-06e6-447a-980e-2e90b03101b8

PromotedLinksList

192efa95-e50c-475e-87ab-361cede5dd7f

ReportListTemplate

2510d73f-7109-4ccc-8a1c-314894deeb3a

SiteFeed

15a572c6-e545-4d32-897a-bab6f5846e18

SiteFeedController

5153156a-63af-4fac-b557-91bd8c315432

SurveysList

00bfea71-eb8a-40b1-80c7-506be7590102

TaskListNewsFeed

ff13819a-a9ac-46fb-8163-9d53357ef98d

TasksList

00bfea71-a83e-497e-9ba0-7a5c597d0107

TeamCollab

00bfea71-4ea5-48d4-a4ad-7ea5c011abe5

WebPageLibrary

00bfea71-c796-4402-9f2f-0eb9a6e71b18

WikiPageHomePage

00bfea71-d8fe-4fec-8dad-01c19a6e4053

WorkflowHistoryList

00bfea71-4ea5-48d4-a4ad-305cf7030140

workflowProcessList

00bfea71-2d77-4a75-9fca-76516689e21a

WorkflowServiceStore

2c63df2b-ceab-42c6-aeff-b3968162d4b1

WorkflowTask

57311b7a-9afd-4ff0-866e-9393ad6647b1

XmlFormLibrary

00bfea71-1e1d-4562-b56a-f05371bb0115

Tags: , | Categories: SharePoint Development

The following table lists the locales/languages with an assigned Locale ID (LCID).

Helpful in development of solutions in multilingual environments.

Language

Country/Region

Locale ID

Afrikaans

South Africa

1078

Albanian

Albania

1052

Arabic

Algeria

5121

Arabic

Bahrain

15361

Arabic

Egypt

3073

Arabic

Iraq

2049

Arabic

Jordan

11265

Arabic

Kuwait

13313

Arabic

Lebanon

12289

Arabic

Libya

4097

Arabic

Morocco

6145

Arabic

Oman

8193

Arabic

Qatar

16385

Arabic

Saudi Arabia

1025

Arabic

Syria

10241

Arabic

Tunisia

7169

Arabic

U.A.E.

14337

Arabic

Yemen

9217

Armenian

Armenia

1067

Azeri (Cyrillic)

Azerbaijan

2092

Azeri (Latin)

Azerbaijan

1068

Basque

Spain

1069

Belarusian

Belarus

1059

Bulgarian

Bulgaria

1026

Catalan

Spain

1027

Chinese

Hong Kong S.A.R.

3076

Chinese

Macau S.A.R.

5124

Chinese

(Default Chinese-Simplified Locale ID)

People's Republic of China

2052

Chinese

Singapore

4100

Chinese

Taiwan

1028

Croatian

Croatia

1050

Czech

Czech Republic

1029

Danish

Denmark

1030

Divehi

Maldives

1125

Dutch

Belgium

2067

Dutch

Netherlands

1043

English

Australia

3081

English

Belize

10249

English

Canada

4105

English

Caribbean

9225

English

Ireland

6153

English

Jamaica

8201

English

New Zealand

5129

English

Republic of the Philippines

13321

English

South Africa

7177

English

Trinidad and Tobago

11273

English

United Kingdom

2057

English

(Default English Locale ID)

United States

1033

English

Zimbabwe

12297

Estonian

Estonia

1061

Faroese

Faeroe Islands

1080

Farsi

Iran

1065

Finnish

Finland

1035

French

Belgium

2060

French

Canada

3084

French

(Default French Locale ID)

France

1036

French

Luxembourg

5132

French

Principality of Monaco

6156

French

Switzerland

4108

FYRO Macedonian

Former Yugoslav Republic of Macedonia

1071

Galician

Spain

1110

Georgian

Georgia

1079

German

Austria

3079

German

(Default German Locale ID)

Germany

1031

German

Liechtenstein

5127

German

Luxembourg

4103

German

Switzerland

2055

Greek

Greece

1032

Gujarati

India

1095

Hebrew

Israel

1037

Hindi

India

1081

Hungarian

Hungary

1038

Icelandic

Iceland

1039

Indonesian

Indonesia

1057

Italian

(Default Italian Locale ID)

Italy

1040

Italian

Switzerland

2064

Japanese

Japan

1041

Kannada

India

1099

Kazakh

Kazakhstan

1087

Konkani

India

1111

Korean

Korea

1042

Kyrgyz

Kyrgyzstan

1088

Latvian

Latvia

1062

Lithuanian

Lithuania

1063

Malay

Brunei Darussalam

2110

Malay

Malaysia

1086

Marathi

India

1102

Mongolian

Mongolia

1104

Norwegian (Bokmål)

Norway

1044

Norwegian (Nynorsk)

Norway

2068

Polish

Poland

1045

Portuguese

Brazil

1046

Portuguese

Portugal

2070

Punjabi

India

1094

Romanian

Romania

1048

Russian

Russia

1049

Sanskrit

India

1103

Serbian (Cyrillic)

Serbia and Montenegro

3098

Serbian (Latin)

Serbia and Montenegro

2074

Slovak

Slovakia

1051

Slovenian

Slovenia

1060

Spanish

Argentina

11274

Spanish

Bolivia

16394

Spanish

Chile

13322

Spanish

Colombia

9226

Spanish

Costa Rica

5130

Spanish

Dominican Republic

7178

Spanish

Ecuador

12298

Spanish

El Salvador

17418

Spanish

Guatemala

4106

Spanish

Honduras

18442

Spanish

Mexico

2058

Spanish

Nicaragua

19466

Spanish

Panama

6154

Spanish

Paraguay

15370

Spanish

Peru

10250

Spanish

Puerto Rico

20490

Spanish

Spain

1034

Spanish

Uruguay

14346

Spanish

Venezuela

8202

Spanish - Modern Sort

(Default Spanish Locale ID)

Spain

3082

Swahili

Kenya

1089

Swedish

Finland

2077

Swedish

Sweden

1053

Syriac

Syria

1114

Tamil

India

1097

Tatar

Tatarstan

1092

Telugu

India

1098

Thai

Thailand

1054

Turkish

Turkey

1055

Ukrainian

Ukraine

1058

Urdu

Islamic Republic of Pakistan

1056

Uzbek (Cyrillic)

Uzbekistan

2115

Uzbek (Latin)

Uzbekistan

1091

Vietnamese

Viet Nam

1066

Welsh

United Kingdom

1106

 

Reference:

http://msdn.microsoft.com/en-us/library/ms912047%28v=winembedded.10%29.aspx

Tags: | Categories: Web development | SharePoint Development
Invalid text value. A text field contains invalid data. 
Please check the value and try again.

Got this message in the ULS after starting a workflow. After some testing, re-deploys and cursing I found the answer: I was adding to much text to a single line text field!
It happens when the value you are adding for a text field is larger than 255 characters, so use lesser characters or change the type to a note field.

Well not much of a helpful error message but again, its SharePoint. Smile

Links
ULS

w3wp.exe (0x1898)

0x1980

SharePoint Foundation

Workflow Infrastructure

72er

Medium

Message:

Microsoft.SharePoint.SPException: Invalid text value. A text field contains invalid data. Please check the value and try again. ---> System.Runtime.InteropServices.COMException (0x81020018): Invalid text value. A text field contains invalid data. Please check the value and try again. at Microsoft.SharePoint.Library.SPRequestInternalClass.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback) at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback) --- End of inner exception stack trace --- at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback) at Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion) at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion) at Microsoft.SharePoint.SPListItem.Update() at Microsoft.SharePoint.Workflow.SPWinOETaskService.CommitTask(Transaction txn, Object[] transData)

Tags: , , | Categories: SharePoint Development

Recently found this excellent post explaining the SharePoint UserProfile picture sizes and naming convention.

 

Naming convention for the thumbnail files:

Thumbnail Image File Name Size
Large domain_username_LThumb.jpg 144x144
Medium domain_username_MThumb.jpg 96x96
Small domain_username_SThumb.jpg 32x32

The full URL of the medium thumbnail (like, “ http:///User Photos/Profile Pictures/__MThumb.jpg”) is stored in the user profile database.

You can use this information like:

var picUrl = profile[PropertyConstants.PictureUrl].Value as string;
this.imgUser.ImageUrl = picUrl.Replace("_MThumb", "_LThumb"); 

 

 read the full post Photo Management in SharePoint 2010 

 

Tags: , | Categories: SharePoint Development | Tips and tricks

Using the in the the wrong parameter with the SPWeb.GetList method you will receive a FileNotFoundException with the following very SharePoint-ish error message:

System.IO.FileNotFoundException: <nativehr>0x80070002</nativehr>
<nativestack></nativestack><nativehr>0x80070002</nativehr>
<nativestack></nativestack>

The stacktrace will often give more information but the ULS log it wil simply show:

<nativehr>0x80070002</nativehr>
<nativestack></nativestack>

So the parameter is incorrect; Either the URL does not specify a valid path to the website, or the list does not exist in the website.

The GetList method gets the list that is associated with the specified server-relative URL to the root folder of a list, such as /sites/sitecollection/subsite/Lists/Announcements.

HINT

You can use the SPUrlUtility.CombineUrl with your webs server relative URL like this:

var list = web.GetList(SPUrlUtility.CombineUrl(web.ServerRelativeUrl, 
"lists/" + listFolderName));

I prefer to use the SPWeb.GetList over the SPWeb.Lists Property. Endusers can easy change the list title in the GUI but it is harder to change its URL.

Be aware; there are other methods casting System.IO.FileNotFoundException!

Tags: , , , | Categories: SharePoint Development | Tips and tricks