none
Document Library Read Only or Edit prompt in custom link

    Question

  • Hey all,

    Using a PowerShell script, we were able to add the standard SharePoint document library context menu to a new URL column which is great. But at the moment clicking the document link sends the user to the View Properties page for the document.  We would like to have the user be prompted with the "Read Only or Edit" prompt when clicking the HREF of the document.

    Is there a JavaScript method that brings up the read only/edit dialog? If so we can modify the PowerShell script that adds the context menu to our new column.

    Any other ideas?

    Thanks,
    Jay
    Thursday, March 05, 2009 3:34 PM

Answers

  • Hi Jay,

     

    Yes, the JavaScript function DispEx located in %\ProgramFiles%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\[Lcid]\Core.js (1033 for English) brings up the read only/edit dialog.

     

    And it is suggested to use Internet Explorer Developer Toolbar to located the JavaScript functions. You can download at http://www.microsoft.com/downloads/details.aspx?FamilyId=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en

     

    Here is the code snippet for your reference:

    <TABLE id="1" class="ms-unselectedtitle" cellSpacing="0" height="100%" SUrl="" UIS="1" CId="0x0101009AA19952EF981946906F209857790EBF" CType="Document" MS="3" CSrc="" HCD="" COut="0" SRed="" COUId="" OType="0" Icon="icdotx.gif|Microsoft Office Word|SharePoint.OpenDocuments" Ext="dotx" Type="" Perm="0x7fffffffffffffff" DRef="<url>" Url="<url>" CTXName="ctx1" _onmouseout="null" _onmousedown="null">

    <TBODY>

    <TR>

    <TD class="ms-vb" width="100%">

    <A onfocus="OnLink(this)" onclick="return DispEx(this,event,'TRUE','FALSE','FALSE','SharePoint.OpenDocuments.2','0','SharePoint.OpenDocuments','','','','1','1','0','0x7fffffffffffffff')" href="<url>"><document name><IMG class="ms-hidden" border="0" alt="Use SHIFT+ENTER to open the menu (new window)." src="http://<url>/_layouts/images/blank.gif" width="1" height="1" /></A><IMG alt="New" src="http://<url>/_layouts/1033/images/new.gif" />

    </TD>

    <TD>

    <IMG style="VISIBILITY: hidden" alt="Edit" src=http://<url>/_layouts/images/menudark.gif width="13" />

    </TD>

    </TR>

    </TBODY>

    </TABLE>

     

    Hope the information can be helpful.

    -lambert


    Lambert Qin | Microsoft Online Support Engineer
    How to ask a question in the forum (http://support.microsoft.com/kb/555375)
    Posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, March 09, 2009 5:13 AM

All replies

  • Hi Jay,

     

    Yes, the JavaScript function DispEx located in %\ProgramFiles%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\[Lcid]\Core.js (1033 for English) brings up the read only/edit dialog.

     

    And it is suggested to use Internet Explorer Developer Toolbar to located the JavaScript functions. You can download at http://www.microsoft.com/downloads/details.aspx?FamilyId=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en

     

    Here is the code snippet for your reference:

    <TABLE id="1" class="ms-unselectedtitle" cellSpacing="0" height="100%" SUrl="" UIS="1" CId="0x0101009AA19952EF981946906F209857790EBF" CType="Document" MS="3" CSrc="" HCD="" COut="0" SRed="" COUId="" OType="0" Icon="icdotx.gif|Microsoft Office Word|SharePoint.OpenDocuments" Ext="dotx" Type="" Perm="0x7fffffffffffffff" DRef="<url>" Url="<url>" CTXName="ctx1" _onmouseout="null" _onmousedown="null">

    <TBODY>

    <TR>

    <TD class="ms-vb" width="100%">

    <A onfocus="OnLink(this)" onclick="return DispEx(this,event,'TRUE','FALSE','FALSE','SharePoint.OpenDocuments.2','0','SharePoint.OpenDocuments','','','','1','1','0','0x7fffffffffffffff')" href="<url>"><document name><IMG class="ms-hidden" border="0" alt="Use SHIFT+ENTER to open the menu (new window)." src="http://<url>/_layouts/images/blank.gif" width="1" height="1" /></A><IMG alt="New" src="http://<url>/_layouts/1033/images/new.gif" />

    </TD>

    <TD>

    <IMG style="VISIBILITY: hidden" alt="Edit" src=http://<url>/_layouts/images/menudark.gif width="13" />

    </TD>

    </TR>

    </TBODY>

    </TABLE>

     

    Hope the information can be helpful.

    -lambert


    Lambert Qin | Microsoft Online Support Engineer
    How to ask a question in the forum (http://support.microsoft.com/kb/555375)
    Posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, March 09, 2009 5:13 AM
  • Hi Lambert,

    doing this i have another Problem:

    I need to create the onclick and onfocus events dynamically. If i do that the DispEx Method doesnt work for me.

    var a = document.createElement("a");
    a.onclick = new Function("return DispEx(this,event,'TRUE','FALSE','FALSE','SharePoint.OpenDocuments.2','0','SharePoint.OpenDocuments','','','','1','1','0','0x7fffffffffffffff')");
    
    a.href = "../../Freigegebene%20Dokumente/"+item.getAttribute('ows_LinkFilename');
    
    
    

    I also tried editDocumentWithProgID2, but then i got an error.

    I would be very happy if you got any ideas about that.

    Thanks
    Monday, August 17, 2009 3:52 PM