Archive for the 'SharePoint 2010' Category

22
Dec

How To modify the DefaultView of a List

 

If you want to modify the DefaultView of a programmatically created list you have to know a “bagatelle”.

First i tried it this way:

list.DefaultView.ViewFields.Add(list.fields.GetFieldByInternalName(“internalName”);

list.DefaultView.Update();

and nothing happened at all.

The reason lies in the property DefaultView which encapsulates a behavior in which in every call the View is instantiated again. So in the first line you would modifiy the first instance of the view. Than, you would update a new instance of the View, which is not modified or updated.

So, knowing this, what you have to do to make it working is the following:

Get the Instance, modifiy it, and safe it.

SPView view = list.DefaultView;

if(view.ViewFields.Exists("internalName")==false)
   view.ViewFields.Add(list.Fields.GetFieldByInternalName("internalName"));
view.Update();
22
Dec

How to set the default ContentType at a Library

 

Get All ContentTypes of the List.

List<SPContentType> ctl = new List<SPContentType>();
SPContentTypeCollection collection = list.ContentTypes;

Iterate over all ContentTypes of the List and compare your CustomContentType with all existing ContentTypes of the List. Compare the Name, not the ID.

Your CustomContentType has to be added to the List programmatically first.

Add the found/calculated ContentType to the List<SPContentType> ctl.

This is necassary in this manner, because after adding the ContentType to the List it gets a ID Appendix which you have to calculate first.

So if you would add your Custom ContentType directly to the List<SPContentType> ctl, it wouldn`t work, because exactly that ContentType is not existent at the SPList. When you add the ContentType to the SPList, it derives and has it`s own ID. So you first have to calculate the exact existent ContenType.

The complete Method looks like this:

private static void SetDefaultContentType(SPContentType CustomContentType, SPList list)
{
try
{
List<SPContentType> ctl = new List<SPContentType>();

SPContentTypeCollection collection = list.ContentTypes;

foreach (SPContentType ct in collection)
{
if (ct.Name.Contains(CustomContentType.Name))
{
ctl.Add(ct);
}
}

list.RootFolder.UniqueContentTypeOrder = ctl;
list.RootFolder.Update();
}
catch { }
}

03
Jun

SharePoint Formulas

Hi there,

i`m searching this site every time i have to create a complexer formula. So this time, i thought, i put it  in my blog as a reminder ;-)

http://msdn.microsoft.com/en-us/library/bb862071.aspx

A thing, you should have a look at, is the language dependant syntax in the formulas, f.e. on a german SP Server you have to use the “;” semicolon as a seperator in your formula, but on an english server a comma “,”. This is not mentioned in the msdn.

If you think of I18N and Solution Deployment, this is really a thing, microsoft should standardize.

14
Apr

Nintex Maintenance Best Practices in english

If you are working with complex Nintex Workflows, you should always keep an eye on the maintenance of your Environment. You should have especially a closer look to the Nintex Content Database and the hidden List “NintexWorkflowHistory”, if you are working with loops inside the workflow. This is necassary to avoid to run into performance issues, which is essentially in long time scenarios. Your system will be affected by this problem sooner or later, depending on your Solution. This is a result of the built in Logging Mechanism which can end in a excessive Database growth. But, knowing this, you can use built in NintexSettings in your Workflow and schedule some BatchTasks to keep your environment healthy and performant. I just want to describe the possibilities Nintex is giving us.

Nintex generates per default the following Entries in the ContentDatabase:

Number of Rows
Description
1 Row per Workflow
2 Rows per Action, which is executed
1 Row per TaskAction (Request Approval…)
1 Row for each Approver, which is participating to a Request
1 Row per each Delegation of a task

But that`s not all, there will be created a SPListItem for each executed Activity in the hidden List NintexWorkflowHistory. For example, i once found the List containing 4.5 Mio. entries affecting the whole environmentperformance massively.

But Nintex gave us some Tools to keep the System on track, even in Long Time Scenarios. Begin to avoid unneccessary entries to the db in your Workflow by Setting a Checkbox in the ConfigurationPanel of your Activity.

Dialog

Just have a closer Look to the Common Tab. You will find a checkbox there “Hide from workflow Status”, which is disabling the Loggingmechanism for this Activity. After you published your Workflow again, this Activity is not logging to the db anymore, which also means, that you can not see the Appearance of the Activity in the WorkflowHistory either. So you should do this after debugging your Workflow and knowing that everything behaves as expected. You can also configure, that the Activity is only executed at business Times. This also reduces the amount of logging entries especially when you use Loops, which maybe are running some days.

You can get rid of existing Entries by using a tool named NWAdmin. You will find this tool in the folder: “C:\Program Files\Nintex\Nintex Workflow 2010”

Create some BatchFiles there and do the following things:

1. Synchronize Nintex with the MS Workflow Foundation / Sync Terminated Workflows

NWAdmin.exe -o SyncTerminatedWorkflows -url “http.//url” -verbose -showMissingItems –terminateDeletedItems

Maybe you deleted some documents without ending a running workflow, you may have a discrepancy in the Workflowstati safed in the MS Workflow Foundation on the one hand and Nintex on the other hand. Deleted Items have to be terminated in Nintex. So you can do this with this command.

2. Purge Workflow Data

NWAdmin.exe -o PurgeWorkflowData -url http://url -state completed  -verbose

REM States: completed/cancelled/errored/all

You can delete existing log entries in the Nintex DB. Maybe for completed Workflows or cancelled and errored Workflows. You can even configure to only delte entries which are older than n days to keep some informations available for a while.

3. Purge Workflow History

NWAdmin.exe -o purgeHistoryListData -siteUrl “http:URL” -verbose -batchSize 500 -state completed

REM States: completed/cancelled/errored/all

You can remove ListItems from the mentioned List NintexWorkflowHistory.

Conclusion

Keeping this in mind, you will have a long time stable Workflow Environment!  Some of the mentioned things are configurable now in the CA if you have the Nintex Version >2.2 installed. The ToDos are valid (or a must) for Nintex 2007 either.

Create some BatchFiles and use you TaskScheduler to automate this. It´s a bit tricky to automate the manually needed Submission with “yes”. If you want to know how that works, don`t hesitate to contact us at ecspand, d-velop or leave a Comment.

Happy Coding!

24
Jan

SharePoint und die MS Workflow Foundation oder Nintex als brauchbare Alternative zu SharePoint Designer und Visual Studio

Ein Workflow ist die technische Abbildung eines Arbeitsprozesses.

Microsoft bietet mit dem SharePoint Server eine ideale Umgebung, um die geschäftseigenen Prozesse dokumentenbasiert abzubilden und mit Hilfe der Workflow Foundation technisch zu automatisieren. Ziel ist letztendlich immer die Einbindung und Benachrichtigung von prozessinvolvierten Personen. SharePoint bringt im Standard einige vordefinierte Workflows mit sich, wie zum Beispiel einen Freigabeworkflow oder einen einfachen Feedbackworkflow.

Häufig gibt es genau diese Prozesse aber so nicht in einem Unternehmen, oder es gibt weitaus komplexere Prozesse (Posteingangsworkflow, Eingangsrechnungsverarbeitung, QM usw.), die mit den bestehenden Workflows nicht abgebildet werden können.

SharePoint Designer

Microsoft gibt dem versierten Benutzer nun ein Werkzeug namens SharePoint Designer an die Hand, mit dem etwas komplexere Workflows ohne Programmierkenntnisse erstellt werden können. Das ist sicherlich für den ein oder anderen kleinen Anwendungsfall eine gute Sache. Sobald aber ein gewisser Komplexitätsgrad des Workflows überschritten wird, stößt man entweder an technische Grenzen oder verliert völlig den Überblick. Die Abbildung eines Workflows im SharePoint Designer ist wegen der verschachtelten tabellarischen Darstellung nämlich nicht ganz optimal gelöst. Hinzu kommt, das es eine Exportmöglichkeit eines einmal erstellten Workflows erst ab der Version 2010 gibt, d. h. ein Workflow musste im 2007er Umfeld für jede relevante Liste/Bibliothek neu erstellt und angebracht werden.

Visual Studio

Komplexe Workflows gibt Microsoft in die Hände des Entwicklers, der mit dem Visual Studio die Anforderungen seines Projektleiters abbilden kann. Auf dieser Ebene kann man nun wirklich die komplexesten Dinge anstellen, man muss allerdings Programmierkenntnisse mitbringen und sich darüber im Klaren sein, das Anpassungen zur Projektlaufzeit aufwendig sind und in der Folge kostspielig werden können.

Nintex

Nintex bietet hier eine Alternative. Nintex integriert einen Designer direkt in das UserInterface des SharePoints und bringt etliche so genannte Activities mit sich, mit denen auch recht komplexe Workflows ähnlich wie in einem FlowChart erstellt werden können. Gibt es Anforderungen, die nicht im Nintex Standard erfüllt werden, so kann man recht einfach so genannte Custom Activities entwickeln und fest in die Nintex Umgebung für die weitere Verwendung in sämtlichen Workflows integrieren. Nintex bietet also eine Mischung aus einem einfachen und übersichtlichen Designer, der es gerade zur Projektlaufzeit ermöglicht, sehr schnell auf neue Anforderungen zu reagieren und die Möglichkeit mit Programmierkenntnissen und dem Visual Studio auch extrem komplexe Anforderungen, mit Entwicklungsunterstützung abbilden zu können. Das alles wiederverwendbar, ex- und importier bar, auch unter SharePoint 2007.

Da ich in meiner täglichen Arbeit als Entwickler bei ecspand Nintex nutze und die Möglichkeiten sowohl auf Seiten des Designers als auch mit dem Visual Studio ziemlich ausreize, möchte ich die Gelegenheit nutzen, hin und wieder einige Tipps und Informationen zu diesem Thema zu veröffentlichen.

Mit diesem einleitenden Beitrag möchte ich den Auftakt machen.




February 2012
M T W T F S S
« Dec    
 12345
6789101112
13141516171819
20212223242526
272829  

Badge Farm

  • Powered by Redoable 1.0