Guest User

Untitled

a guest
Jul 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. var contentItem = args.DataItem;
  2. var contentDatabase = contentItem.Database;
  3. var contentWorkflow = contentDatabase.WorkflowProvider.GetWorkflow(contentItem);
  4. var contentHistory = contentWorkflow.GetHistory(contentItem);
  5.  
  6. //Get the workflow history so that we can email the last person in that chain.
  7. if (contentHistory.Length > 0)
  8. {
  9. //contentWorkflow.GetCommands
  10. var status = contentWorkflow.GetState(contentHistory[contentHistory.Length - 1].NewState);
  11.  
  12. //submitting user (string)
  13. string lastUser = contentHistory[contentHistory.Length - 1].User;
  14.  
  15. //approve/reject comments
  16. var message = contentHistory[contentHistory.Length - 1].Text;
  17.  
  18. //sitecore user (so we can get email address)
  19. var submittingUser = sc.Security.Accounts.User.FromName(lastUser, false);
  20. }
  21.  
  22. public void Process(WorkflowPipelineArgs args)
  23. {
  24. //all variables get initialized
  25. string contentPath = args.DataItem.Paths.ContentPath;
  26. var contentItem = args.DataItem;
  27. var contentWorkflow = contentItem.Database.WorkflowProvider.GetWorkflow(contentItem);
  28. var contentHistory = contentWorkflow.GetHistory(contentItem);
  29. var status = "Approved";
  30. var subject = "Item approved in workflow: ";
  31. var message = "The above item was approved in workflow.";
  32. var comments = args.Comments;
  33.  
  34. //Get the workflow history so that we can email the last person in that chain.
  35. if (contentHistory.Length > 0)
  36. {
  37. //submitting user (string)
  38. string lastUser = contentHistory[contentHistory.Length - 1].User;
  39. var submittingUser = Sitecore.Security.Accounts.User.FromName(lastUser, false);
  40.  
  41. //send email however you like (we use postmark, for example)
  42. //submittingUser.Profile.Email
  43. }
  44. }
Add Comment
Please, Sign In to add comment