Docstoc

Sales Invoice Template - Get as PDF

Document Sample
Sales Invoice Template - Get as PDF Powered By Docstoc
					SharePoint reports and documents
generator ver.: 1.1
User Guide




Version 1.1
      Contents

1.     Overview .................................................................................................................................................... 3
2.     Licensing ..................................................................................................................................................... 4
3.     Installation instructions .............................................................................................................................. 4
     3.1.     Requirements ..................................................................................................................................... 4
     3.2.     Installation.......................................................................................................................................... 4
     3.3.     Creating custom actions to call generator ......................................................................................... 4
4.     Preparing templates for generator ............................................................................................................ 8
5.     Template schema reference .................................................................................................................... 14
     5.1.     Field tag ............................................................................................................................................ 14
     5.2.     Repeat tag ........................................................................................................................................ 14
6.     Tutorial ..................................................................................................................................................... 15




www.sharepointdrive.com                              SharePoint reports and documents generator v.1.1                                                 2|Page
1. Overview

SharePoint reports and documents generator is a solution for Windows SharePoint Services 3.0 and
SharePoint Server 2007 users who wants to generate reports and documents using data stored in
SharePoint lists.

SharePoint reports and documents generator uses Microsoft Office Word 2007 custom XML based
templates. By using custom XML schema it is possible to preserve data and rich Word 2007 formatting
capabilities at the same time.

One of the main features of SharePoint reports and documents generator is capability to generate reports
or documents from lists that are related to each other by SharePoint lookup columns. So for example if you
have Order and Order details list related by lookup column you can prepare template like this:




www.sharepointdrive.com           SharePoint reports and documents generator v.1.1             3|Page
And SharePoint reports and documents generator will generate sales order like this:




2. Licensing

You will find novitas_eula.docx file in downloaded zip file. Also you must accept this EULA when installing
SharePoint reports and documents generator. By this EULA you are granted non-transferable and non-
exclusive right to use and execute the SharePoint reports and documents generator on a single computer,
without right to sublicense it. Under no circumstance may you store, use or allow the use of the
SharePoint reports and documents generator in any manner on more than one computer at a time.


3. Installation instructions


3.1. Requirements

Server      SharePoint reports and documents generator can be installed on Windows Server 2003 or
            Windows Server 2008 where SharePoint Services 3.0 or SharePoint Server 2007 is installed.
Client      Microsoft Office Word 2007

3.2. Installation

Run downloaded executable file and follow onscreen instructions.

3.3. Creating custom actions to call generator

There are many ways of how to create custom actions in SharePoint Services 3.0 or SharePoint Server 2007.
You can find more information in SharePoint Services 3.0 SDK or SharePoint Server 2007 SDK. In this guide



www.sharepointdrive.com           SharePoint reports and documents generator v.1.1              4|Page
you will see how you can quickly add custom actions to item’s Edit Control Block (ECB) menu without the
need to access the SharePoint server.




Open the list page for editing (for example AllItems.aspx) where you want to add custom action:




www.sharepointdrive.com           SharePoint reports and documents generator v.1.1                5|Page
Add a Content Editor Web Part to the page:




Modify the Content Editor Web Part:




Open Source Editor:




www.sharepointdrive.com          SharePoint reports and documents generator v.1.1   6|Page
And copy - paste the following code to it:

<script type="text/javascript" language="javascript">
function Custom_AddListMenuItems(m, ctx)
{
   var url = ctx.HttpRoot +
       "/_layouts/generate.aspx?docLib=Sales documents&conType=Sales
invoice&docName=Sales invoice&returnFile=Yes&suffix=Invoice
number&listName="+ctx.listName+"&itemID="+currentItemID;
   var js = "STSNavigate('" + url + "')";
   CAMOpt(m, "Print Sales Invoice", js, "");
   CAMSep(m);
   return false;
}
</script>



Main area where you need to concentrate is custom action’s link:

"/_layouts/generate.aspx?docLib=Sales documents&conType=Sales invoice&docName=Sales
invoice&returnFile=Yes&suffix=Invoice
number&listName="+ctx.listName+"&itemID="+currentItemID

You MUST pass all the following parameters to the SharePoint reports and documents generator:

conType                                          SharePoint reports and documents generator is using
                                                 document content type templates. You need to set this
                                                 parameter to the name of document content type you
                                                 wish to generate.

docLib                                           Document library where document content type set by
                                                 conType parameter is defined.



www.sharepointdrive.com            SharePoint reports and documents generator v.1.1         7|Page
docName                                          The name of the generated document.

suffix                                           You can add a suffix to the name of the generated
                                                 document. It must be the name of one of the current
                                                 item columns. For example you may want to add Order
                                                 Number to the generated document name.

returnFile                                       You can return generated document directly to the
                                                 browser and open it with Word 2007 or save it to the
                                                 SharePoint document library. Document library set by
                                                 docLib parameter is used to save generated document.

listName and itemID                              SharePoint reports and documents generator must be
                                                 called from a list item context. It means that you need to
                                                 pass list and item ID to the generator. You can always
                                                 pass those parameters by adding following string to the
                                                 custom actions link:
                                                 listName="+ctx.listName+"&itemID="+currentItemID




So in example above you are telling to the generator: generate document using content type’s Sales Invoice
template stored in Sales document library. Use Sales invoice name for the generated document by adding
Invoice number suffix to it. And please return generated document directly to the browser.

Alternatively you can use Windows SharePoint Services 3.0 SDK to figure out how to add custom actions
using SharePoint features or you can ask to do it your SharePoint system administrator. You can use exactly
the same custom action link as in example above:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 <CustomAction Id="UserInterfaceCustomActions1.DisplayFormToolbar"
 RegistrationType="ContentType" RegistrationId="0x01005728C2E9132CA4469E63D58F478E115A"
 Location="DisplayFormToolbar" Sequence="106" Title="Print Order">
 <UrlAction Url="~site/_layouts/generate.aspx?docLib=Sales documents&conType=Sales
 invoice&docName=Sales invoice&returnFile=Yes&suffix=Invoice
 number&listName={ListId}&itemID={ItemId}" />
 </CustomAction>
 <CustomAction Id="UserInterfaceCustomActions2.DisplayFormToolbar"
 RegistrationType="ContentType" RegistrationId="0x01005728C2E9132CA4469E63D58F478E115A"
 Location="DisplayFormToolbar" Sequence="107" Title="Print Invoice">
 <UrlAction Url="~site/_layouts/generate.aspx?docLib=Sales documents&conType=Service
 invoice&docName=Service invoice&returnFile=No&suffix=Invoice
 number&listName={ListId}&itemID={ItemId}" />
 </CustomAction>
</Elements>



4. Preparing templates for generator

In order to prepare templates for SharePoint reports and documents generator you don‘t need
SharePoint. All you need is to use custom XML schema that is provided with SharePoint reports and
documents generator.



www.sharepointdrive.com           SharePoint reports and documents generator v.1.1                  8|Page
First you need to attach custom XML schema to Word 2007 document (it don‘t need to be a new
document, you can use documents that you already have):

To work with Custom XML you need to enable Developer tab in Word 2007. Open Word Options dialog:




Select Show Developer tab in the Ribbon:




Click OK.

To attach custom schema open Developer tab in the Ribbon and click Schema:




www.sharepointdrive.com          SharePoint reports and documents generator v.1.1        9|Page
In Templates and Add-ins dialog select Add Schema:




Browse and select generator.xsd schema file which you will find in downloaded SharePoint reports and
documents generator zip file (you need to extract the files first):




www.sharepointdrive.com          SharePoint reports and documents generator v.1.1           10 | P a g e
Enter „SharePoint reports and documents generator” in Alias field and Click OK:




Make sure that SharePoint reports and documents generator schema is selected and click OK:




www.sharepointdrive.com           SharePoint reports and documents generator v.1.1           11 | P a g e
Now you must see XML Structure task pane right to the document:




After you attached custom schema to the document you can start creating your template.



www.sharepointdrive.com          SharePoint reports and documents generator v.1.1        12 | P a g e
At the moment there are 2 possible custom XML tags that you can insert in to template: Field and Repeat.

Field

Field tag is used when you want to insert single column value. If column is a lookup column than you can
insert one column value from item to which the lookup column is related.




Repeat

Repeat tag is used when you want to insert all items from related/child list. Child list must have a lookup
column to the parent list (the list from which generator was called). After you insert Repeat tag you must
insert one Field tag inside Repeat tag for each child‘s list column you want to appear in generated report or
document.




For more details how to use tags see the

Note: to avoid creating tables from big lists – tables will not be created if you set ignoreParent to true and
will not give view‘s name. If you really need tables containing all list items, you must provide a view
containing all items (e.g. „All Items“).

Tutorial and Template schema reference.

After you created template you need to save it as one of your document content type‘s template:




www.sharepointdrive.com             SharePoint reports and documents generator v.1.1               13 | P a g e
5. Template schema reference

    5.1.Field tag

Field tag is used to insert column value of current context item. All tags that are out of Repeat tag bounds
have current item context (item on which custom action was called). All tags that are inside Repeat tag
have context of related list set by Repeat tag list attribute.

Attributes

name (required)        Column name of the current context list item.
lookupListField        If column name set with name attribute is a lookup column you can set this
                       attribute to the column name (which value you want to appear in report) of
                       related list. Also if column name set with name attribute is Person type you can
                       set lookupListField to the one of users profile attributes.


    5.2.Repeat tag

Repeat tag is used to define display items from some list. The items from the list can be taken in two ways
(or combination of them):

    a) Items can be taken from the list related to the current context item (context item should be set and
       ignoreParent attribute not set or set to false). e.g. order items that belong to the context of the
       current order.
    b) Items can be taken from the lists view. View attribute must be set to any of the list view names
       (context item should not be set or ignoreParent attribute should be set to true). E.g. a list of tasks
       finished this week.
    c) Items related to the current context item and contained in some view (context items and view
       attribute should be set). E.g. current order items currently in stock.

www.sharepointdrive.com            SharePoint reports and documents generator v.1.1             14 | P a g e
Attributes

list(required)          The name of the list to take items from. SharePoint reports and documents
                        generator automatically will find a lookup field in related list by which the lists
                        are related.
view                    This attribute can be set to view name. If view name is set, then only items from
                        this view is taken.
ignoreParent            If this attribute is set to true, then current context item is ignored and table is
                        created form the list items from the view


Note: to avoid creating tables from big lists – tables will not be created if you set ignoreParent to true and
will not give view‘s name. If you really need tables containing all list items, you must provide a view
containing all items (e.g. „All Items“).


6. Tutorial

In this tutorial we will use OOTB document library, a couple Contact lists and one Custom list to prepare
template to the SharePoint reports and documents generator and later will add custom action to call
document generator that will be using this prepared template:

    1.   Create a standard document library named Reports.
    2.   Create a standard Contacts list named Accounts.
    3.   Create a standard Contacts list named Contacts.
    4.   Create a custom list Banks (with a single Title column).




    5.   Create a lookup column in Contacts list named Account and point it to Accounts list.
    6.   Create a lookup column in Accounts list named Bank and point it to Banks list.
    7.   Enter a couple of related items in Contacts, Account and Banks lists.
    8.   Enable content types in the Reports document library:




www.sharepointdrive.com             SharePoint reports and documents generator v.1.1               15 | P a g e
   9. In the Reports document library select Document content type and in Advanced setting click Edit
      template:




   10. Attach Custom XML schema as explained in Preparing templates for generator.
   11. Create template like this:




   12. Insert a tag for Account company field. Place a cursor after a colon and click Field tag in the XML
       Structure task pane:




www.sharepointdrive.com          SharePoint reports and documents generator v.1.1            16 | P a g e
       In the “Apply to entire document?” dialog select Apply to selection only (this is one time message
       only):




   13. Right click on inserted tag and select Attributes:




   14. Select Name attribute. Enter “Company” in the Value field and click Add. Click OK.




www.sharepointdrive.com           SharePoint reports and documents generator v.1.1          17 | P a g e
       This tells to the SharePoint reports and documents generator to insert a Company column value
       for the current Account item.
   15. Using same technique insert E-Mail and Created By column values:




www.sharepointdrive.com        SharePoint reports and documents generator v.1.1         18 | P a g e
www.sharepointdrive.com   SharePoint reports and documents generator v.1.1   19 | P a g e
   16. Insert tag for Bank field. But this time we need to lookup value in Banks list item that is related to
       the current Account. To do this we need to set Name attribute to the “Bank” value and
       lookupListField to the ” Title” value (related list’s column name that we want to appear in report):




   17. Insert tag for Job Title field. We need a Job Title column value from user’s who created Account
       profile properties:




       To tell that to the generator we need additionally set lookupListField to Job Title:



www.sharepointdrive.com           SharePoint reports and documents generator v.1.1              20 | P a g e
   18. Next step is to prepare a contacts table for the Account. Double click on the first table cell so that
       entire row gets selected:




   19. While row is selected click Repeat tag in the XML Structure task pane:




   20. Right click inserted Repeat tag and select Attributes.
   21. Set the current Repeat tag context to Contacts list by setting List attribute to “Contacts” value:




www.sharepointdrive.com           SharePoint reports and documents generator v.1.1               21 | P a g e
   22. Insert one Field tag for each rows cell in a table and set name attributes to the corresponding
       column names: Last Name, First Name, Business Phone, Home Phone, E-Mail Address. At the end
       you will get picture like this:




   23. The template is ready. Save it.
   24. Now we will need a custom action in the Accounts item’s context menu:




www.sharepointdrive.com         SharePoint reports and documents generator v.1.1          22 | P a g e
   25. To insert custom action use steps explained in Creating custom actions to call generator an use the
       following JavaScript:


      <script type="text/javascript" language="javascript">
        function Custom_AddListMenuItems(m, ctx)
        {
        var url = ctx.HttpRoot +
        "/_layouts/generate.aspx?docLib=Reports&conType=Document&docName=Account
      report&returnFile=Yes&suffix=Company&listName="+ctx.listName+"&itemID="+currentIte
      mID;
        var js = "STSNavigate('" + url + "')";
        CAMOpt(m, "Print Account Contacts", js, "");
        CAMSep(m);
        return false;
        }
      </script>


   26. Call generator by selecting just created custom action and see the results:




www.sharepointdrive.com           SharePoint reports and documents generator v.1.1            23 | P a g e

				
DOCUMENT INFO
Description: Sales Invoice Template document sample