May I know how to create a button in a customized aspx file (designed by SharePoint Designer 2007) that when pressed, it trigger a workflow in a SharePoint form library?

Scenario: A web-based form (not InfoPath form but a aspx-customized form) that can trigger a workflow that is inside a SharePoint form library.

3 Answers 3


Here are a couple examples from sites where I have implemented this. Both options are based on hyperlinks (but could be adapted to buttons) This first example shows how to do it directly.

I have a DVWP with this markup:

<a href="https://my.spsite.com/sites/submit/_layouts/NintexWorkflow/StartWorkflow.aspx?List=4f988f8a-336e-4154-b045-d083fa0371a1&amp;ID={@ID}&amp;TemplateID=%7Beefc705f-b3ad-43fb-9fc8-615fb1226955%7D&amp;Source=https%3A%2F%2Fmy%2Espsite%2Ecom%2Fsites%2Fsubmit%2FPageLib%2FAdmin%2FDashboard%2Easpx">Copy Request</a>

It is calling a Nintex workflow in this case but it could be any workflow you've created. You can gather all the information by going to a list item and going into the manual initiation screen.

The other option I have a DVWP that has this code. On clicking the hyperlink, it executes some jQuery triggering my workflow. It uses Marc Anderson's SPServices library.

<xsl:attribute name="id">
                    <xsl:value-of select="@ID" disable-output-escaping="yes"/>
                <a href="#">
                    <xsl:attribute name="onclick">
                        <xsl:value-of select="$Host" />
                        <xsl:value-of select="@FileRef" disable-output-escaping="yes"/>
                        <xsl:value-of select="@ID" disable-output-escaping="yes"/>
                    </xsl:attribute>Copy Request</a>

Then I have a script that looks like this:

<script type="text/javascript">
function StartWorkflow(ItemURL, ItemID) {
var workflowGUID = null;
  operation: "GetTemplatesForItem",
  item: ItemURL,
  async: false,
  completefunc: function (xData, Status) {
    $(xData.responseXML).find("WorkflowTemplates > WorkflowTemplate").each(function(i,e) {
      // hard coded workflow name
      if ( $(this).attr("Name") == "Copy" ) {              
        var guid = $(this).find("WorkflowTemplateIdSet").attr("TemplateId");        
        if ( guid != null ) {
          workflowGUID = "{" + guid + "}";

var workflowTD = '#WorkflowTD' + ItemID;
    operation: "StartWorkflow",
    item: ItemURL,
    templateId: workflowGUID,
    workflowParameters: "<root />",
    completefunc: function() {
      $(workflowTD).html("Workflow Started");
  • [Q1] for your 2nd option, you mean that I just need to copy the first set of code to a data view web page and the second set of code to a normal aspx will do the trick? [Q2] I find that the SPService library is for SharePoint 2010, do correct me if I find it wrongly, is there for SharePoint 2007? [Q3] If the SPService library can be used for SharePoint 2007, do one still need to go to the SharePoint server to install / run it just like Visual Studio which need to be install togethrer with SharePoint 2007 Server? Sep 20, 2011 at 8:30
  • 1, the XSLT and the script work in conjunction with each other. THe XSLT renders the HTML that executes the javascript. 2. SPServices works for both 2007 and 2010. 3. SPServices and jQuery can be uploaded to a document library in the site collection they are going to be used. They don't have to be bundled into a feature and deployed like a VS solution. Sep 20, 2011 at 12:04

Try the accepted answer on this MSDN thread


  • [Q1] for the SPList inside the link you provided, does the code belong to Visual Studio C# coding, do correct me if I am wrong? Sep 20, 2011 at 8:32
  • @LarryMorries Yes it belongs to the code you write in Visual Studio C# coding
    – user2536
    Sep 20, 2011 at 9:19

I cannot get your code (below) to work. when link clicked I recieve error and the url then displays ...ID={@ID}, it takes url ID bit literally and not the value.

<a href="https://my.spsite.com/sites/submit/_layouts/NintexWorkflow/StartWorkflow.aspx?List=4f988f8a-336e-4154-b045-d083fa0371a1&amp;ID={@ID}&amp;TemplateID=%7Beefc705f-b3ad-43fb-9fc8-615fb1226955%7D&amp;Source=https%3A%2F%2Fmy%2Espsite%2Ecom%2Fsites%2Fsubmit%2FPageLib%2FAdmin%2FDashboard%2Easpx">Copy Request</a>

My code is below:

<a href="http://sp20104/HitsMissesApp/_layouts/IniWrkflIP.aspx?List={deff1c34-4aec-43ad-b1e8-00444d3ab674}&amp;ID={@ID}&amp;TemplateID={0db61b7a-1517-421b-86f6-ac2ee13c95cd}&amp;amp;Source=http%3A%2F%2Fsp20104%2FHitsMissesApp%2FLists%2FHitsandMisses%2FAllItems%2Easpx">clicke here</a>

I've tried several ways but it does not process, Is there a setting in SP that i've missed?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.