February 2010 - Posts
אז מפגש ראשון של קהילת מפתחי SharePoint הסתיים בהצלחה!
במפגש הצגתי את הקבוצה ומטרותיה, והכרזתי על פתיחתו של פורטל SharePoint הישראלי בקרוב.
דיברנו על כלי הפיתוח החדשים ב SharePoint 2010, על Linq 2 SharePoint ועל Client Object Model.
בסוף המפגש שאלו אותי 2 שאלות שלא הספקנו לענות עליהן, והבטחתי לענות עליהן בבלוג:
1. בשימוש ב Client OM, איך אפשר לקבוע מראש אילו מאפיינים על אובייקט יחזרו? לדוגמא, אם אני רוצה להביא מהשרת את האובייקט List, אבל אני לא צריך את כל המאפיינים שלו. תשובה:
כדי להחזיר את המאפיינים Title, Created, OnQuickLaunch של האובייקט List, נכתוב קוד שנראה כך:
clientContext.Load(myList,
list => list.Title,
list => list.Created,
list => list.OnQuickLaunch);
שימו לב שהמאפיין OnQuickLaunch הוא מאפיין שלא יורד ללקוח כברירת מחדל, וזאת אחת הדרכים גם לאלץ אותו לרדת ללקוח.
2. בשימוש ב Linq 2 SharePoint, חסר המאפיין “נוצר על ידי” בקלאס שנוצר ע”י SPMETAL. מה ניתן לעשות בנידון? תשובה:
http://blogs.microsoft.co.il/blogs/itaysk/archive/2010/02/19/spmetal-missing-created-by-modified-by-fields.aspx
את המצגות ניתן להוריד מכאן:
http://www.sharepoint2010.co.il/Events/SPDG1/Resources
את התמונות שצולמו באירוע ניתן למצוא כאן:
http://www.sharepoint2010.co.il/Events/SPDG1/Photos
תודה רבה לכל מי שהגיע!
המפגש הבא יתקיים ב 10/03, פרטים בהמשך…
נתראה במפגש הבא,
איתי שקורי.
Update: I have posted a more appropriate solution for this problem here: http://blogs.microsoft.co.il/blogs/itaysk/archive/2010/09/22/spmetal-default-fields.aspx
I have been playing around with Linq 2 SharePoint (SharePoint 2010 beta 2), and noticed that SPMETAL fails to generate the appropriate fields for the ‘Created By’ and ‘Modified By’ fields.
This is probably a bug with SPMETAL, but here’s a quick workaround.
generate a code file with SPMETAL as usual, and look for the ‘Item’ class.
Add this piece of code inside the class:
string _CreatedBy;
[Microsoft.SharePoint.Linq.ColumnAttribute(Name = "Author", Storage = "_CreatedBy", ReadOnly = true, FieldType = "User", IsLookupValue = true)]
public string CreatedBy
{
get
{
return this._CreatedBy;
}
set
{
if ((value != this._CreatedBy))
{
this.OnPropertyChanging("CreatedBy", this._CreatedBy);
this._CreatedBy = value;
this.OnPropertyChanged("CreatedBy");
}
}
}
Notes:
I have created this as part of a ‘User’ field type (It might be useful sometime), but you can do the same with plain string. If you do, the value of the property will include both the ID and the string part if the User lookup.
I have omitted the Id property (which is supposed to be part of a ‘Lookup’ field declaration) because it is useless in this case.
If you would like to do the same for ‘Modified By’ field, copy the same code, and replace “Author” with “Editor” in the ‘Name’ property of the ‘ColumnAttribute’.
The first thing that crossed my mind when I was learning about SPMetal, was why isn’t there an easier way to call it. Something like an addin for Visual Studio.
It was only a manner of time, but someone has already picked the glove (and beat me to it).
Waldek Mastykarz has extended SharePoint Explorer (that is part of Visual Studio 2010), to allows picking a site, and running SPMETAL at it.
Read more and download the addin here:
http://blog.mastykarz.nl/imtech-spmetal-definition-extension/
If you’ve been following the latest events from MWC @ Barcelona, You probably know that Microsoft is up to something big with Windows Phone Series 7.
Watching the demos, and reading through the materials, I noticed the “Office” hub, that has a “SharePoint” tab on it. (click to enlarge)
We don’t know for sure what’s it going to look like, but apparently there’s going to be some kind of integration between the two.
Microsoft VP Joe Belfiore, during his keynote demonstration:
"SharePoint is a terrific experience, whether you're a company that has SharePoint Servers inside your firewall, or a small business or individual and you want to store documents in SharePoint as part of Windows Live. So, what we've tried to do is take that experience from the applications, and documents, through note taking to the service, and bring it together on the phone"
Perhaps we will hear more details at MIX conference that is not too far now.
Here’s a quick tip that might help you some day. (It did for me..)
SharePoint stores some of it’s search configurations (that are usually configured through the SSP Admin UI) in the windows registry of the index server.
Now, there are basically 2 search services for a typical MOSS farm: Windows SharePoint Services Search Service (WSS Search), and Office Server Search Service (MOSS Search). The differences between them are explained here: http://technet.microsoft.com/en-us/library/cc263400.aspx#section1
Lets take for example the file types (to crawl) configuration, that is normally controlled from Central Administration –> SSP Administration –> Search Settings –> File types (http://YourSSPHost/ssp/admin/_layouts/managefiletypes.aspx).
This setting is saved for MOSS Search in the following registry path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\12.0\Search\Applications\GUID\Gather\Portal_Content\Extensions\ExtensionList and for WSS Search: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Applications\GUID\Gather\Search\Extensions\ExtensionList
In this location, you will find a list of string valued keys, each has a unique ascending number as name, and the file extension as value.
Basically you can add your file extensions directly here, it’s pretty much the same as from the GUI interface.
Note that the GUI interface doesn’t exist at all for WSS Search. So if you want to configure this setting for WSS, you HAVE TO manually add the keys here.
Linq 2 SharePoint distinguishes between three types of queries: Normal Queries, Inefficient Queries, and Unsupported Queries.
For more on that subject see the SDK article: http://msdn.microsoft.com/en-us/library/ee536585(office.14).aspx
According to the SDK (at least as of today), you can execute inefficient queries if you set the AllowInefficientQueries property to true.
Also, If you try to actually try to run an inefficient query, you will get the following exception, that instruct you to set the AllowInefficientQueries flag:
But if you try to to apply this practice to your code, you will soon find out that there’s no property called AllowInefficientQueries at all!
Wondering why?
I’ve done some digging, and found out that it was only present in internal Beta1 distributions, and was removed with the public Beta2. Documentation is probably still outdated.
So if you still want to run inefficient queries, you will have to to take the extra mile and explicitly get the list from SP, then use LINQ 2 Objects to query the list.
Lets say I have 2 lists – Employees, and Departments. I also have a lookup set between them where each employee has a lockup field to the Departments list.
This query should fail due to inefficiency:
IEnumerable<EmployeesContact> res =
from employee in data.Employees
where employee.Department.Budget>1000
select employee;
To make it work, we need to first get the list locally, and work with it offline. The following query should work:
IEnumerable<EmployeesContact> employeesList =
data.Employees.ToList<EmployeesContact>();
IEnumerable<EmployeesContact> res =
from employee in employeesList
where employee.Department.Budget>1000
select employee;
I agree, it’s not the most efficient code, since we actually run tow queries instead of one.. but it’s the only way, and hey - this post is about inefficient queries right..?
-- My name is Itay Shakury, and I’m a SharePoint consultant --
Lets say that I have a wiki page called “itaysk.aspx”. and lets say that I use this page inside a SharePoint dialog.
When I created the page, it looked like this: (click on the pics to enlarge)
And the dialog looks like this:
See the difference? When the page is presented inside a dialog, we see a lighter version of the page. And that’s actually very good, because in a dialog, we want the content of the page, and not full design of the master page.
So how is this happening?
When called from a dialog, a special query string parameter is added to the address. It is called IsDlg and makes the page know it is inside a dialog.
What does IsDlg=1 actually does?
Well, lets take a look at something that is present in the page, and disappeared in the dialog:
As you can see, the quick launch menu is assigned a css class called: “s4-notdlg”. This is the secret behind this process. Every element in the page that has this class, is not to be displayed inside a dialog, and that applies to your custom content as well.
Just want to recommend a very helpful site: www.SharePointReviews.com
It catalogs, and reviews all the solutions for SharePoint that are out there. Can be very handy if you are looking for a solution, and don’t want to miss a product that didn’t show up in searches.
![spr_logo[1] spr_logo[1]](http://blogs.microsoft.co.il/blogs/itaysk/spr_logo1_0EC49BCA.gif)
הנה פתרון מהיר לבעית לוקאליזציה קטנה שקיימת ב SharePoint מהגרסא הראשונה, ועדיין לא תוקנה.
כשמשתמשים בערכת נושא (Theme) שאינה ערכת הנושא המוגדרת כברירת המחדל, התבליטים (Bullets) שבתפריט הצידי (Quick Launch) מיושרים לשמאל ולא לימין.
כדי להתגבר על הבעיה תוסיפו את ה style הקטן הזה לתוך ה MasterPage או לתוך קובץ ה CSS שנמצא בשימוש.
.ms-navitem td{
background-position:right top !important ;
}
תוצאה:

-- שמי איתי שקורי, ואני יועץ SharePoint --