Client Object Model in SharePoint 2010

SharePoint 2010 offers client side object model for interacting with SharePoint content DB and Config DB.SharePoint API can be invoked from Javascript and Silverlight.Namespace and classes are similar to ServerSide ones.

Request to server are made in the XML form and return data comes as JSON response.This new feature of SharePoint offers exciting options for developing SharePoint UI.Inclusion of JSON in SharePoint APIs is great addition to the repertoire of SharePoint developer.I am particularly interested in JavaScript OM.The way it works is consequite server request are accumulated and sent in one shot to reduce server traffic.Technology has to be similar to Ajax of posting asynchronous XMLHTTP request to server.

Silverlight has new RIA framework to go along with it.In future RIA may get used in SharePoint developement.The javascript library for new ECMAScript OM is located in new ’14Hive’  “Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS” in file sp.js. This can be reference from pages like <SharePoint:ScriptLink Name=”sp.js” ………. />

Sample javascript code:

<script language=’javascript’>

var ctx=new SP.ClientContext.get_current();

this.web=ctx.get_web();

ctx.load(this.web);

ctx.executeQueryAnync(Function.createDelegate(this,this.onSuccess),Function.createDelegate(this,this.onFail));

function onSuccess(sender,args)

{

alert(this.web.get_title());

}

function onFail(sender,args)

{

alert(args.get_message());

}

</script>

Reference Article:

http://www.codeproject.com/Articles/60348/SharePoint-2010-Client-Object-Model-for-JavaScript.aspx

Custom task form for SharePoint Designer Workflow

There may be requirement while developing SharePoint Designer workflow for a custom task form.

Custom task form can capture user information like whether content is approved or rejected ,comments etc.SharePoint designer has OOB facility for providing custom task form.

Microsoft has greate article on this http://office.microsoft.com/en-us/sharepoint-designer-help/collect-data-from-a-user-in-a-workflow-HA010209808.aspx.There is action called ‘collect-data-from-a-user’ which provides wizard where one can define fields which are needed in the custom task form.This creates a custom task content type automatically and Custom Task form which captures the data.It is a ASPX page which is visible in concerned workflow folder in SPD.

The data captured by the custom task form can be used to update list item fields or decision making in the workflow.

The steps are as follows:

(1)Define ‘collect-data-from-a-user’ where fields for the custom task form are defined.

(2)Then define workflow variables which contains the task item id.

(3)Then define workflow variables which are set the values from the task item fields captured previously.The relavant task item is retreived by quering against the task id variable created earlier.

(4)Then the variables defined and set in the previous step can be used to set fields in the list item or decision making.

Reference articles:

http://nishantrana.wordpress.com/2009/01/29/collect-data-from-a-user-and-set-workflow-variable-action-in-sharepoint-designer/

http://office.microsoft.com/en-us/sharepoint-designer-help/collect-data-from-a-user-in-a-workflow-HA010209808.aspx

Silverlight and new .NET RIA framework

The new .NET RIA framework along with Silverlight provides a different type application architecture as far as .NET application development goes.

RIA provides something called Domain services which essentially is a services which kinda like a DAL which integrates with a backend datasource.I tried an example where database tables were mapped to .NET web application level by Entity Data Model entities.Then domain service is defined/created by using VS which gives OOB CRUD operations on entities pulled by EDMX.

Then the Silverlight component can use the Domain Service to pull the data.From xaml.cs ,one needs instantiate a DomainContext object which is kinda proxy class object of the DomainService defined the ASP.NET web application.

So it is like triggering data related activites like CRUD operation from purely presentation layer i.e. silverlight component of the application.This simplifies data related activities for a Silverlight application.Once you create an Domain Service from Visual Studio by selected the entity concerned it creates the CRUD operations automatically for that entity.

One needs to install msi for .NET RIA Framework to get the required components available in Visual Studio.In Visual Studio,one needs to select Silverlight Bussiness Application project template for creating RIA application.

Reference Articles:

http://dotnetslackers.com/articles/silverlight/ria-services-with-silverlight-3-part1.aspx

http://www.nikhilk.net/Entry.aspx?id=227

Silverlight data driven app with REST service

Next step in Silverlight exploration is to do some backend data related activity.

Silverlight being a client side technology,how CRUD operations work is matter of interest.It can integrate with webservices(asmx,wcf),REST etc.

Silverlight has it’s own controls for showing tabular form of data.The call to fetch data is to be made from xaml.cs file.HTTPGETREQUEST,WebClient can be used to fetch the data.Data retreival is asynchronous and callback function is used to process the returned dataset.My idea is that though it is asynchronous but definetely it is not clientside like Ajax or JSON.The actual data fetching call is initiated as serverside event.This needs certain amount of coding and understanding of how Silverlight data related controls work with respect to different type datasources and data presentation needs.

Need to explore Silverlight more to understand how this can improve userexperience at large.Just scratching the surface as of now.

Technology is similar to flash and has similar UI effects via its new set of controls.

Good reference article:

http://timheuer.com/blog/articles/silverlight-get-started-part-3-accessing-data.aspx

Silverlight Introduction

Wanted to explore Silverlight for sometime.But never took it seriously as I thought it is just related to designing fancy UI.

Anyway finally just started to scratch the surface as I was interested to know about both the RIA and how Silverlight will be benefited by new RIA framework coming out.

So first thing to know about Silverlight development is that it is client side technology so far as the code execution goes.

Once you are done with development ,a cab file(has a specific file extension invented by MS!!!@@##) which is embedded in ASPX or HTML file as an object just  the way flash files are embedded.

Then if you have silverlight installed in client machine the code executes at browser level.

The Visual Studio development includes two visual studio projects.One for silverlight component develpement and the other the parent .NET web application where the silverlight component will be embedded in ASPX /HTML pages.

The Silverlight component developement involved creating Silverlight pages and views etc. which have file extension XAML.There separate set of controls which are used in Silverlight pages and views.

The developement requires Silverlight developer SDK,toolkit and runtime.

XAML files when rendered on browser generates the UI.But during developement in Visual Studio it is difficult to understand what will be look and feel as VS IDE does not show the resultant UI which will be produced from the silverlight controls put together in the silverlight page or view.

MS has another product callled Blend which interprets the resultant UI look and feel at design time.So this can be helpful while designing silverlight apps.

Next step for me is to see how back end data related activities are pulled into Silverlight compoents…

Accessing Infopath form data programatically within workflow code

Recently I came across a scenario where infopath forms were used to store data in form library and there is workflow associated with the form library.

Now during the course of workflow there may be requirement to change the form data.

The form data may be available as columns in the form library and the item data can be read within the workflow as listitem fields but the list item or form associated can not be updated by updated list item fields.

In such a scenario,the infopath form associated with the item needs to be read in memory stream as an xml document object.

Then the particular field or node need to be accessed with XPath and updated.

Once you are done with all field updation then the XML Document need to be saved back.

There should have been APIs for accessing fields embedded in the form programatically rather reading the form as an XML docuemnt.

Anyway that is the way it works with SharePoint 2007 and InfoPath 2007.

Hope things are better in SharePoint 2010.