locked
ecb redirect to editform with document url passed to the form RRS feed

  • Question

  • Hey guys,

    I wanted to redirect the user from a document library to a editform.aspx so they can enter more information about the document in the document library. I've currently had it so when they click on an item in ECB (edit control block, the drop down you get from clicking on the document title) they would be directed to the list and, after entering information, would be redirected back to document library via ?source=... Now I want to pass on the url of the specific document (the one that they click the redirect item in the ECB on) in the document library and put it into a field in the editform in the list so they can reference the document by clicking on the url column in the list. How could I achieve that? 

    Here's what I have so far:

     

    <script language="javascript">

    function Custom_AddDocLibMenuItems(m, ctx)

    {

    var strDisplayText = "Redirect to form here";

    var strImagePath = "";

    var strAction = 'window.navigate("/.../editform.aspx?Source=" + document.URL.substring(0, document.URL.indexOf("/Forms", 0)) + "?RootFolder=" + GetUrlKeyValue("RootFolder")) + "DocUrl=" + GetDocURL(ctx)'; 

      // Add our new menu item

      CAMOpt(m, strDisplayText, strAction, strImagePath);

      // add a separator to the menu

      CAMSep(m);

      // false means that the standard menu items should also be rendered

      return false;

    }

    function string GetDocURL(ctx)

    {

    var URL = "";

    var index = itemTable.innerHTML.indexOf("href=");

    if (index > 0)

    {

      var str = itemTable.innerHTML.substr(index + 6);

      index = str.indexOf('"');

      if (index > 0)

      {

        URL = str.substr(0, index);

      }

    }

    return URL;

    }

    </script>

    Sunday, August 7, 2011 12:19 AM

Answers

  • Hi chanpb,

    If I understand correctly, you are asking how to get the value of the parameter DocUrl from the EditForm page, and then add the value to a field(a textbox in the EditForm).

    In order to get the DocUrL parameter(a URL query parameter), we can use JavaScript to split the URL parameter, and then get the DocUrl. In order to assign the value to a textbox, we can use JavaScript too. So, please add a Content Edit Web Part to the EditForm, and then use JavaScript to get the value and assign it.

    For more information, please see:
    http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html

    Thanks,
    Jinchun Chen


    Jinchun Chen
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff AT microsoft.com(Please replace AT with @)
    • Marked as answer by Wayne Fan Sunday, August 14, 2011 6:08 AM
    Friday, August 12, 2011 9:30 AM
    Moderator