Showing posts with label how to. Show all posts
Showing posts with label how to. Show all posts

Monday, March 8, 2010

How to uncheck the overwrite check box in Upload.aspx page ?

Hey.

Very common issue, that I was also asked to do over clients in past version of Sharepoint too.

Well, by default when you create a Doclib , in the upload.aspx page the "overwrite" checkbox is checked. The outcome is that people overwrites files by accident.

So how you uncheck this checkbox on all your doclibs ? Change it in the templates.

This is how -

in Wss 2.0 , go your sharepoint hive, under the TEMPLATE folder ( TEMPLATE\1033\SPSTOC\LISTS\DOCLIB ) - backup the Schema.xml file and change the follwing lines :
 




change the value to FALSE.

And then scroll a bit down and track down this line -
 




and delete the word CHECKED.

Now save the file, do an iisreset - and the upload.aspx page is done.

in Wss 3.0, it's even simplier because all of those pages are application pages.

Just go to the sharepoint hive ( 12\template\layouts ) , backup and open the upload.aspx file.
Track down this line -

 




and just change the "Checked" attribue to "false".

BE AWARE - on every hotfix/service pack you need to check that the file hasnt change. If it did, remember to fix it again.

Enjoy.

Friday, October 9, 2009

How to check if list is a document library ? Let's Linq it !

Sometimes you need to iterate via the Doclibs of a site for a dedicated reason, and there is no need to iterate via the "regular" lists of the site.

Of course it's very easy so you usually just run something like that -

 
SPWeb web = site.Openweb();
SPListCollection listCol = web.lists;
foreach(SPList list in listCol )
{
//Do your thing
}


So in order to be more efficient, run only in doclibs, and not on all lists that you have in your website ( including hidden ones ).

How you do that ? very simple.

 
SPWeb web = site.Openweb();
SPListCollection listCol = web.lists;
foreach(SPList list in listCol )
{
if(list.BaseType == SPBaseType.DocumentLibrary)
{
//Do your thing
}
}


And to make it even nicer, lets just LINQ it -
 
var docLibs = from SPList list in web.Lists where (list.BaseType == SPBaseType.DocumentLibrary) select list;
foreach (SPList doclib in docLibs)
{
//do your thing
}


Hope it helps.

Sunday, August 23, 2009

How to edit / update / change "Read Only" list columns

We had to retrieve data from our archive storage, back to the sharepoint sites. The problem was that when we retrieved the data back to the sharepoint doclib\lists we changed the Meta Data of our items ( such as Modified, Modified By ) which most of them appear as "read only" columns.

The solution - We had to interfere in our lists, and touch those "read only" columns \ Fields. Remembering we had to avoid changing those lists\Doclibs columns and keep the "old" metadata ( before the retrieval process ).

Code Snippet for how changing the data in the "read only" column such as "Modified" -

 

SPFieldCollection colFields = list.Fields;
for (int i = 0; i < colFields.Count; i++)
{
SPField field = colFields[i];
try
{

if (list.Fields[i].Title == "Modified")
{
if (field.ReadOnlyField)
{
list.Fields[i].ReadOnlyField = false;
for (int j = 0; j < list.Items.Count; j++)
{
SPListItem oListItem = list.Items[j];
DateTime date = (DateTime)oListItem[list.Fields[i].Title];

// updating the relvant stuff on that item.

oListItem[list.Fields[i].Title] = date;
oListItem.Update();

}
}
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}


You can play with it more, and adjust it. Hope you got the idea.

Good luck.

Thursday, July 23, 2009

How to change SQL server name ?

A very common issue, when you make a p2v ( convert in vmare language ) to a physical Server and change the name of the server.

The whole idea is that the database still thinks it's on the pervious database and it damages his functionalty.

Those are the steps to check if you have this issue, and how to fix that.

 
//check the hosting server of the SQL service
sp_helpserver
select @@servername

//if the server name that appears is of the pervious server
// Make sure to run it from the server itself, NO remote execution
sp_dropserver 'old_name'
go
sp_addserver 'new_name','local'
go
// Now restart the SQL service and check the first step again to make sure.


Good luck