Tuesday, July 21, 2009

How to register safe control to web.config manually

Here is a little code example I found at MSDN that allows you to add a safe control to the web application web.config file throughout the SharePoint farm.

It uses the SPWebConfigModification class to add the change and will, make sure your changes gets re-applied whenever a new web application is created in the farm!

Note, you can add all sorts of modifications using this class - not only safe controls.
As Daniel Larson wrote in the comments for the MSDN article, for web controls - if possible you should use other methods of deployment and update the safe control in the manifest xml file.

taken from: msdn SPWebConfigModification

SPWebService myService = SPWebService.ContentService;

SPWebConfigModification myModification = new SPWebConfigModification();
myModification.Path = "configuration/SharePoint/SafeControls";
myModification.Name = "SafeControl[@Assembly='MyCustomAssembly'][@Namespace='MyCustomNamespace'][@TypeName='*'][@Safe='True']";
myModification.Sequence = 0;
myModification.Owner = WebConfigModificationFeatureReceiver.OwnerId;
myModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
myModification.Value = "";

myService.WebConfigModifications.Add(myModification);
myService.Update();
myService.ApplyWebConfigModifications();


I found that usefull when a customer of ours wanted to use a custom field inside a publishing page layout... the original installer did not add the safe control since you dont need it when you are inside list item form (create/edit/view), but inside a publishing page layout we got a message saying the control is not registered as safe.

Hope you do to, Shai.

Monday, July 20, 2009

Helpful batch file command for installers

Hi,

Just a short one this time,

here is a nice script for looping through all MSI files in current folder / sub folders and running the installers one after the other.

Just paste this into a install.bat file and place with your set of installers:
for /f "delims=" %%a IN ('dir /s /b *.msi') do MSIEXEC /i "%%a"

simple, 1 line of script made my life easier with WikiPlus.

You see, installing it involves running installers for 5 different products so this way I just throw them into sub folders and this little script does the rest for me.

:)

Enjoy,

Tuesday, July 14, 2009

How do I duplicate a list item without code?

By Roi Kolbinger - SharePoint Consultant
KWizCom Professional Services – http://www.kwizcom.com/

Did you ever wish to copy an Item to the current list several times? What is the best way to duplicate a list item? Can it be done without code?

There is an easy, effective way and no – you don't need code! Here's how:

All you need to do is to create two new columns and SPD workflow.

Step 1: Create columns

Name the first new column you create according to the number of copies you want to make. When defining the type of information that will be in the column, choose "number". This column is where you will define the number of copies you want to create.

Name the second column according to the number of copies you want, minus one. Define the type of information that will appear in this new column as "Calculated" (this gives a number which is the result of a calculation based on a different column).
The calculation we will use here will take the first column and subtract from it -1.
The formula to use for doing this is =[number of copies]-1 like so:

Step 2: Create a new workflow at the SPD

Open the site at the SPD and then create a new workflow.
Give the workflow a name and select the list from which you desire to copy the Item. Then select your workflow start options. It is best to choose: "automatically starts the workflow whenever the item is been changed". This will renew your workflow each time the item has been updated and/or edited and insure that the calculated result is always accurate.

Next, define the step of the workflow – select "Number of copies" greater the zero.

And then, define two actions:
1) Update your item: "Numbers of copies" is will be "Number of copies minus one".


2) Create a new item in the list that duplicates the columns taken from the original item. Do not include the "Number of copies" column! If you do an infinite loop will be created.



Now when you go to an item that you wish to duplicate, all you need to do is edit the item and write the numbers of copies that you want to make in the "Number of copies" column and your copies will be made! Easy and simple with no code necessary at all!

Sunday, July 12, 2009

Delegate Controls: What, Where and How

See the presentation Shai gave during SharePoint Saturday:

** updated slide here: http://kwizcom.blogspot.com/2010/08/delegate-controls-what-where-and-how.html **




Download this presentation and a code example here.

Monday, July 6, 2009

KWizCom is going to SharePoint Saturday Toronto!









This month KWizCom is going to the first-ever SharePoint Saturday Toronto and you are invited to come along!

KWizCom is proud to participate in and sponsor this grass-roots event. SharePoint Saturday events are free, community-focused SharePoint events dedicated to educating and engaging members of the local technical community.

SharePoint Saturday will be an educational, informative & lively day filled with sessions from respected SharePoint professionals & Microsoft MVPs, covering a wide variety of SharePoint-oriented topics. Amongst them will be KWizCom's own VP R&D Shai Petel, who will be presenting a session on
"Delegate Controls: What, Where and How"

KWizCom representatives will be amongst a select group of vendors with a booth at SharePoint Saturday. Come talk to us and learn about the many opportunities and benefits of working with KWizCom!
We have prepared a special gift for everyone who visits our booth but you have to attend to benefit!

SharePoint Saturday Toronto will take place:
On: Saturday, July 11th, 2009
At: Microsoft Canada Conference Centre
1950 Meadowvale Blvd, Mississauga, Ontario, Canada.

The day starts at 9:00 AM with a short introductory keynote and ends at 4:30 PM.
Lunch will be provided and there will be numerous giveaways throughout the day.
Come join us for a day of fun, learning, networking and – SharePoint!

Register for the event
For more information, please visit
www.sharepointsaturday.org/toronto.