Thursday, January 31, 2013

In IIS 7 to change process model identity click on application pool -> advanced settings

To change ping timeout

http://stackoverflow.com/questions/1421578/why-does-debugging-keep-timing-out-in-iis7
Entity Object generator

http://msdn.microsoft.com/en-gb/library/vstudio/ff477605(v=vs.100).aspx

http://stackoverflow.com/questions/1814469/ado-net-entityobject-generator

http://www.code-magazine.com/Article.aspx?quickid=0909081

http://msmvps.com/blogs/matthieu/archive/2009/09/02/ado-net-entityobject-generator-how-to-get-the-entitytype-s-entityset-and-how-to-get-entityset-s-entitytypes.aspx

After generating entity model and using it in the c# code I was getting error "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'", it was resolved after removing "
integrated security=True;multipleactiveresultsets=True;App=EntityFramework;" from the connection string auto-generated by entity framework

Wednesday, January 23, 2013

In Place Record Management
http://saifalmaluk.wordpress.com/2012/02/24/configuring-in-place-records-management-in-sharepoint-2010/

Create records center
http://www.c-sharpcorner.com/UploadFile/Roji.Joy/how-to-configure-record-centre-in-sharepoint-2010/

This post explains that a web service OfficalFile.asmx should be used to configure sent to connection however, I was getting below error

Url validation failed for http://mysite/sites/testrecordcenter/_vti_bin/OfficialFile.asmx during Record and document center connection configuration with exception The request failed with HTTP status 401: Unauthorized.:

Resolution
http://blogs.msdn.com/b/sharepoint_2010/archive/2011/06/13/unable-to-create-a-quot-send-to-connection-quot-verification-failed-url-is-a-not-a-valid-routing-destination.aspx

Anddddd.... it worked !! But just as mentioned in a comment there, this is not a safe way so followed below steps also mentioned in the comment and everything is working again !!!

http://support.microsoft.com/kb/896861

 

Monday, January 21, 2013

If sharepoint site has FBA or mixed mode authentication, then Report Builder can be temporarily used with and extended URL mapped to that site

A report model can be created using SSRS development studio which has shared data source and this data source can be used by multiple reports.

Deploy report model
http://msdn.microsoft.com/en-us/library/ms159695(v=sql.105).aspx

Tuesday, January 15, 2013

Linq to sharepoint library automatically removes spaces between choice options, to get correct choice values we have to use extention methods as described below

http://sharepoint.stackexchange.com/questions/21750/frustrated-linq-to-sharepoint-choice-values-losing-spaces

http://blogs.msdn.com/b/sharepointdev/archive/2011/05/03/using-linq-to-sharepoint-with-choice-fields.aspx

this method does not work for multiple choice fields, so I have created a new static method (which is not an extension method)

public static string StringValueOf(object obj,string propertyName)
{string returnValue = string.Empty;
if (((Microsoft.SharePoint.Linq.ColumnAttribute)(obj.GetType().GetProperty(propertyName).GetCustomAttributes(false)[0])).FieldType == "MultiChoice")
{string allvalues = Convert.ToString(obj.GetType().GetProperty(propertyName).GetValue(obj,null));
string[] values = allvalues.Split(",".ToCharArray());
foreach (string value in values)
{string actualValue = string.Empty;
FieldInfo fi = obj.GetType().GetProperty(propertyName).GetValue(obj, null).GetType().GetField(value.Trim());
Microsoft.SharePoint.Linq.ChoiceAttribute[] attributes = (Microsoft.SharePoint.Linq.ChoiceAttribute[])fi.GetCustomAttributes(typeof(Microsoft.SharePoint.Linq.ChoiceAttribute), false);
if (attributes.Length > 0)
{
actualValue = attributes[0].Value;
}
else
{
actualValue = value.ToString();
}
if (returnValue.Length > 0)
{
returnValue +=
", " + actualValue;
}
else
{
returnValue = actualValue;
}
}
}
else
{
string value = Convert.ToString(obj.GetType().GetProperty(propertyName).GetValue(obj, null));
FieldInfo fi = obj.GetType().GetProperty(propertyName).GetValue(obj, null).GetType().GetField(value);
Microsoft.SharePoint.Linq.ChoiceAttribute[] attributes = (Microsoft.SharePoint.Linq.ChoiceAttribute[])fi.GetCustomAttributes(typeof(Microsoft.SharePoint.Linq.ChoiceAttribute), false);
if (attributes.Length > 0)
{
returnValue = attributes[0].Value;
}          
else
{
returnValue = value.ToString();
}
}
return returnValue;
}
ASP.Net special tags

<% %> An embedded code block is server code that executes during the page's render phase. The code in the block can execute programming statements and call functions in the current page class.http://msdn2.microsoft.com/en-gb/library/ms178135(vs.80).aspx
<%= %> most useful for displaying single pieces of information.http://msdn2.microsoft.com/en-us/library/6dwsdcf5(VS.71).aspx
<%# %> Data Binding Expression Syntax. http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx
<%$ %> ASP.NET Expression. http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx
<%@ %> Directive Syntax. http://msdn2.microsoft.com/en-us/library/xz702w3e(VS.80).aspx
<%-- --%> Server-Side Comments. http://msdn2.microsoft.com/en-US/library/4acf8afk.aspx
<%: %> Like <%= %> But HtmlEncodes the output (new with Asp.Net 4).http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx

Source: http://forums.asp.net/p/1139381/1828702.aspx
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/pages/syntax.aspx

Friday, January 11, 2013

If BDC external data column has been added to a custom list, easiest way to retrieve an item using filter conditions is similar to

using

(MyWebDataContext context = new MyWebDataContext(SPContext.Current.Web.Url))

{


SPList myList = SPContext.Current.Web.Lists["My List Title"];


var myListResult = context.AthleteAppearances.Where(r => r.UniqueColumn == "filter value").FirstOrDefault();


if (myListResult != null && myListResult.Id.HasValue)

{


SPListItem myItem = myList.GetItemByIdAllFields(myListResult.Id.Value);


//Add your code to update the list item here

}
}
 

Thursday, January 10, 2013

Insert value into a Column which lookup data from an External List

http://social.technet.microsoft.com/forums/en-US/sharepointdevelopmentprevious/thread/490dc593-5a18-47fc-9b66-00567efcc61c/
http://zimmergren.net/technical/sp-2010-programmatically-work-with-external-lists-bcs-using-the-client-object-model

http://msdn.microsoft.com/en-us/library/microsoft.businessdata.metadatamodel.ientity.getfinderview.aspx

http://msdn.microsoft.com/en-us/library/ff798357.aspx

And finally ... when none of the above is working, I found the correct approach

http://wadehuntersblog.blogspot.co.uk/2008/10/progrmatically-set-bdc-column.html
http://dotnetfollower.com/wordpress/2011/12/sharepoint-understanding-businessdata-column-bdc-field/

I have used code similar to:

SPField bdcField = spItem.Fields[sBDCColumnName];
XmlDocument xmlData = new XmlDocument();
xmlData.LoadXml(bdcField.SchemaXml);
String sEntityName = xmlData.FirstChild.Attributes["RelatedFieldWssStaticName"].Value;

spItem[sEntityName] = EntityInstanceIdEncoder.EncodeEntityInstanceId(new object[] { Value });
spItem[sBDCColumnName] = Value;
spItem[ BDCFieldName + ": " + BDCDisplayFieldName ] = "SomeValue";

// ex: spItem["Products: Name"] = "XYZ";


I This works for both External Data Columns and lookup columns created from external lists
Using the SPQuery class is the only supported server object model approach for programmatically working with data in external lists.

http://msdn.microsoft.com/en-us/library/ff798485.aspx

Wednesday, January 9, 2013

External lists can not display more than 2000 items, this had me stumped for many hours

http://social.technet.microsoft.com/forums/en-US/sharepointadminprevious/thread/cc05f9d6-b83b-4e43-8f5b-400dd16ff795/

Sridhar has explained some fixes in the post below, but did not try them, just changed criteria so that less number of records are fetched.

http://blogs.msdn.com/b/sridhara/archive/2010/03/10/bcs-and-external-list-learning-part1.aspx
To copy already created BDC model to new model follow these steps:

1) Add new BDC model with a new name
2) Copy and paste entity_name.cs file from old BDC model folder to new BDC model folder and change namespace to the new model namespace
3) Keep existing entity in the new model as it is and add a new entity
4) Rename new entity and add only primary key identifier to it
6) Add a ReadItem method to new entity using BDCMethod details window (Create specific finder method)
7) Change type descriptor of ReadItem return parameter to new custom entity class created in step 4, the method should be accepting primary key identifier created in step 4 as its only parameter.
8) Add ReadList method in similar way, this automatically recognises and uses new_entity_class as its return parameter.
9) Deploy solution and provide all permissions to the BDC model in SharePoint Central Administration
4) Open old_BDCModel.bdcm file using text editor and copy all identifiers and type descriptors list
5) Open new_BDCModel.bdcm file using text editor and replace its identifiers and type descriptors list with the one copied in above step
10) Try to create a new external list and verify that this content type is displyed in the available external content types list, this should throw "Method Not Implemented" error
11) Edit new_entity_nameservice.cs file and add functionality to ReadItem and ReadList methods.
12) Deploy and test

Important: Identifiers work similar to primary key for the entity while type descriptors work similar to properties

Update 26-Mar-2013: I learned it the hard way that

1) Identifier property must be specified for primary key type descriptor, else an external list can not be created with the enitity
2) Class returned by ReadItem and ReadList methods must have exactly same number and type of parameters as the type descriptors of method
3) All fields (type descriptors) must be recreated, they can not be copy pasted.
Oracle BDC
http://msdn.microsoft.com/en-us/library/ff464424(v=office.14).aspx
http://www.c-sharpcorner.com/uploadfile/anavijai/integrating-oracle-into-sharepoint-2010-using-business-data-connectivity-model/

After adding a new entity to BDC data model, I was not able to see it in Central Administration >> Application Management >> Manage Service Applications >> Business Data Connectivity Service >> External Content Types list, it became visible when I set "Estimated Instance Count" property to 1000
 

Tuesday, January 8, 2013

Using spmetal and linq

http://blog.technock.net/2012/11/how-to-use-linq-spmetal-in-sharepoint.html

SPMetal.exe gets error: The Web application cound not be found.

http://rabbitmaomao.wordpress.com/2010/10/08/spmetal-exe-gets-error-the-web-application-cound-not-be-found/

I started receiving the error: "Error occurred in deployment step 'Recycle IIS Application Pool': Not found" after trying to deploy solution in VS2010,

solution: Provide permissions to SharePoint_config and WSS_Content databases


 
For config settings use

System.Configuration.
ConfigurationManager.ConnectionStrings["MyConnectionName"].ConnectionString

Friday, January 4, 2013

Connect to oracle from Visual Studio

http://blogs.msdn.com/b/kaevans/archive/2009/07/18/connecting-to-oracle-from-visual-studio.aspx

If connection to oracle database throws the error "Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed"

https://forums.oracle.com/forums/thread.jspa?messageID=10719809

Still this was not working so installed 32 bit oracle client version (on top or earlier 64 bit version) and yet this failed to work.

Finally added tns_names variable as explained below and the connection is now working.

http://yyosifov.blogspot.co.uk/2011/10/ora-12154-tnscould-not-resolve-connect.html
http://kb.tableausoftware.com/articles/knowledgebase/oracle-connection
Machine.config location

%windir%\Microsoft.NET\Framework\framework_version\CONFIG

but framework 3.5 uses the same as 2.0

http://forums.asp.net/p/1202081/2095050.aspx#2095050
To assign value to a choice field using entity framework, enum generated by SPMetal has to be used.

http://www.codeproject.com/Articles/168714/Using-SPMetal
Error while deploying BCS data model

Error 22 Error occurred in deployment step 'Add Solution': The default web application could not be determined. Set the SiteUrl property in feature Feature1 to the URL of the desired site and retry activation.
Parameter name: properties



Solution: Follow these steps

1) Open your Feature Designer
2) Click on the Manifest tab
3) Click on Edit Options to append your changes to the manifest file
3) Add the SiteUrl property in the manifest template
<Properties>
<Property Key=”SiteUrl” Value=”http://<your-site-name>” />
</Properties>


http://go4answers.webhost4life.com/Example/error-deploying-bcs-model-sharepoint-132591.aspx
http://weblogs.asp.net/jan/archive/2010/05/07/sharepoint-2010-bdc-model-deployment-issue-the-default-web-application-could-not-be-determined.aspx

Thursday, January 3, 2013

Interesting .. Show InfoPath forms data using XML Web Part

http://dkolitha.wordpress.com/2008/02/25/show-infopath-forms-data-using-xml-web-part/
Infopath concat values in a multi selection list box

in xpath editor enter below value

substring(xdMath:Eval(xdMath:Eval(dfs:dataFields/my:SharePointListItem_RW/my:FieldToConcat/Value[. != ""], 'concat(", ", .)'), ".."), 3)

references
http://sharepoint.stackexchange.com/questions/27154/binding-multi-selection-listbox-in-infopath-form-2010
http://youdhbir.blogspot.co.uk/2012/08/using-multiple-selection-list-box.html
 

Secure micro services using jwt and ocelot

  Secure Microservices Using JWT With Ocelot in .NET Core (code-maze.com)