manoj´ssharepointblog

SharePoint Blog


2 Comments

A look-up field contains invalid data. Please check the value and try again.

In My Case I have the above issue while updating the value of a taxonomy field.  This is caused due to the wrong TextField ID assosiated with the Taxonomy Field. By updating the TextField ID to the correct note Field ID. The above Issue is Solved.

Advertisements


Leave a comment

How to programmatically search for the Index Component in SharePoint 2013

At the company I work for, we are going to start working with synonyms in our Search results (we are still on SharePoint 2010). The synonyms will be maintained by our Content Editors team and therefore I decided to let them maintain the synonyms in the term store (Managed metadata service application), as it is done in SharePoint 2013. Every night a timer job will run to read the term store and to create the tsenu.xml file and to copy it to the \Microsoft Office Servers\14.0\Data\Office Server\ApplicationsGUID-query-0\config\tsenu.xml folder.

When our code goes in production, it goes through a DTAP process, meaning that our code needs to be deployed on dev, on test, on acceptance before it goes in production. So we have different SharePoint farms for the different environments. Although the SharePoint folders our always deployed to the same drive, the folder for the tsenu.xml can be different as one of the folders is the GUID of the Search Service Aplication. So I wanted that the timer job would figure out the correct folder using the Search topology.

SearchService s = new SearchService(“OSearch14”, SPFarm.Local);
if (s != null)
{
var srchApp = from SearchServiceApplication sapp in s.SearchApplications
where sapp.Name == “Enterprise Search Service Application”
select sapp;

SearchServiceApplication serviceApp = srchApp.FirstOrDefault();
if (serviceApp != null)
{
var queryComponent = serviceApp.QueryTopologies.ActiveTopology.QueryComponents.FirstOrDefault();
if (queryComponent != null)
{
string serverName = queryComponent.ServerName;
string directoryPath = queryComponent.IndexLocation;
string foldername = queryComponent.Name;

string configfoldername = directoryPath + “\\” + foldername + “\\Config”;
}
}
}


Leave a comment

How to Programmatically find Search Service Application in SharePoint 2013

We found a lot of posts that use the GetDefaultProxy method to get to the Search Service Application but in our case this piece of code always returned our first Search Service Application.

SPServiceContext serviceContext = SPServiceContext.GetContext(site);
SearchServiceApplicationProxy searchProxy =
serviceContext.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as SearchServiceApplicationProxy;
if (searchProxy != null)
{
SearchServiceApplicationInfo searchServiceAppInfo = searchProxy.GetSearchServiceApplicationInfo();
SearchServiceApplication searchServiceApp = SearchService.Service.SearchApplications.GetValue(
searchServiceAppInfo.SearchServiceApplicationId);
Schema searchSchema = new Schema(searchServiceApp);
}

Finally we came out with the following piece of code to get to the correct Search Service Application:

SPServiceContext serviceContext = SPServiceContext.GetContext(site);
SearchService searchService = new SearchService(“OSearch14”, SPFarm.Local);

var srchApp = from SearchServiceApplication sapp in searchService.SearchApplications
where sapp.Name == “Our other search service application”
select sapp;

SearchServiceApplication searchServiceApp = srchApp.First();
searchSchema = new Schema(searchApplication);This does not seemed to be the best way to get to a service application and after some time of research I found out that you can also write it like this, which seems a better way to me:

searchApplication = (SearchServiceApplication)SPFarm.Local.Services.
GetValue().
Applications.GetValue(“Our other search service application”);
It took us several hours to find this out, but I hope that these snippets can save someone a few hours in the future.


6 Comments

Adding Services to Default Application Proxy Group in SharePoint 2010 Using Powershell

$serviceAppProxy = Get-SPServiceApplicationProxy | where { $_.Name -eq “Name of the service” }
$proxygroup = Get-SPServiceApplicationProxyGroup | where { $_.FriendlyName -eq “[default]” }
Add-SPServiceApplicationProxyGroupMember -Identity $proxygroup -Member $serviceAppProxy