1
votes

I have created Sharepoint Approval 2010 workflow in visual studio.

How can I catch if user clicked approve or reject button?

private void createTaskWithContentType1_MethodInvoking(object sender, EventArgs e)
{

    createTaskWithContentType1_ContentTypeId1 = "0x01080100C9C9515DE4E24001905074F980F93160003A15057E2AF34B67B32E14B94EB70409";
    createTaskWithContentType1_TaskId1 = Guid.NewGuid();
    createTaskWithContentType1_TaskProperties1.AssignedTo = workflowProperties.Web.SiteAdministrators[0].LoginName;
    createTaskWithContentType1_TaskProperties1.DueDate = DateTime.Now.AddDays(1.0F);
    createTaskWithContentType1_TaskProperties1.Title = "Approval Required for xx";
    createTaskWithContentType1_TaskProperties1.Description = "Specify the approval result here.";

    SPList taskList = workflowProperties.TaskList;

}

private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
{
 //I think here i have to somehow do:  If button approve clicked .... else if reject button clicked
}
2

2 Answers

2
votes

I found solution

private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
        {
            string taskStatus = onTaskChanged1.AfterProperties.ExtendedProperties["TaskStatus"].ToString();

ExtendedProperties["TaskStatus"] will return Approved or Rejected

There are more properties in ExtendedProperties, but you need to go to debug mode to see them.

1
votes

Have you created your custom task form? or OOTB task form. If it is custom then you can set the values directly from your custom task form(on save button). If it is an OOTB then you have to edit the task form and add the javscript or JQuery to get the save button click.

It will prompt if you click on save button. sharepoint OOTB Task list form

function PreSaveItem(){
// add other your codes
if(value == 'confirm'){
  return true; // allow save form...
}

return false; // not allow save form
// use return true; if confirm or return false...
}

for more information please visit the below link https://sharepoint.stackexchange.com/questions/117147/how-to-trigger-the-click-event-of-the-sharepoint-ootb-lists-new-form-save-butto