Homepage - Isrichtig.de
Zum Hauptinhalt wechseln
VHelms

Isrichtig.de

Suchen
Homepage
Kontakt
Impressum
  
 

RSS-Feed

Blog von Volker Helms
April 18
How to update Fieldvalues from other Field in your own BaseFieldControl

Hi,

today I have the problem with my custom LookupField. The LookupField uses its own field and another lookupfield from the list. The other field ist not visible in the normal edit form. So i must set the value from the other lookupfield in my basefieldcontrol code. How to do this:

public override void UpdateFieldValueInItem()

{

if (Some logic if the value is a good value)
{
//save the parent value
var lookupValue = new SPFieldLookupValue(int.Parse(_ParentDropdown.SelectedItem.Value), _ParentDropdown.SelectedItem.Text);
SPField parentField = ListItem.Fields.GetFieldByInternalName(CurrentItemParentFieldName);
BaseFieldControl parentRenderControl = parentField.FieldRenderingControl;
parentRenderControl.Value = lookupValue;
parentRenderControl.UpdateFieldValueInItem();

Value = string.Format("{0};#{1}", _ChildDropdown.SelectedItem.Value, _ChildDropdown.SelectedItem.Text);
}
base.UpdateFieldValueInItem();
}

The differences between Value and ItemFieldValue can be found here.

April 10
CopyUpsProps Tool to export or import UPS Properties

Hi together,

often you have different farms in your company. Maybe one test farm, an integration farm and a productive farm. So, before you go productive you configure your user profile properties in the user profile service. You add some props and modify the order of the properties. These needs much time because you can only move one prop one step up or down. If you want to move 10 steps up you must click the up button 10 times and every click need a couple of seconds. Not so funny to configure. So I have written a little tool to export your configuration and import it to another farm. OK, you must configure die Properties one time to create a master configuration. But then export it and if needed import it to another farm.

How to use the Tool:

CopyUPSProps.exe http://siteurlofonewebapp "AD Connection Name" -import|-export"

The AD Connection Name is the Connection Name from the User Profile Service.


image

If the tool can’ t find the AD connection name it will ask you if you want to continue.

image

Sometimes the tool can’t find the connection, because your user have not the correct ups permissions. Please Check the Administrators and the Permissions of the User Profile Services.

image

What does the tool? If you use the –export option the tool will create a xml file with the ups properties.

Here you can see an Example:

image

You can take a look at the file and see what happens. Most of the properties are written out to the file. With the –import option you can then import this xml file to another SharePoint Farm.The tool does not delete properties that are on the import farm and not on the export farm. The tool updates all properties if they are different. But some property values can’t be updated after the creation. In this situation the tool gives you no info. It simply does not change the value. Properties that are not available on the Import Farm will be created. If the tool can’t find the AD Connection and you have answered with “Yes” to continue, the tool does not configure the AD Connection value.

This tool is in beta status. So please test it before using it on a productive system. Please report any errors or if you have an improvement.

If you see an error like this check the permissions of the user. The user must have permissions on the site, user profile service and the user profile connections (see screenshot above).

image

Download

Hope this tool helps to save some time.

Volker

März 22
How to configure Task List with "Send e-mail..." attribute
You have a list definition with inherits from a task list or you use a list instance with the customschema attribute in your solution and you want to activate the "Send e-mail when ownership is assigned" property for a list. So what todo in the schema.xml file to get this property activated? This is really simple. You only have to add the EmailAssignTo="TRUE" attribute to the <List .../> tag. Hope this helps, Volker
Februar 03
Uploading files using Client Object Model in SharePoint 2010

I want to upload a file through the COM to a document library in SharePoint 2010. So I used something like this:

   1:  ClientContext context = new ClientContext("http://blog.isrichtig.de");
   2:  Web web = context.Web;
   3:  List list = web.Lists.GetByTitle("Shared Documents");
   4:  FileCreationInformation uploadFile = new FileCreationInformation();
   5:   
   6:  string fileCompletePath = @"C:\Temp\MyDoc.docx";
   7:  string fileName = Path.GetFileName(fileCompletePath);
   8:   
   9:  var uploadFile = new FileCreationInformation
  10:  {
  11:    Content = File.ReadAllBytes(fileCompletePath),
  12:    Url = string.Join("/", new[] { docList.ListUrl, fileName })
  13:  };
  14:   
  15:  var uploadFile = list.RootFolder.Files.Add(uploadFile);
  16:   
  17:  context.Load(uploadFile);
  18:  context.ExecuteQuery();

But after some testing I get an error if the file size is above 3MB. The error message is “(400) Bad Request”. So what happens here? The file is encoded in BASE64 and the ClientContext has some limitations in the messagesize. I found a good explanation here.

So what can we do to upload the file without an errormessage? We have 2 possibilities:

1.) We modify the messagesize:

   1:  SPWebService ws = SPWebService.ContentService;
   2:  SPClientRequestServiceSettings clientSettings = ws.ClientRequestServiceSettings;
   3:  clientSettings.MaxReceivedMessageSize = 10485760;
   4:  ws.Update();

2. We use a different type of file uploading:

   1:  string fileCompletePath = @"C:\Temp\MyDoc.docx";
   2:  string fileName = Path.GetFileName(fileCompletePath);
   3:  string listUrl = @"/Shared Documents";
   4:  ClientContext context = new ClientContext("http://blog.isrichtig.de");
   5:  using (FileStream fs = new FileStream(fileCompletePath, FileMode.Open))
   6:  {
   7:      Microsoft.SharePoint.Client.File.SaveBinaryDirect(context, string.Join("/", new[] { listUrl, fileName }), fs, true);
   8:  }

 

Once again many thanks to sridhara2 for helping me understanding the problem.

Volker

Februar 03
SharePoint Export Users and Groups with Excel

Hello,

yesterday i have to export a user list from a SharePoint site collection. So how can i do this task without programming?

Here we go. First open the Site Collection in Internet Explorer and browse to Site Settings/ People and Groups. Switch to one group (it is not important which group) an copy the url to clipboard. Next open Excel 2010 and go to the Data Tab. Click “From Web”

clip_image002

Next, a new window opens and you can paste your url. You will get something like this:

image

You can select every table in this window. We want to select the users and groups table:

clip_image002[11]

Next, click Import:

clip_image002[13]

clip_image002[15]

Now we have a list with all users and groups from this site collection.

Volker

Januar 06
Easy WSP deployment
I have created a regfile and 2 batchfiles for easy wsp solution deployment on a SharePoint server. The regfile will add 2 context menu entries in the windows explorer. The batchfiles must be placed in the SharePoint BIN folder in the 14 hive.
 
 
Happy deploying,
Volker
 
Screenshot:
2012-01-06 09h37_20.png
November 22
Error – Failed to get value of the "ColumnName" column from the "Managed Metadata" field type control. See details in log. Exception message: Invalid field name. {GUID}
Yesterday I get this error message if I want to save an Publishing Page with an ContentType containing a Managed Metadatacolumn. After some googling I found some nice info's from Ari Bakker.
The problem occurs because the Managed Metadata Column creates an additional field named MMdColumnName_0 from type Note. In the Metadata Column the Notecolumn is mapped through the TextField Property. If the TextField Property is empty or has the wrong guid the error occours. So if the error occurs please compare the guid with the ID from the Notecolumn via SPM2010 (The column is hidden) and corret the guid. If the Note column is not availible please add the Column to the list or the content type and correct the guid in the metadata column.
 
Volker
Oktober 28
Get ID from Term to Filter Managed Metadata Field

Hi,
today, I have to find out the ID from a term to filter a Managed Metadata field with url parameters (listviewwebpart). The term itself gives me an id. So how to find out the assigned id. First, important to know is, the spweb has a hidden list named “taxonomyhiddenlist”. The list contains items which are associated with the terms.

So I googled a little bit and find this nice page from Peter Holpar who has written the necessary code. I have optimized the code a litte bit.

        public static int GetWssIdByTermId(SPWeb rootWeb, Guid termId)
        {
           int result = -1;
           if (rootWeb.Properties.ContainsKey("TaxonomyHiddenList"))
           {
              var taxonomyHiddenListId = new Guid(rootWeb.Properties["TaxonomyHiddenList"]);
              SPList taxonomyHiddenList = rootWeb.Lists[taxonomyHiddenListId];
              var query = new SPQuery {Query = String.Format(@"<Where><Eq><FieldRef Name='IdForTerm' /><Value Type='Text'>{0}</Value></Eq></Where>", termId)};
              SPListItemCollection items = taxonomyHiddenList.GetItems(query);
              if (items.Count == 1)
              {
                 result = int.Parse(items[0]["ID"].ToString());
              }
           }
           return result;
        }

Volker

Oktober 28
SetUrlParameter

This Codesnippet sets or adds an Url Parameter to a string.

        public static string SetUrlParameter(string url, string key, string value)
        {
            // find url parameter and replace or add if not availible
            var startIndex = url.IndexOf("?") + 1;
            if (startIndex == 0)
            {
                return string.Format("{0}?{1}={2}", url, key, value);
            }
            var oldQueryString = url.Substring(startIndex);
            var queryParameters = HttpUtility.ParseQueryString(oldQueryString);
            queryParameters[key] = value;
            return url.Substring(0, startIndex) + queryParameters;
        }
Oktober 17
RDP Zugriff Windows 2008R2: gleicher User – 2 Sessions

Unter Windows 2008R2 hat sich das Verhalten bei der Benutzung von RDP Sessions etwas geändert. Unter 2003 konnte man sich mit einem Anwender durchaus mehrfach anmelden (z.B. einmal an die Konsole und ein weiteres mal als Session). Unter 2008R2 wird für jeden User immer nur eine Session erstellt. Nutzt man einen Admin Account um den Server zu administrieren kommt es nun häufig vor, dass man dem netten Kollegen nebenan die Session klaut. Dies kann auf 2 unterschiedlichen Wegen wieder geändert werden, sodass sich der Server wie unter 2003 verhält.

1.

In dieser Variante kann einfach eine Gruppenrichtlinie erstellt werden, die das alte Verhalten wiederherstellt. Falls man keine globalen Gruppenrichtlinien konfigurieren, oder das Verhalten nur auf einem einzelnen Server nutzten möchte kann die Einstellung auch in der Lokalen Richtlinie eingestellt werden. Hier dazu ein Bild:

clip_image001

Der Eintrag heißt “Restrict Remote Desktop Services users to a single Remote Desktop Services Session”.

2.

Bei der zweiten Variante wird die Einstellung direkt über die Remote Desktop Connection Konfiguration durchgeführt. Dazu einfach unter Start in das Suchfeld "Remote Desktop Session Host Configuration" eingeben und im Fenster den Punkt "Restrict each user to a single session" Doppelklicken und entsprechend ändern. Hier ein Bild dazu:

clip_image001[6]

Gruß,
Volker

1 - 10Weiter

 Archiv

How to update Fieldvalues from other Field in your own BaseFieldControl
CopyUpsProps Tool to export or import UPS Properties
How to configure Task List with &quot;Send e-mail...&quot; attribute
Uploading files using Client Object Model in SharePoint 2010
SharePoint Export Users and Groups with Excel
Easy WSP deployment
Error – Failed to get value of the &quot;ColumnName&quot; column from the &quot;Managed Metadata&quot; field type control. See details in log. Exception message: Invalid field name. {GUID}
Get ID from Term to Filter Managed Metadata Field

 Downloads

CopyUPSProps.zipCopyUPSProps
clip_image0029_45B038FB.jpgclip_image0029_45B038FB
clip_image0029_thumb_45B038FB.jpgclip_image0029_thumb_45B038FB
WspDeployment.zipWspDeployment
Wiki2HtmlSrc.zipWiki2HtmlSrc
1 - 5Weiter