kamagra how much to take

Returning The SharePoint Start Workflow Link

Building the “Start Workflow” link is pretty straight forward. I am pretty sure there are better ways to do it, but here is an approach when you have to build the link using a string return. How it works is pretty straightforward. Consuming a SPListItem and SPWorkflowAssociation parameter, the SPListItem exposes the ParentList and ID properties and the SPWorkflowAssociation provides the InstantiationUrl and Id properties. The only field level stuff is I was passing a finish url in the query string (_finalurl in the below). When the link is built, it is cleaned up using the inherent SPHttpUtility.UrlKeyValueEncode method.

  1. private string _finalurl;
  2.  
  3. public static string QueryStringAppend(string url, string args)
  4. {
  5. if (string.IsNullOrEmpty(url))
  6. {
  7. return url;
  8. }
  9. var num = url.LastIndexOf("?");
  10. switch (num)
  11. {
  12. case -1:
  13. return (string.Format("{0}?{1}", url, args));
  14. }
  15. return num == (url.Length - 1) ? url + args : string.Format("{0}&{1}", url, args);
  16. }
  17.  
  18. protected string BuildWorkflowStartLink(SPListItem listItem, SPWorkflowAssociation workflowAssociation)
  19. {
  20. var builder = new StringBuilder();
  21. builder.Append(SPHttpUtility.UrlPathEncode(string.Format("{0}/{1}", Web.Url, workflowAssociation.InstantiationUrl), true));
  22. builder.Append("?List=");
  23. builder.Append(listItem.ParentList.ID.ToString());
  24. builder.Append("&ID=");
  25. builder.Append(listItem.ID.ToString());
  26. builder.Append("&TemplateID=");
  27. builder.Append(workflowAssociation.Id.ToString("B"));
  28. string url = _finalurl ?? Request.QueryString["Source"];
  29. url = QueryStringAppend(url, string.Format("{0}={1}", FinishIdName ?? "ID", listItem.ID));
  30. if (!string.IsNullOrEmpty(url))
  31. {
  32. builder.Append("&Source=");
  33. builder.Append(SPHttpUtility.UrlKeyValueEncode(url));
  34. }
  35. return builder.ToString();
  36. }

:)

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>