To get value from specific field of an item, you need to know the guid of that field. Following is a way to get value from custom workflow task field.
Ex.
Guid testStatusFieldId = workflowProperties.TaskList.Fields["Test Status"].Id;
var status = (string)(Q0AfterProperty.ExtendedProperties[testStatusFieldId]);
if (status == "Q1")
{
_isQ1 = true;
}
else if (status == "Q4")
{
_isQ4 = true;
}
Tuesday, July 17, 2012
Monday, July 9, 2012
Delete all related tasks when workflow complete in sharepoint
When your workflow finished or terminated, you might see some tasks still remain in the task list. Do you want to get rid of them?
Following code help you to remove all tasks remain after workflow complete.
using (var spweb = workflowProperties.Web)
{
spweb.AllowUnsafeUpdates = true;
var list = workflowProperties.Item.Tasks.Count;
while (list>0)
{
workflowProperties.Item.Tasks[0].Delete();
list = workflowProperties.Item.Tasks.Count;
}
spweb.AllowUnsafeUpdates = false;
}
Following code help you to remove all tasks remain after workflow complete.
using (var spweb = workflowProperties.Web)
{
spweb.AllowUnsafeUpdates = true;
var list = workflowProperties.Item.Tasks.Count;
while (list>0)
{
workflowProperties.Item.Tasks[0].Delete();
list = workflowProperties.Item.Tasks.Count;
}
spweb.AllowUnsafeUpdates = false;
}
Tuesday, June 26, 2012
Delete items from sharepoint list
In some case, you may want to delete item in sharepoint list.
It is easy job.
Ex. You have a list named "Sample List"
Ex. You have a list named "Sample List"
using (SPSite siteCollection = new SPSite("http://server")) { using (SPWeb site = siteCollection.OpenWeb()) { SPList list = site.Lists["Sample List"]; foreach (SPListItem item in list.Items) { item.Delete(); } } }
Weird dialog box in membership change password control
You may experience with a weird dialog box which ask you to select a user if you want to change password. This happen with mostly Firefox browser (It can be happened with other browser).
The problem is that you use remember password in the Firefox browser. I think it is the bug from Firefox itself. Nothing to do with Asp.net member ship.
To fix this problem, you go to
1- Tool
2- Option
3-
4-
The problem is that you use remember password in the Firefox browser. I think it is the bug from Firefox itself. Nothing to do with Asp.net member ship.
To fix this problem, you go to
1- Tool
2- Option
3-
Security4-
Remove All
Read item from sharepoint list
In some case, you may want to get all list item in sharepoint list. It is easy to get all those list. below are code for reading list item from sharepoint list.
Ex. You have a list named "Sample List"
Ex. You have a list named "Sample List"
using (SPSite siteCollection = new SPSite("http://server")) { using (SPWeb site = siteCollection.OpenWeb()) { SPList list = site.Lists["Sample List"]; foreach (SPListItem item in list.Items) { //do what you want to do with it. } } }
Fix error when create task in loop
If you create task in loop, you will got the message "Error occurred".
The problem is that you don't understand the correlation of the task.
The following is how to fix it.
The problem is that you don't understand the correlation of the task.
The following is how to fix it.
Subscribe to:
Posts (Atom)



