We have an insurance customer, who required a contracr repository. WSS 3.0 fits on their base requirements, but they had some special needs as well: First of all, at the end of contracts' lifecycle, after signing them, we have to save several attachments, for example scanned copies or some appendixes. In one word, every contracts contain a main document and some attached documents, so we need document libraries with ability to attach files to documents. The second special need is a custom field, which manages the contract elements' permissions.
Document library with ability to attach files
In WSS 3.0 we don't have any out-of-the-box feature to manage attachments in document libraries, so we have a little trick. Our steps were the followings:
- Create the base document library, which stores the contracts.
- Create a secondary document library, which will store the attachments. This library have to contain a lookup column to the base document library - we store here a reference to the bace contract for every attachment.
- Insert special commands to base library's element menu with a little javascript added to a Content Editor webpart on AllItems.aspx: one for Add new attachment, and the other one for View attachments:
<script language="javascript">
// Add a custom menu items into the menu
function Custom_AddDocLibMenuItems(m, ctx)
{
var strDisplayText = "Add new Attachment";
var strAction = "window.open('http://myserver/insurance/Attachments/Forms/Upload.aspx?&RelatedDocumentID="+currentItemID+"');";
var strImagePath = "/_layouts/images/attach.gif";
// Add our new menu item
CAMOpt(m, strDisplayText, strAction, strImagePath);
var strDisplayText2 = "View Attachments";
var strAction2 = "window.open('http://myserver/insurance/Attachments/Forms/AttachmentForContract.aspx?&ID="+currentItemID+"');";
var strImagePath2 = "/_layouts/images/attach.gif";
// Add our new menu item
CAMOpt(m, strDisplayText2, strAction2, strImagePath2);
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
- In the attachment library we have a lookup column to the base document library, so we have to set a default value to the base contract. This contract's ID is passed by ID parametet.
- That's all :) The AttachmentForContract.aspx is a custom list of contracts filtered by ID parameter. If the user click to View attachments menu, he/she will be redirected to this page, and he/she can see the attachments for base contract passed by ID parameter.
In the next part, I'll show you how you can develop a custom field, which is responsible for rights management on a list item or a document.
Posted
May 27 2008, 09:16 PM
by
aghy