none
Get Site URl in Sharepoint designer workflow

    Question

  • I have created one workflow in sharepoint designer. In that workflow i want to access my site's URL and i dont want to hardcode it. Is there any way to get the site's root url in the designer workflow?
    Monday, November 17, 2008 11:40 AM

Answers

  •  

    Hello,

     

               Yes you can. What you should do is as follows:

    1.       Create a custom list, and create a column (path1) with single line of text type, and create a test item.

    2.       Open the site in SPD, create a workflow to give the column value of “encoded absolute url” of current item to path1.

    3.       Run the workflow to get path1 updated with the value from that column.

    4.       Create a calculated column, use the formula:

    =left(path1,find(“Lists”,path1)-1)

     

    After that, you use this value in SPD workflow.

     

                  Hope it can help you,

                  Jerry


    Xing-Bing Yu
    Wednesday, November 19, 2008 10:12 AM
  • Hi Priyadit,

    Jerry's suggested solution seems to be a very nice workaround.

    I have another suggestion:
    I would create a custom SPD action, which has 2 properties:
    -- A property of type WorkflowContext and called __Context.
    -- An output property of type string called SiteUrl.

    The pseudo code of Execute method goes as follows:
    // Get the SPWeb that is associated with this workflow
    SPWeb myWeb = __Context.Web;

    // Set the output property
    this.SiteUrl = myWeb.Url;

    Try it and give me your feedback, if you need further help.

    Regards,
    Samar Hossam
    Thursday, November 20, 2008 10:32 AM

All replies

  •  

    Hello,

     

               Yes you can. What you should do is as follows:

    1.       Create a custom list, and create a column (path1) with single line of text type, and create a test item.

    2.       Open the site in SPD, create a workflow to give the column value of “encoded absolute url” of current item to path1.

    3.       Run the workflow to get path1 updated with the value from that column.

    4.       Create a calculated column, use the formula:

    =left(path1,find(“Lists”,path1)-1)

     

    After that, you use this value in SPD workflow.

     

                  Hope it can help you,

                  Jerry


    Xing-Bing Yu
    Wednesday, November 19, 2008 10:12 AM
  • Hi Priyadit,

    Jerry's suggested solution seems to be a very nice workaround.

    I have another suggestion:
    I would create a custom SPD action, which has 2 properties:
    -- A property of type WorkflowContext and called __Context.
    -- An output property of type string called SiteUrl.

    The pseudo code of Execute method goes as follows:
    // Get the SPWeb that is associated with this workflow
    SPWeb myWeb = __Context.Web;

    // Set the output property
    this.SiteUrl = myWeb.Url;

    Try it and give me your feedback, if you need further help.

    Regards,
    Samar Hossam
    Thursday, November 20, 2008 10:32 AM
  • Thanks for this - great way to make SharePoint Designer Workflows able to pick up a dynamic server name / server URL.

    Note - for others trying this, take care of the " quote marks when copying and pasting the above formula. Delete and retype them to get around the following error...

    "Error: The formula contains a syntax error or is not supported. "


    Ruth, UK
    Thursday, July 15, 2010 1:48 PM
  • I got one error.. with the above process of jerry

    i am left behind one list ,,, i mean

    suppose my site was 

    www.sharepoint.xyz.com/st/test/

    but while following the above approach it gave the path upto st & not test :(

    Sunday, September 16, 2012 11:39 AM