Thursday, 4 December 2008
Calculated Field Formulas
Herzaman google'da arıyordum. barı blog'a kaydedeyim de bulmam kolay olsun dedim :)
[ENG]
I was googling the link everytime I needed. Then I thought it would be better to write it on the blog :)
http://msdn.microsoft.com/en-us/library/bb862071.aspx
Sunday, 17 August 2008
Adding Property to SPNavigationNode
Birkaç gün önce yöneticim Sharepoint için 4. kırılıma kadar destekleyen ve node'larında extra değerler tutabileceğim bir menu manager yazmamı istedi. Bunu sharepoint standardında yapmam gerekiyordu. İlk önce SPNavigationNode sınıfını extend etmeyi düşündüm ancak bunun sealed bir class olduğunu farkettim. Daha sonra extra değerleri property olarak tutmaya karar verdim. Ancak bir sorun vardı. Bir türlü property ekleyemiyordum.
En sonunda node'a property ekleyebilmek için önce node'u oluşturup, siteye kaydedip, daha sonra geri çağırıp, property'i ekleyip, node'u update etmem gerektiğini öğrendim. Örnek kodu aşağıda veriyorum
[ENG]
My manager asked me to write a component to sharepoint which makes it possible to add 3th & 4th level link node to sharepoint navigation. It was like adding a new heading under a heading and then adding link to the second heading. That was easy. But the main problem was I needed to add some new properties to that link (like "is default page" value). I tried to extend SPNavigationNode class but I realised that it is a sealed class and sharepoint keeps each property as a different column in DB. Then I realed that adding my new values as a property vould solve my problem. But the problem was when I added a property I got compile time error.
Finally I learned that to add a property to a SPNavigationNode we must first create the object, add it to navigation, call the node back, add properties, update node.
Here is a sample code;
SPNavigationNodeCollection nodes = PublishingWeb.GetPublishingWeb(spweb);
SPNavigationNode newNode = new SPNavigationNode("DeveloperKoala", "http://developerkoala.blogspot.com");
nodes.AddAsLast(newNode);
node = nodes[nodes.Count() -1];
node.Properties.Add("ExtendedProperty", "This is a cool site");
node.Update();
Friday, 4 July 2008
Creating view which shows approved/rejected items at workflow
Sharepoint'te bir listeye workflow bağlayıp herbir item için onay almanız mümkün. Bunu yaptıktan sonra bir view tanımlayıp sadece kabul edilen önerileri görmek isterseniz muhtemelen ilk yapacağınız şey bir view tanımlayıp Workflow Status kolonu is equal to Approved yapmak olacaktır. Ancak view'a dönüp baktığınızda hiçbir item'ın gelmediğini göreceksiniz. Hatta is equal yerine is not equal yazarsanız bu defa da query error ile karşılaşacaksınız. Bunun nedeni Sharepoint'in Accept, reject gibi değerleri enum olarak tutmasıdır. Buna göre kabul edilen öneriler için Status is equal to 16 demeniz gerekiyor. Diğer durumları ve kodlarını aşağıda bulabilirsiniz.
Durum Değer
Not Started 0
Failed on Start 1
In Progress 2
Error Occurred 3
Canceled 4
Completed 5
Failed on Start (retrying) 6
Error Occurred (retrying) 7
Canceled 15
Approved 16
Rejected 17
[ENG]
Sharepoint allows you can to connect an approval workflow to a list. If you want to see the items that has been approved the first thing you will probably do will be creating a new view and settind Workflow Status column is equal to Approved. But when you look at the list you will see that there is not any item at that view. If you modify this view and change is equal condition as is not equal you will get a query error at view's display page. Reason for that is sharepoint keeps that conditions as enum. for example if you want to display only approved itemsi you must set Workflow status is equal to 16. Here are other workflow status and codes
Status Code
Not Started 0
Failed on Start 1
In Progress 2
Error Occurred 3
Canceled 4
Completed 5
Failed on Start (retrying) 6
Error Occurred (retrying) 7
Canceled 15
Approved 16
Rejected 17
Wednesday, 25 June 2008
Sharepoint file name standarts
Sharepoint'te biryere döküman yükleyecekseni şu standartlara dikkat etmeniz gerekiyor
- Dosya adında şu karakterler olmamalı : " # % & * : < > ? \ / { } ~
- Dosya adı 128 karakterden uzun olmamalı
Daha fazla bilgi için aşağıdaki linki ziyaret edebilirsiniz;
http://blogs.officezealot.com/legault/archive/2007/04/26/20302.aspx
[ENG]
If you are uploading a file to sharepoint you should obey some rules. Which are
- File names cannot contain those cahacters: " # % & * : < > ? \ / { } ~
- File name cannot be longer than 128 characters
For mor info check this link:
http://blogs.officezealot.com/legault/archive/2007/04/26/20302.aspx
Wednesday, 18 June 2008
System.Security.SecurityException
Geliştirdiğim bir webpart'ı sayfaya eklemeye çalıştığımda şöyle bir hata alıyordum:
System.Security.SecurityException: Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed
Daha sonra bu webpart ile ilgili dll'in GAC'da olmadığını farkettim. dll'i GAC'a atıp iisreset yaptıktan sonra sorun çözüldü
[ENG]
I developed and deployed a webpart to my development server. After adding the web part to my web page I get an error which was:
System.Security.SecurityException: Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed
Then I realised that I'm not deploying the dll file to GAC. Because of that sharepoint cannot trust this dll. After copying dll to GAC and a quick iisreset the problem has been solved
Monday, 9 June 2008
Last created Survey which has only one question
Bir WebPart için site üzerindeki en son girilen tek soruluk anket bilgisini almam gerekti. Site üzerinde oluşturulan anketler ok ama tek sorulu olanı nasıl almaya çalışacam diye düşünürken anketlerin her bir soruyu bir field olarak tuttuğunu farkettim. Daha sonra moss'taki bir anketin default olarak 42 tane field'ının olduğunu öğrendim ve kodla kontrol ettim. En sonunda ortaya şöyle bir kod parçası çıktı
DateTime created = DateTime.MinValue;
foreach (SPList list in mainWeb.Lists)
{
if (list.BaseType.ToString() == "Survey" && list.Created > created && list.Fields.Count==43)
{
AnketTitle = list.Title.ToString();
}
}
[ENG]
I needed to get the title info of the last created survey which has only one question. It was fine to get last created survey but I was wondering how to get number of questions. Then I realised each question is kept as a field in the survey. I checked that each survey has 42 default fields. Finally I wrote a code like that;
DateTime created = DateTime.MinValue;
foreach (SPList list in mainWeb.Lists)
{
if (list.BaseType.ToString() == "Survey" && list.Created > created && list.Fields.Count==43)
{
AnketTitle = list.Title.ToString();
}
}
Wednesday, 4 June 2008
Disabeling Sharepoint's default errors

- compilation batch="false" debug="true"
- SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false"
- customErrors mode="Off"
[ENG]
When I first started to make developments on sharepoint the biggest problem for me was seeing the error message of "Unexpected error has occured". Because I couldn't identifywhat causes that problem. After a quich research I learned how to disable default moss errors and get classic .Net errors instead of it. You need to change 3 lines at web.config file like that
- compilation batch="false" debug="true"
- SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false"
- customErrors mode="Off"
Monday, 2 June 2008
Debugging Custom Timer Job
[TR]
Sharepoin 2007 için yazdığım bir timerjob bi türlü çalışmayınca debug etme ihtiyacı duydum. Ama bu timerjob'ın Installer kısmını debug edebiliyorken Definition kısmını bir türlü debug edemediğimi farkettim. biraz araştırma sonunda şöyle bişeyler buldum
- Kodunuzun herhangi bir yerine breakpoint koyun
- Toolbar'dan Debug'a tıklayıp "Attach to process" 'i seçin
- Önünüze gelen panelden "OWSTimer.exe"'yi seçin
- Artık kodunuzu debug edebilirsiniz
[ENG]
I needed debug a timerjob that I wrote for Sharepoint 2007. But I realised that I can debug Installer code but I cannot debug Definition code file. After a little research I found a solution;
- Put a breakpoint to any line of your code
- Click Debug from Toolbar and then select "Attach to Process"
- From that list select "OWSTimer.exe"
- Now you can debug your code