Showing posts with label Sharepoint2010. Show all posts
Showing posts with label Sharepoint2010. Show all posts

Monday, 24 September 2012

Claims, forms and the root site

If you have a web application configured with claims (in this case with Windows authentication) in SP2010 and want to use People Picker control in an Infopath form. Make sure you have a site collection at root (http://nameofapp/) which all users atleast have read access to.

I got the following error in the event viewer if the root site collection is not created and readable for all users:

"an exception occurred in ad claim provider when calling spclaimprovider.fillsearch(): access denied.."

You can also set the ULS category "General" for "SharePoint Foundation" to see this behaviour.

Wednesday, 6 April 2011

Decrypting error in multi-forest environment

In the ULS for a SharePoint 2010 Server after a trust between two domains has been re-configured: Decryption failed with error 0:" (and the rest of the callstack) Solution: stsadm -o setapppassword -password "SomeString" (on all WFE:s) stsadm -o setproperty -pn peoplepicker-searchadforests -pv "ForestDomainUserString" No IISResets needed.

Wednesday, 10 November 2010

Code example for EnabledScript element in Ribbon XML

Andrew Connel explains how to enable and disable buttons in the Ribbon based on a condition.

I need to check a field value on the selected item and the item permission and then enable / disable multiple buttons. I assume that you have some knowledge about the Ribbon XML structure :).


//Should only be enabled when IssueStatus == Report
      <CommandUIHandler
Command="Tab.CloseIssue"
CommandAction="javascript:EditDeviation('{ListId}');"
EnabledScript="javascript:SingleEnable('Report',SP.PermissionKind.editListItems);"/>

//Should always be enabled
      <CommandUIHandler
Command="Tab.CurrentStatus"
CommandAction="javascript:DisplayStatus('{ListId}');"
EnabledScript="javascript:SingleEnable('All',,SP.PermissionKind.viewListItems);"/>


function SingleEnable(EnableForStatus, PermissionKind) {

var result = false;

var selectedItems = SP.ListOperation.Selection.getSelectedItems();
var ci2 = CountDictionary(selectedItems);
if (ci2 == 1) {

if (this.IssueRibbonItemId == null) {

this.IssueRibbonItemId = selectedItems[0]['id'];
var listGuid = SP.ListOperation.Selection.getSelectedList();
getStatus(this.IssueRibbonItemId, listGuid);

}
else if (this.IssueRibbonItemId != selectedItems[0]['id']) {

this.IssueRibbonItemId = selectedItems[0]['id'];
var listGuid = SP.ListOperation.Selection.getSelectedList();
getStatus(this.IssueRibbonItemId, listGuid);
}
else if(this.IssueRibbonStatus != null){

if (this.IssueRibbonStatus == EnableForStatus || EnableForStatus == '') {
if(this.IssueItem.get_effectiveBasePermissions().has(PermissionKind)){
result = true;
}
}
}
}

return result;
}

function getStatus(ItemId, listGuid) {

var clientContext = new SP.ClientContext();
var web = clientContext.get_web();
var lists = web.get_lists();
var list = lists.getById(listGuid);
this.IssueItem = list.getItemById(ItemId);

clientContext.load(IssueItem, 'IssueStatus', 'EffectiveBasePermissions');
clientContext.executeQueryAsync(Function.createDelegate(this, this.onStatusQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}


function onStatusQuerySucceeded(sender, args) {
this.IssueRibbonStatus = this.IssueItem.get_item("IssueStatus");
RefreshCommandUI(); //Makes the EnabledScrip method to be enabled again.
}

function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

Monday, 1 November 2010

Some TaxonomyField things and code

Before a new term can be used for tagging in a web site it needs to be added to the hidden list "TaxonomyHiddenList".
Several suggestions how to add a new term with code has been posted and this is my conclusion:

Adding a new term to an item:

TaxonomyField tf = item.Fields["ColumnName"] as TaxonomyField;
tf.SetFieldValue(item,term);
item.Update();

This doesn´t work for new items:

int hiddenTermId = -1;
int[] wssIds = TaxonomyField.GetWssIdsOfTerm(site, TermStore.Id, TermSet.Id, Term.Id, false, 1);

if(wssIds.Length > 0)
hiddenTermId = wssIds[0];

TaxonomyFieldValue tfv = new TaxonomyFieldValue(termId + ";#" + term.Name + TaxonomyField.TaxonomyGuidLabelDelimiter + term.Id.ToString())

or this:

string termString = String.Concat("-1", SPFieldMultiColumnValue.Delimiter, term.GetDefaultLabel(1033));
TaxonomyFieldValue tfv = new TaxonomyFieldValue(termString);

Add a comment if you have any question.

Friday, 27 August 2010

MissingSetupFile for themes

Running Test-SPContentDatabase for migration preparation. The report contained errors referring to missing themes files. The web didn´t use the theme as the active theme but had used the theme before.

Start SPD and open the site. Browse to the themes folder and delete the theme folder referenced in "MissingSetupFiles". Open the web in the browser and delete the folder from the Recycle Bin and then also from the site collection Recycle Bin.

Wednesday, 28 April 2010

WebTemplate

Have noticed a long awaited feature in SP2010: WebTemplate! This means that you can add a template definition for one site collection only and not for the whole farm.

Friday, 4 December 2009

Push changes from a content hub

1. Change or add a content type in a content hub site.
2. Click on "Manage Publishing for this content type" in the content type administration page.
3.Click on "Publish" if it´s a new content type or "Republish" if it´s a content type update.
4. Fire up "SharePoint 2010 Management Shell" on the SharePoint server.
5. Run these commands to trigger the timer jobs for content hub sync:

Start-SPTimerJob MetadataHubTimerJob
Start-SPTimerJob MetadataSubscriberTimerJob

6. Check your "Job History" (Monitoring --> Check job status --> Job History) page in CA for the status of the timer jobs