Feedback on the Arabic web casts!

Last week, I have been receiving wonderful feedback on the Arabic SharePoint web casts I have recorded lately, I would like to thank everybody who took time to send me an e-mail or contacted me via facebook or twitter to give me his/her feedback.

I would like also to extend a special thank you to Mike Walsh [SharePoint MVP and author of Sams Teach Yourself SharePoint 2007 in 24 Hours: Using Windows SharePoint Services 3.0] for giving my webcasts a plug in his blog.

38

Advertisements

SharePoint Site Definition Provisioning Order

When you use site definitions to create sites it’s often pretty unclear what the order is in which the sites are provisioned. Knowing the order can be important if you want to make several changes to your site that are dependent on each other. In case you need to know how to make sure that the changes are executed in the right order, Check Mirjam’s blog 🙂

ReadOnly, Hidden and Sealed Fields

That’s another question that I Answered in MSDN Social forums and thought of sharing with you here 🙂
Q :
The documentation regarding those attributes is not informative enough.
Hidden :
Optional Boolean . If TRUE , the field is completely hidden from the user interface. Setting ReadOnly to TRUE means the field is not displayed in New or Edit forms but can still be included in views.
ReadOnly :
Optional Boolean . If TRUE , the field is not displayed in New or Edit forms but can be included in views. Setting the Hidden attribute to TRUE completely hides the field from the UI.
Anybody knows the differences ?And what about CanToggleHidden attribute ?

A :

Similarities : Both aren’t displayed anywhere unless you configure a view to show any of them.
Differences : Hidden Fields can be updated through the object model but ReadOnly fields can’t be updated through OM like “Created” And “Created By” fields.

If you are still confused, consider the following example :You have a field that you use only by the object model for setting or getting a flag and you don’t want the field to be visible to anybody and non updatable through the UI, however you want it to be updatable through the object model.
For me, I was creating a list that stores the applications of Scholarships offered by a foundation and we needed the status of each application to be totally hidden but updatable through the OM.
Theoritically, this should be an east task :
SPSite site=SPContext.Current.Site;
SPWeb web=site.OpenWeb();
SPList list =web.Lists[“ScholarshipApplicationsList”];
string id=list.Fields.Add(“Status”,SPFieldType.Boolean,false);
SPField statusField = list.Fields.GetField(id);
statusField.Hidden=true;
statusField.Update();

But if you try this you’ll receive a nice exception
Why? The Hidden property checks if CanToggleHidden property is true and throws an exception if its not.
Fair enough, all we do then is set the CanToggleHidden property to true and do the update but there is no such a property in the object model.
So I’ve decided to use “Reflection” ..
SPField statusField= web.Lists[“ScholarshipApplicationsList”].Fields[“Status”];
Type type = spfield.GetType();
MethodInfo mi = type.GetMethod(”SetFieldBoolValue”,
BindingFlags.NonPublic BindingFlags.Instance);
mi.Invoke(spfield, new object[] { “CanToggleHidden”, true });
statusField.Hidden = true;
statusField.Update();
And if you want to use CAML, this is much more easier :
<field displayname=”Status” type=”Boolean” required=”FALSE” name=”NewField” cantogglehidden=”TRUE” hidden=”TRUE”>

Q :
Thanks Ayman El-Hattab.I’ve created a few hidden fields but now I’m trying to delete them using the following code :
list.Fields[“Status”].Delete();
But I’m gettin the following exception :
“You cannot delete a hidden column ”

A :
Unhide the field , then delete it. CanToggleHidden attribute is now set to true, so you can hide and unhide the field as you wish.