Monday, July 20, 2009

BDC to Show distinct Records

How to make MOSS BDC to Shaow distinct rows??? Sometimes using Distinct keyword in BDC query may fail in execution. To avoid this, simply create a view with the distinct query and call this view and query it without using distinct keyword. Makes simple...
Even in future, if you wanted to change the table from current to other, it is very easy, just a change in view...

Monday, July 13, 2009

SharePoint workflow in ASPX - Part 5

The final part of the process. We read the workflow values from ASPX page, now if anybody clicks approve or reject or any action, accordingly the workflow should react. To achieve this, in the task form, create a Hashtable and add item keys with the same name of Task After Properties and its value like this,
Hashtable taskProps = new Hashtable();
taskProps.Add("ApprovalStatus", "Approved");
taskProps.Add("Comments", "Approved");
taskProps.Add("CurrentUser", "NAME");
Now pass the value to workflow by calling the below functin,
SPWorkflowTask.AlterTask((SPListItem)item, taskProps, true);

Hope you got an idea of how to do this....

SharePoint Workflow in ASPX - Part 4

Now reading the values sent from Workflow in ASPX form. Basically, the infopath form reads all the Workflow values by looking @ metadat.xml. But in our case we need to get it from workflow task's extended properties. More clear: Once the task created by workflow, that task is viewable in workflow task. All those values sending from Workflow to task forms are passed thru extended properties of the task item. If we capture the workflow task item we can get the Extended properties of Workflow value.
If you look @ task form url-querystring, 2 values will be passed
ID - Task List item Id
List-List ID [GUID]
using the above values you can locate the correct task item.
Response.Write("Item ID:" + item.ID);
Response.Write("Item Name:" + item.Name);
Hashtable spTaskProperties = SPWorkflowTask.GetExtendedPropertiesAsHashtable((SPListItem)item);
foreach (DictionaryEntry entry in spTaskProperties) { Response.Write("Key :" + entry.Key.ToString() + ", Value: " + entry.Value.ToString()); }

Next: Sending value back to Workflow...

SharePoint Workflow in ASPX - Part 3

Associating ASPX form with workflow task:
Create a content type which is having your requierd columns in Workflow task.
Design a ASPX page of your custom logic, and keep the form in _Layouts folder. Provide the content type edit form url and display form url as this page.
Deploy the content type in SharePoint. This content type will be having 1 content type id, copy this content type id and paste it in Workflow.xml TaskContentTypeId.

Now all the task you are creating thru Workflow will be opened in that newly deployed ASPX page.

Next: How to read Workflow values from ASPX page.

SharePoint Workflow in ASPX - Part 2

Creating Initiation form in ASPX:
Create a content type same like properties pomoted from InfoPath form.
Now, design a simple ASPX form with all the required fields like desinging Infopath form. In the InfoPath we will be associating the form with the site and list. So that the submit functionality will do the insert operation. But in our case we need to write the method to insert the value into list.
After designing the form, copy and paste it in _layouts folder. So that this page will be accessible from all the sites.
In the content type provide Display form url, edit form url as the newly copied page in _layouts folder. Deploy this content type into SharePoint using feature. Associate this content type to a list.
After deploying the content type and associating with the list, if you click New you can see the ASPX page opening up....

Initiation form in ASPX done!!!
Next, Creation of task forms....

SharePoint Workflow in ASPX - Part 1

Everybody might be excited to see, how the workflow can be associated with custom ASPX forms rather than InfoPath forms. The reason for the change from InfoPath Form to ASPX form is clear that very limited edition(functionality).
Ok, What are all the advantages of using ASPX over InfoPath form?
1. Easy deployment
2. Custom logic insert
3. Feature enhancement
4. Bug fix
These are all very very easy compare to InfoPath forms. Apart from all the above, there is no need of Portal to show the workflow forms. WSS is enough.

Fine, What are all the things do we need to do to achieve this...
1. Initiation fom in ASPX
2. Task forms in ASPX
3. Reading workflow value from Workflow.
4. Sending value back to workflow...