SharePoint 2010 FAST Search : Property doesn’t exist or is used in a manner inconsistent with schema settings

In order to fix error Property doesn’t exist or is used in a manner inconsistent with schema settings ,

1. Double check the data-type of any newly created Managed Property with respect to the crawled property.

2. Start full crawl the content source and verify if search started working properly.

3. In case search result still shows the same error, then run the following command in FAST Powershell ,  followed by full crawl, read.

                                        nctrl restart qrserver

 

 

How to create a Lookup Field From Sub-Site List to Root-Site Collection List (Cross-Site Lookup)

This solution is based on power shell script for creating cross site look up field.

For example there is a sub site http://mksportal/site1 which contains a list “Product Name”  and
there is another sub site http://mksportal/site2/site3.
In order to make cross site look up field available to sub site through content type,
this can be achieved by using power shell script.

There are couple of things mandatory, when cross site look up is created on that time both sub site and list must exist because it is dependent on list ID.
This is basic script, one can customize further like add reference field for the same lookup field mapped to other field like ID etc.
try
{

$mksWebSite =  “http://mksPortal/Site1″

$spweb = Get-SPWeb $mksWebSite
$webids=$spweb.ID

$lst = $spweb.Lists["Product Name"]

$fieldXML = ‘
<Field ID=”GUID”
Name=”mksField”
Group=”MKS
Type=”Lookup”
DisplayName=”mksField”
StaticName=”mksField”
List=”{‘ + $lst.ID +’}”
ShowField=”Title”
Overwrite=”TRUE”
WebId=”‘ + $webids + ‘”  ></Field>’

$field = $spweb.Site.RootWeb.Fields.AddFieldAsXml($fieldXML)
$fieldRef = $spweb.Site.RootWeb.Fields.AddFieldAsXml($mksFIELDRef)
$spweb.Site.RootWeb.Update()
$ctypeParent = $spweb.Site.RootWeb.availablecontenttypes["My Custo CType"]
$newContentType = $spweb.Site.RootWeb.ContentTypes[$ctypeParent.ID];
$fieldLink = new-object Microsoft.SharePoint.SPFieldLink($spweb.Site.RootWeb.Fields[ $fieldInternalName])
$newContentType.FieldLinks.Add($fieldLink)
$newContentType.Update()

$spweb.Dispose()

}

catch [System.SystemException]

{

write-host “Execution stopped due to: “+$_.Message -foregroundcolor Red

}

InfoPath Form Library doesn’t allow to save any changes

Sometime InfoPath form library doesn’t allow to save the changes made to list item.

It throws following error:-

ExceptionType: ‘SPException’ ExceptionMessage: ‘Changes could not be saved into the
document.
The property to change is read-only for the document’s content type, or the
document is missing XML elements
or attributes where the changes would be saved.
Try editing the document  in a Windows SharePoint Services-compatible XML editor
such as Microsoft Office InfoPath.

This problem happens when the Form Library contains several property promoted fields
and the form for which changes were made and supposed to save , doesn’t contains those
fields and blows up when trying to save.

To fix this issue, double check content type definition and linked field associated with that.

Some time problematic field got created, doesn’t remove just by deactivating/Uninstall of
feature because instance got created.
This is important to find the instance and remove it then use feature to install/activate to work properly.

Action Item to resolve this issue:-

To fix the problematic filed which blows up,
1. Create a unit test to identify the fields used in Infopath Form
2. Now Remove the filed column mapping from the content type associated in a list
3. Similarly remove the field mapping from content type in Site Collection
4. Remove the content type from the Site Collection
5. Redeploy the content Type so that the Push Down mechanism will update the child
content type

And this solved the problem.

Problem with multiple Infopath forms Associated to a Forms library.

In Forms Library some time field with type Note does not accepting
long text  for some InfoPath form and on the same time it accepts
long text for other InfoPath form.

It will give following error

ExceptionType: ‘SPException’ ExceptionMessage: ‘Invalid text value
A text field contains invalid data. Please check the value and try again.’

This types of problem occurs to those forms whose Field definition was
not properly associated to Infopath form content type.

To fix this strange behaviour check field definition in infopath form content type.

If the Form Template created using contentype definition then link
the field with that. If was created without content type definition then
go to content type definition gallery and find the content type for the
legacy deployed infopath form which got created when published.

After getting the name of the content type link the Field
and then it will start working  correctly.

How to revert library items to its previous working condition.

There are some scenarios in day to day development, where current changes need to revert to  its previous working condition.
This can be achieved by finding the correct Version from Version-History of the item
and restore it accordingly.
The below code snippet is just for information, for files in document library and has the same approach for List Item as well.

Sample code Snippet…..

using (SPSite mksSite = new SPSite(“http://devsp:9900/”))
{
using (SPWeb mksWeb = mksSite.OpenWeb())
{
mksWeb.AllowUnsafeUpdates = true;
SPList lst = mksWeb.Lists["helloListName"];
IEnumerable<SPListItem> demoLib = lst.Items.OfType<SPListItem>();
SPListItemCollection demoFormCollection = lst.Items;
XmlDocument itemVersionDoc = new XmlDocument();
using (WebClient client = new WebClient())
{
for (int i = 0; i < demoFormCollection.Count; i++)
{
SPListItem item = demoFormCollection[i];
byte[] fileByte = item.File.OpenBinary(SPOpenBinaryOptions.None);

// Validate your output if this is the correct one. THEN no further action required//

if (THE OUTPUT AFTER VALIDATION IS INCORRECT THEN)
{

IEnumerable<SPFileVersion> listItems = item.File.Versions.OfType<SPFileVersion>();

var allResults = listItems.OrderByDescending(prod => prod.ID);

foreach (var vitem in allResults)
{

bool needToFindOtherVersion = true;
{
if (needToFindOtherVersion)
{
//<MOST IMPORTANT> “_vti_history” IS THE PLACE FOR ALL THE VERSIONS//

client.Credentials = CredentialCache.DefaultCredentials;
fileByte = client.DownloadData(mksWeb.Url.TrimEnd(‘/’)
+ “/_vti_history/” + vitem.ID.ToString() + “/helloListName/” + item.Title);

//NOTE: fileByte is the OUTPUT from  VERSION HISTORY//

//CHECK IF THE OUTPUT IS THE CORRECT ONE AS PER REQUIREMENT//
if (THE OUTPUT AFTER VALIDATION IS INCORRECT THEN)
{
needToFindOtherVersion = true;
}
else
{
needToFindOtherVersion = false;

item.File.Versions.RestoreByLabel(vitem.VersionLabel);
Console.WriteLine(“Correct Version Restored Successfully.“);
break;
}
}

}
}

}
mksWeb.AllowUnsafeUpdates = false;
}

How to create Infopath Property Promotion Field using Feature

Steps to create Property Promotion field in Infopath form and map it to library :-

1. Open InfoPath form in design mode.
2. Create Property Promotion field from Form Option
3. Save InfoPath form as source.
4. Note down XPath of property promoted field
5. Open XSF file notedown the Guid or Change the Guid based on field    GUID
6. Create Field with node value of as of XPath
7. Deploy  Field in Site
8. Deploy Infopath Form using Custom Content Type and bind field to the Content Type

Now go to the Form Library all the Fileds will be available.   :-)

How to Create Custom Site Ribbon Tab with buttons

In this post I have demonstrated how to create custom Site scope Ribbon Tab , how to deployed and  enable in custom page and
control buttons inside the Tab i.e., enable/disable based on business requirement.
using ECMA Script.

1. When no item is selected, two button inside the custom Tab is disabled and the third one is always enable.

2. When first item is selected, then first button is enabled and the second button is disabled.


3. When both item are selected, then second button inside Tab is enabled and first is disabled and third Button remains enable

Create Ribbon definition :-

ustom Action
<CustomAction
Id=”IDEMO.MKSRibbon.CustomTabDeployment”
Location=”CommandUI.Ribbon”
Title=”Add custom tab to page”>

2. Tab Definition
<Tab Id=”HiMKSDemoIRibbon.CustomTabs”
Title=”Mukesh” Description=”Mukesh Menu”
Sequence=”102″ >

3. Define Scaling
<Scaling Id=”HiMKSDemoIRibbon.CustomTabs.Scaling”>
<MaxSize  Id=”HiMKSDemoIRibbon.CustomTabs.Scaling.NewGroup.MaxSize”
GroupId=”HiMKSDemoIRibbon.CustomTabs.MyGroup”
Size=”MukeshLarge”
Sequence=”2″/>
<Scale    Id=”HiMKSDemoIRibbon.CustomTabs.Scaling.NewGroup.Large”
GroupId=”HiMKSDemoIRibbon.CustomTabs.MyGroup”
Size=”MukeshLarge” Sequence=”3″/>

4. Define Group
<Group Id=”HiMKSDemoIRibbon.CustomTabs.MyGroup”
Sequence=”2″
Description=”"
Title=”My Group”
Template=”HiMKSDemoIRibbon.CustomTabs.MyTemplate”>

5. Control definition
<Button
Id=”HiMKSDemoIRibbon.CustomTabs.MyGroup.HelloWorld”
Command=”CustomTab.ButtonServerCommand”
Sequence=”3″
Image32by32=”/_LAYOUTS/INC/MKSRibbon/Img/network32_32r.png”
LabelText=”My Control !!!”
TemplateAlias=”RowI” ToolTipTitle=”Welcome Ribbon”
ToolTipDescription=”This is Button -1″/>

6. Template Defnition
<GroupTemplate Id=”HiMKSDemoIRibbon.CustomTabs.MyTemplate”>
<Layout Title=”MukeshLarge”   LayoutTitle=”MukeshLarge”>
<Section Alignment =”Top” Type=”OneRow”>
<Row>
<ControlRef DisplayMode =”Large” TemplateAlias=”RowI”/>

Deploy using Feature.

To make custom tab enable on custom site page this can be instantiated using webpart or usercontrol.

In this case custom webpart and pagecomponent ECMA Script is used

In page load register commands for the button click used Tab definition.

string initialTabId = “HiMKSDemoIRibbon.CustomTabs”;// “DemoRibbon.CustomTabs”;// “MKSRibbon.CustomTabaA”;

if (Page.Request.QueryString["id"] != null)
{
initialTabId = Page.Request.QueryString["id"].ToString();
}

if (!ribbon.IsTabAvailable(initialTabId))
{
ribbon.MakeTabAvailable(initialTabId);
ribbon.Minimized = false;
}
ribbon.InitialTabId = initialTabId;

var commands = new List<IRibbonCommand>();

commands.Add(new SPRibbonCommand(“CustomTab.ButtonServerCommand2″, “alert(’2′);”, “true”));
commands.Add(new SPRibbonCommand(“CustomTab.ButtonServerCommand”, “alert(’1′);”, “true”));

ScriptLink.RegisterScriptAfterUI(Page, “SP.Runtime.js”, false, true);
ScriptLink.RegisterScriptAfterUI(Page, “SP.js”, false, true);

//Initialize function
var manager = new SPRibbonScriptManager();
var methodInfo = typeof(SPRibbonScriptManager).GetMethod(
“RegisterInitializeFunction”,
BindingFlags.Instance | BindingFlags.NonPublic);
methodInfo.Invoke(
manager,
new object[]
{
Page,
“InitPageComponent”,
“/_layouts/INC/MKSRibbon/PageComponent.js”,
false,
“MKSRibbon.PageComponent.initialize()”
});

manager.RegisterGetCommandsFunction(Page, “getGlobalCommands”, commands);
manager.RegisterCommandEnabledFunction(Page, “commandEnabled”, commands);
manager.RegisterHandleCommandFunction(Page, “handleCommand”, commands);

How to open both Old and New Infopath Template Version in Form Library

In a situation when you want InfoPath XML form containing data required to load in the same version  of the InfoPath form template
it was created with.

After googling I didn’t find any  proper solution, one way I got by publishing using Infopath designer But this approach is not the
smart way to deploy in production environment.

Finally I am able to resolve this issue. :-)

To solve this problem we need to understand, Infopath form template will not work just by saving inside the SharePoint environment. In order to work it should be properly registered. Read more

To open infopath form in the same version when it was created , change the process instruction “HREF” value pointing  to old version of Infopath form template. In this way whenever infopath form will load it will always take the old Infopath form template
and on click of new it will open latest infopath form template .

The most important part is the deployment strategy, which should be capable enough to maintain both old and new version together.

PowerShell Command for SharePoint 2010

1.  Install / Uninstall and Activate/Deactivate Feature

$Hive14=’C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\’

$Url=’http://devsp:9901′
$Feature=’MKS.Services.ProdDev.Images’
$Path=’E:\WorkArea\MasterPage\’ + $Feature
$DestPath=$Hive14 + $Feature

Remove-Item $DestPath -recurse

Copy-Item $Path  $DestPath  -recurse
Disable-SPFeature $Feature -Url $Url
Uninstall-SPFeature $Feature
Install-SPFeature $Feature
Enable-SPFeature $Feature -Url $Url

2. Configuring MasterPage and CSS
$newLogoUrl=’http://devsp:9901/PublishingImages/_t/MukeshMainLogo_jpg.jpg’
$web = Get-SPWeb http://devsp:9901
$web.MasterUrl = “/_catalogs/masterpage/MKSProductDefaultMasterPage.master”
$web.CustomMasterUrl= “/_catalogs/masterpage/MKSProductDefaultMasterPage.master”
$web.AlternateCssUrl=”/_LAYOUTS/1033/STYLES/CUI.css”
$web.SiteLogoUrl = $newLogoUrl
$web.Update()
$web.Dispose()

How to handle limitations in SharePoint 2010 BCS when working with large data

In SharePoint 2010 when connecting with large data, it will give you error because throttling limit is set and default is 2000,
however this is also configurable using Powershell, but this is also not the solution and also not going to fit in all
scenario, when someone want to display 20 records in a web part and BCS is  fetching all the record.

This can be handled using object model by invoking BDC Metadata Method Instance and by passing input parameter
and this input parameter can be used to filter the number of record to display.

By using this approach it become quiet handy to full control over the method to execute and input parameter can
be set dynamically which can passed to Stored Procedure /or Custom method where these input
parameter can be used to limit the number of records to display ….

Follow

Get every new post delivered to your Inbox.