Donnerstag, 21. Oktober 2010

Custom Field Type -> User : <Field Name="ParentType">User</Field>

Wenn man ein Custom Field Type des ParentTypes User erstellen will, dann geht man vor wie bisher, nur an zwei Stellen müsste man etwas ändern.

1. fldtypes_[your name].xml
Dort muss man den folgenden ParentType definieren:
<Field Name="ParentType">User</Field>

2. FieldControl verlangt beim get der überschriebenen Methode Value ein gewisses Format [Sharepoint UserId];#[Sharepoint UserName] als String.
public override object Value
{
get
{
return "1;#Mein Name";
}
}


Sharepoint UserId bzw. UserName erhält man wie folgt:
Aktueller User:
SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.RootWeb)
{
SPUser oUser = oWebsite.CurrentUser;
oUser.Name; //Der Sharepoint UserName
oUser.ID; //Die Sharepoint UserId
}


Ein User aus einer Gruppe:
using (SPSite spSite = new SPSite("[URL zu meiner Sharepointinstanz]"))
{
using (SPWeb spWeb = spSite.RootWeb)
{
foreach (SPUser user in spWeb.SiteGroups["[Mein Gruppenname]"].Users)
{
user.Name;
user.ID;
}
}
}


3. Ihre Field Klasse erbt bei normalen Custom Field Types von der Basisklasse SPField. In diesem Fall muss es SPFieldUser sein. Der restliche Code bleibt gleich. Wenn man einen Defaultwert setzen will, kann man die dazugehörige Eigenschaft überschreiben.
public class [Ihr Name]Field : SPFieldUser
{ ...

HINWEIS: Wenn Sie SPField als Basisklasse benutzen, dann bleibt der Wert in der Liste leer.


If you want to create a custom-field-type of parent-type User, then you just create your custom-field-type like any other and make changes at two spots.

1. fldtypes_[your name].xml
There you have to define the following ParentType:
<Field Name="ParentType">User</Field>

2. FieldControl requires a special format in the get function of the overridden method Value. [Sharepoint UserId];#[Sharepoint UserName] as string.
public override object Value
{
get
{
return "1;#My name";
}
}


You can get the values of Sharepoint UserId or UserName like this:
Current user:
SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.RootWeb)
{
SPUser oUser = oWebsite.CurrentUser;
oUser.Name; //The Sharepoint UserName
oUser.ID; //The Sharepoint UserId
}


User from a specified group:
using (SPSite spSite = new SPSite("[URL of my Sharepoint-instance]"))
{
using (SPWeb spWeb = spSite.RootWeb)
{
foreach (SPUser user in spWeb.SiteGroups["[My group-name]"].Users)
{
user.Name; //The Sharepoint UserName
user.ID; //The Sharepoint UserId
}
}
}


3. Usual custom-field-types inherit from the base-class SPField. In this case your class needs to inherit from SPFieldUser. The rest of the code remains the same. If you want to set a default-value, then you need to override the property DefaultValue.
public class [Your name]Field : SPFieldUser
{ ...

HINT: If you do use SPField as the base class, then the value in the list will remain empty.

Mehrere SP.UI.ModalDialog.showModalDialog - CallBack

Wenn man mehrere SP.UI.ModalDialog.showModalDialog Fenster auf einer Seite platziert, ist es wichtig, dass die Callback Methoden unterschiedlich heissen. Ansonsten funktioniert immer nur ein Dialog Callback. Deshalb in den Properties des Dialogs immer einen anderen Methodennamen verwenden.

If you are using multiple SP.UI.ModalDialog.showModalDialog windows on your page, be aware to have different callback methods defined. Otherwise there will be just one callback working. Therefore set in the properties of your dialog always a different method.

Dialog 1:

function OpenDialog1()
{
var options1 = {
url: '/_layouts/MyDialog.aspx',
title: 'MyDialog',
allowMaximize: false,
showClose: true,
width: 400,
height: 400,
dialogReturnValueCallback: DialogCallback1 };

SP.UI.ModalDialog.showModalDialog(options1);
}

function DialogCallback1(dialogResult, returnValue) {
[Your code on callback]
}

Dialog 2:

function OpenDialog2()
{
var options2 = {
url: '/_layouts/MySecondDialog.aspx',
title: 'MySecondDialog',
allowMaximize: false,
showClose: true,
width: 400,
height: 400,
dialogReturnValueCallback: DialogCallback2 };

SP.UI.ModalDialog.showModalDialog(options2);
}

function DialogCallback2(dialogResult, returnValue) {
[Your code on callback]
}


Es existiert noch eine andere Schreibweise ->
There is also another way of defining the dialog ->

Dialog 1:

function OpenDialog1()
{
SP.UI.ModalDialog.showModalDialog(options);
var options1 = SP.UI.$create_DialogOptions();
options1.url = '/_layouts/MyDialog.aspx';
options1.width = 400;
options1.height = 400;
options1.allowMaximize = false;
options1.showClose = true;
options1.dialogReturnValueCallback = DialogCallback1;

SP.UI.ModalDialog.showModalDialog(options1);");
}

function DialogCallback1(dialogResult, returnValue) {
[Your code on callback]
}

Dialog 2:

function OpenDialog2()
{
SP.UI.ModalDialog.showModalDialog(options);
var options2 = SP.UI.$create_DialogOptions();
options2.url = '/_layouts/MySecondDialog.aspx';
options2.width = 400;
options2.height = 400;
options2.allowMaximize = false;
options2.showClose = true;
options2.dialogReturnValueCallback = DialogCallback2;

SP.UI.ModalDialog.showModalDialog(options2);
}

function DialogCallback2(dialogResult, returnValue) {
[Your code on callback]
}

Mittwoch, 20. Oktober 2010

Timerjob does not fire

Wenn Sie einen Timerjob erstellt und deployed haben, jedoch dieser keine Funktion auszuführen scheint, dann liegt es evtl. daran, dass die Assembly nicht neu instanziert wurde. Hierzu unter Verwaltung -> Services -> Sharepoint Timer neu starten. Danach den Timerjob nochmals starten.

When you created and deployed a timer-job, this seems not to work or functionallity seems not to fire, then the reason might be that the assembly was not initialized properly. Therefore restart Administrative Tools -> Services -> Sharepoint Timer. Then run your timer-job again.

Freitag, 15. Oktober 2010

Import spreadsheet als Liste

Bei dem Import eines Spreadsheets als Liste in Sharepoint 2010 hatte ich folgende Fehlermledungen:
1. "Automation server can't creat object"
ActiveX Controls sind nicht aktiviert oder Sie verwenden nicht den IE.

2. "The specified file is not a valid spreadsheet or contains no data to import"
Gehen Sie im Internet Explorer unter Tools -> Internet Options -> Security -> Trusted Sites -> Sites (Button) und fügen Sie die Seite hinzu. Sollte es dort eine Fehlermeldung geben, dann die Checkbox uncheck, denn Sie wollen wahrscheinlich eine http:// Seite hinzufügen.


When importing a spreadsheet as a list in Sharepoint 2010 I had the following error-messages:
1. "Automation server can't creat object"
ActiveX controls are either not activated or you are not using the IE.

2. "The specified file is not a valid spreadsheet or contains no data to import"
Go to Internet Explorer under Tools -> Internet Options -> Security -> Trusted Sites -> Sites (Button) and add this site to your trusted sites. If there is also an error-message, then uncheck the checkbox below, because you are trying to add a http:// site.

Montag, 11. Oktober 2010

Sharepoint 2010 -> Javascript API window dialog

Wer in seiner Sharepointseite ein windows bzw. dialog selbst erstellen und öffnen will, der muss lediglich auf ein wenig Sharepoint API zurückgreifen:

If someone wants to use the window/dialog of Sharepoint in his Sharepoint instance, you can use the Sharepoint API like this:

<script type="text/javascript">
function MyDialog() {
var thisdialog = SP.UI.$create_DialogOptions();
thisdialog.url = "/_layouts/DialogDemo/MyDialog.htm";
thisdialog.width = 400;
thisdialog.height = 300;
SP.UI.ModalDialog.showModalDialog(thisdialog);
}
</script>


More information can be found here (thanks to the authors):
External blog
External blog

Mittwoch, 6. Oktober 2010

Incompatible Web Part markup detected. Use *.dwp Web Part XML instead of *.webpart Web Part XML.

Wenn Sie ein eigenes Webpart erstellt haben und oben genannte Fehlermeldung erhalten, dann liegt es daran, dass das Webpart von der falschen Klasse erbt. Sie muss von folgender Klasse erben:
System.Web.UI.WebControls.WebParts.WebPart
und NICHT:
Microsoft.SharePoint.WebPartPages.WebPart

If you get the above mentioned error message, then you inherit from the wrong class in your custom webpart. It is supposed to inherit from:
System.Web.UI.WebControls.WebParts.WebPart
and NOT:
Microsoft.SharePoint.WebPartPages.WebPar

Hier ein kleines Beispiel, wie man ein eigenes Webpart erstellt:
Here is a little example how to create your custom webpart:
Link 1

Mittwoch, 29. September 2010

sharepoint 2010 page layout disabled in ribbon

Wenn der Page Layout Button im Ribbon disabled ist kann dies folgende Ursachen haben:
1. Der User, welcher eingeloggt ist und das Layout ändern will hat nicht genug Rechte. Es einmal mit einem Adminuser versuchen.
2. Es gibt einfach keine Page Layouts auszuwählen. Hierzu Settings -> Look and feel -> Page Layouts und dort in der mittleren Spalte ein paar Layouts zur Verfügung stellen.
3. Die eigen erstellen Layouts wurden von einem User mit minderer Berechtigung hochgeladen. Sie sind zwar in den Settings zu sehen, können aber nicht ausgewählt werden. Hierzu als Admin einloggen und unter Settings -> Galleries -> master pages and page layouts, die einzelnen aspx Dateien auschecken und einchecken. Der Modified By User dürfte dadurch ändern. Anschliessend nochmals checken ob Punkt 2 erfüllt ist und nochmals in der Seite sehen ob der Button noch disabled ist.

When the page-layout-button in the ribbon is disabled, the reason therefore can be:
1. The user, who is logged in and wants to change the layout, does not have enough permissions. Try the admin-user.
2. There are no page-layouts to choose from. Go to settings -> look and feel -> page layouts and take the selection boxes in the middle to provide some layouts.
3. The custom layouts have been uploaded by a user, that does not have enough permissions. You can then see the layouts in the settings, but they can't be chosen in the page. Therefore login as an admin and go to settings -> galleries -> master pages and page layouts, there check out the different aspx files and check in. The Modified By User is suppsoed to be changed. Then check again if you topic no 2 is correct set and if it works and the button is enabled.

Mittwoch, 22. September 2010

$('#s4-ribbonrow').show(); Javascript error: object expected

Dieser Fehler taucht auf, wenn man den ...<div id="s4-ribbonrow">... Layer irgendwie auf hidden, oder display none gesetzt ist.

This error happens, when the layer ...<div id="s4-ribbonrow">... is set to hidden or display:none.

Freitag, 10. September 2010

AgilePoint - Sharepoint can't add workflow

Wenn Sie beim Versuch, einen Workflow in Sharepoint mit einem Processtemplate des AgilePoint Servers zu verbinden, folgende Fehlermeldung erhalten "Object reference not set to an instance of an object", dann liegt es vielleicht daran, dass Sharepoint und der AgilePoint Server nicht kommunizieren. Kann sein, dass ein AD User ein neues Passwort besitzt oder der User geändert wurde. Hierzu unter Listen die AgilePoint Configuration Liste öffnen und überprüfen ob die Userdaten noch korrekt sind.

If you get the following error: "object reference not set to an instance of an object", when trying to add a process-template for a workflow in Sharepoint. Reason therefore might be, that the communication between Sharepoint and AgilePoint server is not working correctly. Maybe the AD user got deleted or password changed. Please go to the AgilePoint-configuration list, under Sharepoint lists, and check the credentials there.

AgilePoint form does not open in browser - AgilePoint Formular öffnet nicht im Browser

Wenn man vom AgilePoint Server aus einen Workflow deployed, welcher dann mit eigenem InfoPath Formular kommt und dieses sich beim hinzufügen von Items in Infopath öffnet, sollten folgende Einstellungen untersucht werden:
InfoPath, wenn man ein neues Formular erstellt: -> "nur browserkompatible Features aktivieren" anklicken. Sollte das Formular schon erstellt sein, dann unter Extras -> Formularoptionen -> Kompatibilität kontrollieren, ob die Checkbox ("Formularvorlage entwerfen, die in einem...) aktiviert ist. Anschliessend in Sharepoint auf der Liste unter List-settings -> Advanced settings -> Opening Documents in browser, dort prüfen ob die Einstellung stimmt.

When you deploy a workflow from the AgilePoint server, that uses an InfoPath form and opens up in InfoPath instead of the browser, than you should check those settings:
InfoPath when creating a new form: -> "enable browser compatible features only", check-box needs to be clicked. If the form is already created, then go to Tools -> Form Options -> Compatibility and check if the check-box ("Design a form-template that can...") is activated. Afterwards go to the sharepoint-list and go to list-settings -> advanced settings -> opening documents in browser, check if this setting is correct.