How to open InfoPath form in browser from workflow status page even though InfoPath client is installed

In our project we have browser enabled InfoPath form and workflow. Whenever we tried to open InfoPath form from workflow status page (WrkStat.aspx) page, if InfoPath client is installed on client machine then it always opened InfoPath form in InfoPath client even though InfoPath form is browser enabled. Our customer has requirement that InfoPath form must be opened in browser irrespective of InfoPath client is installed or not. So after doing research we found an alternative, if we add a query string parameter to InfoPath form XML URL, ?OpenIn=Browser then InfoPath form always opens in browser even though InfoPath client is installed. Now to implement this solution we have two options,

<!–[if !supportLists]–>

1.

<!–[endif]–>

Either modify OOB workflow status page

<!–[if !supportLists]–>

2.

<!–[endif]–>

Copy and have our own separate workflow status page and then change it Definitely first option is not the recommended solution. So we copied OOB workflow status page and then modified it. In workflow status page, there is variable called StrUrlItem which contains the URL of InfoPath form xml. The original code is like<% if (!string.IsNullOrEmpty(StrUrlItem)) { %> onclick=<%SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(StrOnClickItem),Response.Output);%>> <% } SPHttpUtility.HtmlEncode(StrNameItem,Response.Output); if (!string.IsNullOrEmpty(StrUrlItem)) { %> <% } %>So we changed the above code and made it as follows<% if (!string.IsNullOrEmpty(StrUrlItem)) { StrUrlItem = StrUrlItem + “?OpenIn=Browser”; %> onclick=<%SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(StrOnClickItem),Response.Output);%>> <% } SPHttpUtility.HtmlEncode(StrNameItem,Response.Output); if (!string.IsNullOrEmpty(StrUrlItem)) { %> <% } %>Now once workflow status page get customized we need to change the URL of workflow status page in workflow.xml file as _layouts/{Our folder}/WrkStat.aspx

Advertisements

SPSiteDataQuery understanding with examples for SharePoint 2010

SPSiteDataQuery can be used to perform cross-site and cross-list queries. In order to use it, you must call SPWeb.GetSiteData method on the appropriate web and provide a SPSiteDataquery object.

SPSiteDataQuery and SPQuery differ SPSiteDataQueries ability to search more than a single site or single list. SPSiteDataQuery can be configured to search in all lists of a particular list type or list base type located in either

1) The complete site collection

2) a particular site and sub-sites

Using SPSiteDataQuery.Webs property you can specify where the data will be retrieved from. This property can have one of the following values:

“” (or string.Empty) – default value : will search only the SPWeb on which you run GetSiteData

“<Webs Scope=’SiteCollection’ />” : will search on all webs in the site collection

“<Webs Scope=’Recursive’ />” : will search the SPWeb on which you run GetSiteData and all subwebs

You can restrict the search using Lists and Query properties. In the following example we query all contacts lists in the site collection for items containing John in the Last Name field:SPSiteDataQuery query = new SPSiteDataQuery();

//query contacts list.

query.Lists = “<Lists ServerTemplate=’105′ />”;

query.ViewFields = “<FieldRef Name=’Title’ />”;

query.Query = “<Where><Contains>” +

“<FieldRef Name=’Title’ /><Value Type=’text’>John</Value>”+

“</Contains></Where>”;

query.Webs = “<Webs Scope=’SiteCollection’ />”;

DataTable dt = SPContext.Current.Web.GetSiteData(query);

For the Lists property you can use constructs like:

<Lists ServerTemplate=’10001′ /> – query lists with template 10001

<Lists BaseType=’5′ /> – Issues lists

<Lists><List ID=”960BF6F6-F264-4305-B3CB-BDB9BF8F67DF” /></Lists> – query a specific list