Skip to main content

Posts

Showing posts from January 1, 2017

Update all Pages to entire Sites and SubSite using Client Object Model C#

If you want to update, Delete any and all the list, document library, publishing library to entire site collection. Following code will be helpful to achieve this requirements. public static class Program { static void Main(string[] args) { try { using (ClientContext _context = GetSiteContext(Constants.DeploymentSiteUrl)) { var webs = clientContext.Site.EnumAllWebs(w => w.Title, w => w.Lists); foreach (var web in webs) { foreach (var list in web.Lists) { if (list.Title == "Pages") { Console.WriteLine(web.Title + "-----" + list.Title); result.Add(web.Title + list.Title); CamlQuery query = CamlQuery.CreateAllItemsQuery(); query.ViewXml = @" "; ListItemCollection

Set Taxonomy Field Value using Client Object Model in publishing page

Many time there are some cases. when people add or updates the publishing page it requires to set some field values. In this case I have covered Taxonomy Field. Following code will get current publishing page and set Taxonomy field Page Type to its value. // Comment jQuery(document).ready(function () { var pagelayout = ""; //current context var context = SP.ClientContext.get_current(); // current web var web = context.get_web(); // get pages library of current site var currentPageLibrary = web.get_lists().getById(_spPageContextInfo.pageListId); // get and load page item which is rendered var currentPageItem = currentPageLibrary.getItemById(_spPageContextInfo.pageItemId); context.load(currentPageItem); context.executeQueryAsync(function() { // get pagelayoutname var itm = currentPageItem.get_item("PublishingPageLayout"); if(itm != null) pagelayout = itm.get_description(); // get id of TaxonomyField Id var countriesControlId =j