Tuesday, January 19, 2010

How to update ShowInFileDlg programmatically


At some point in your SharePoint development life time you will probably need to update the ShowInFileDlg attribute of a Site Column.

If you will try to do that by a feature and update the XML with new Field's attributes values, the changes will only take effect on new instances, and will not effect on exsisting ContentTypes or Lists that use these Site Columns.

Programmatically updating the Site Column and the Content Type, the changes will be deployed to the children as well.

Here is a generic method for updating any attribute of the Field element and forcing the changes to the Content Type and its children:

public void UpdateFieldAttribute(string siteCollectionURL, string siteColumnName, string contentTypeName, string fieldAttributeName, string fieldAttributeValue)
{
SPSite site = null;
SPWeb web = null;
try
{
using (site = new SPSite(siteCollectionURL))
{
using (web = site.OpenWeb())
{

SPField siteColumn = site.RootWeb.Fields.GetField(siteColumnName);
XmlDocument fieldSchemaXml = new XmlDocument();
fieldSchemaXml.LoadXml(siteColumn.SchemaXml);
XmlNode fieldXmlNode = fieldSchemaXml.SelectSingleNode("Field");
XmlAttribute attr = fieldXmlNode.Attributes[fieldAttributeName];
attr.InnerText = fieldAttributeValue; ;

siteColumn.SchemaXml = fieldXmlNode.OuterXml;
siteColumn.Update(true);

SPContentType contentType = site.RootWeb.ContentTypes[contentTypeName];

contentType.Update(true, false); //Updating the content type is important or the changes will not be reflected
}
}
}
finally
{
if (web != null)
web.Dispose();
if (site != null)
site.Dispose();
}
}

38 comments:

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

The information here is great. I will invite my friends here.

Thanks

Anonymous said...

Genial post and this fill someone in on helped me alot in my college assignement. Thank you on your information.

Anonymous said...

nice one! but why did you create the instance of spweb? it´s never used.

Anonymous said...

jtnkilp, xrumer linklist , eIDrfiS.

神待ち said...

クリスマス目前に家出少女にプレゼントしませんか?神待ちサイトに登録してる娘に連絡するだけで、物凄いプレゼントになるでしょう!!当然プレゼント返しは望みのまま

出合い系 said...

独り身で寂しい彼氏、彼女、クリスマスを一緒に過ごす異性が欲しくありませんか?確実に出会える出合い系サイトでパートナーをゲットして、今年のクリスマスは安心ですね

ワンピース said...

ワンピースの物知り自慢を争ってみませんか?なんか海賊王争いみたいで良いでしょう。ちょっとレアな問題とかも出ますが、結果によってはレアな称号、ヒグマ山賊団の頭の称号が手に入るかもって、いらないかな

Unknown said...

Google's vision of a pc in which all the things was on the net turned heads while in the tech world past yr, should the first Chromebooks appeared. The real acer aspire 5536 battery
COMPAQ CQ61 Laptop Batteries earth? Considerably less impressed. Apple's iPad proved a much more persuasive concept for people today spending their hard-earned monies, but Google, undeterred, has gone back again towards the drawing board and up to date its Chrome OS.

Martin said...

Setting ShowInFileDlg doesn't work for Managed Metadata columns. You must customize Document Information Panel. More information can be found here http://social.technet.microsoft.com/Forums/en-US/17e1f67a-cf24-4abe-9366-2fba8e1d8fe4/hide-managed-metadata-column-in-document-information-pannel

yanmaneee said...

timberland outlet
fila
nike react
converse outlet
air max 2018
air jordan
coach outlet
golden goose outlet
off white hoodie
fila shoes

Assignment Help said...

The people to do my homework service you have been looking for is here. Get the best assignment help by PhD experts at affordable prices. Our assignment services are 100% risk free and are assured by 100%.
do my hw

David Warner said...

But garmin express never let you suffer because you have to do only one thing that is- connect your device to computer using USB and update garmin.com/express for better experience.
garmin.com express
garmin .com/express
garmin.comexpress
garmin express.com
garminexpressinstaller.exe
garmin express not working

James Marcus said...


Such a valuable post. I like it very much and I like your choice words also. Please post some more topics related to online help because I also work in the online professional support industry which provides support of Outlook. I am waiting for your next valuable post.
Thanks
How do I contact outlook by phone?
How do I contact Outlook support?
Is there a phone number for Outlook support?
Outlook Support Phone number
Microsoft Outlook Support

assignment help Sydney  said...

I am a college student and doing the study in the graduate-level course in Sydney. I have got some assignments to complete within the deadline, but I am so busy in the class and studying the courses assigned by the professors and tutors. Student life is so busy that every student can’t cover their course study. While studying, I am also doing job, therefore I don’t have much time for writing the assignments. So, I have a lot of pressure to complete the assignments within the deadline, so I am looking for the Assignment Help Sydney for completing the assignment writing services on time. Due to the lack of writing skills, I am not able to complete the assignments accurately and timely, so I have a lot of problems to submit the assignments on the time. So, I am looking for the best assignment writing Service Company in Sydney. Can anyone share the best assignment writing services Company?

Online Technical Help said...

This post is extremely amazing! This blog gives the ideas to take support from Outlook Support phone number.This post is helpful for users to obtain Microsoft Outlook Support from trained technicians. Thanks for sharing this post!
Outlook Support number
Outlook Support
How do I Contact Microsoft Outlook Support?
Is There A Phone Number To Call Outlook Support?
Is there a phone number for Outlook support?
How do I call Outlook support?

printersupportnumber said...

Nice Post..
I am An HP printer user and using HP printer for completing printing tasks on time. I prefer HP printer because of good quality features and improved performance. I know very well that HP printer is very easy in using and fast in the printing performance. From the last few days, my HP printer is not printing, so I am unable to print any document from my HP printer. It may be a very challenging and irritating issue for me. So I want to take help from a reliable support provider just like hp.com/support. Please put your suggestion here.
support.hp.com
www.hp.com/support
www.support.hp.com

jimmy andrew said...

There is no denying that HP printers have become an unavoidable part of the professional as well as personal life. From education, finance to IT industry, and others, these printers are used for high-quality printing. If you have bought this device and facing trouble in the set up of your HP printer, then you can follow the set of instructions from123.hp.com.setup. Apart from this, even after following the proper guideline from there your printer is still not functioning smoothly, and then you must contact us. Our team of technical experts will resolve the issue or guide you to fix the problem in the easiest possible way.

Assignment help said...

My Assignment Help provides ultimate Management Assignment help as we cover all the fields of the management such as project management , IT management and information , Human Resource management etc. We explore the necessary facts within provided time limit.

chloeting2701 said...

How much do you charge for Nursing Homework Help? I am stranded with an assignment here and therefore I want an experienced Nursing Assignment Help expert to help me. I have gone through your website and there are very many tutors. The only challenge is that I only have $50. If you can help with that price then I would be very happy.

Lucas Miller said...
This comment has been removed by the author.
Unknown said...

Hello. My son is looking for Probability homework help urgently. He is not very good with this subject and now he is adamant on improving his grades. Kindly tell me about your R Programming assignment help as well for best experiences. If that is possible, I can immediately join in with your team of tutors. Let me know whatever is possible. In case you are unable to offer any assistance of this sort, I will seek help from another tutor.

Rose Watkins said...
This comment has been removed by the author.
Windstream Email Login said...

I have gone through this article, and I found it really worthy. The in-depth content mentioned is really amazing and it really helped in gaining some insight in this topic. I would request you to have a look on the roadrunner email login , Bellsouth email login , Windstream Email Login , Bellsouth.Net Email Login , Www.Windstream.Net Email Login

123hpcomsetup said...

Useful information.

Thanks for sharing.Are you tired up how to scan on hp envy printer ? We assist the scan setup, driver download, and wireless setup.

How to scan on hp envy 6055 printer ? |  How to scan on hp envy 7855 Printer ? | How to scan on hp deskjet 2652 printer? | How to scan on hp deskjet 3755 printer?

How to scan on hp officejet 3830 printer? | How to scan on hp officejet 5255 printer? | How to scan on hp officejet pro 8035 printer? | 

How to scan on hp officejet pro 9015 printer?.

Renould Asik said...

Hey. I am looking for statistics assignment help right now at the best prices. I live in India right now but will soon be shifting to Australia forever. So, let me know if you can offer online classes to me for the same. I also require economics homework help at your service for the best academic experience. I also want chemistry homework help right away. So, please help me out with all these subjects at once. Do not delay any more. Thank you for your time and support. I am waiting for your response. Please let me know about them as soon as possible.

Edward said...

I want a wireless HP printer for wireless printing favor. Wireless printing technology permits the users to print the files wirelessly simply. It makes users feel free and is the best way to get the pinout of any file easily 123.hp.com.setup.

Unknown said...

What if I say that this is one of the best article of this topic & it is well written with the good amount of content.

Nursing Assignment Help

Leo Oliver said...


Our Econometrics Assignment Help is accessible 24 hours a day, 7 days a week to assist you with your econometric assignment. The solutions are given in an easy-to-understand step-by-step format. Thousands of students in the United States, the United Kingdom, Canada, Australia, and other countries have benefited from our Econometrics guidance. We are here to assist you with your Econometrics assignment.

Omsdelhi said...

kamagra Gold 100mg Tablet, a prescription medicine, is used to treat male impotence. Increased blood flow to the external male genitalia is how the drug works. As a result, guys have an easier time getting and maintaining an erection. It belongs to the class of drugs known as phosphodiesterase type 5 (PDE5) inhibitors. Get this medicine now from Omsdelhi.

Leo Oliver said...

Offering students with Microeconomics Assignment Help means assisting them with duties such as economic cost, basic economics, and market positioning. Microeconomics assignment help is necessary for students to properly study challenges with organization and corporation budgeting and utilisation by writing essential assignments on these challenging themes.

EIbass said...

I compliment the effort put towards creating this content, its quite relevant and interesting mapoly post utme form registration deadline

Naturecamp Travels said...

Don’t think more about your Dooars Trip Package. Naturecamp Travels has been always ready to provide you with help during your tour. You will find all the arrangements here. From receiving the Airport and till drop at Airport, our agents will be there with you. To know more, reach us now.

Oms99 said...

Oms99 has a huge variety of medicines for various issues. You can now order these online male sex medicines from the comfort of your home with just a click on your mobile or computer. Online Buy Kamagra Jelly from us.

Lumiere Holidays said...

Explore the enchanting beauty of Kashmir with our curated tour packages. Immerse yourself in the breathtaking landscapes of snow-capped mountains, serene lakes, and lush valleys. Embark on a memorable journey to Kashmir with our tailored Kashmir Tour Package. Witness stunning valleys, lakes, and cultural richness. Book your package at Lumiere Holidays.

Fajil Hura said...

Unveil the spiritual heart of India with our immersive Varanasi Holiday Packages. Embark on a sacred pilgrimage with the transformative Chardham Tour, visiting holy shrines. Immerse yourself in history and culture through the iconic Golden Triangle India tour, covering Delhi, Agra, and Jaipur. Explore India's diverse essence with these incredible journeys.

unknow said...

Discover inner harmony with our diverse 2 Feet Buddha Statue and Fibre Buddha Statue, carefully selected for The Stone Studio. Each sculpture embodies peace and spiritual enlightenment, offering a gateway to serenity. Explore our collection of Buddha statues for sale and invite the essence of enlightenment into your space.