How To: Create a Report Template Using Embedded Pictures

Version 7

    Verified Product Versions

    Service Desk 7.6Service Desk 7.7.xService Desk 7.8.xService Desk 2016.xAsset Manager 2016.x

    Environment:

    Service Desk 7.4 and above

     

    Requires Access To:

    Service Desk Console (to design)

    Web Access (to be applied)

     

    How to:

    In this article, we are going to review step by step how to set up a report templates with images embedded in an attachment attribute. We are going to apply this on a specific scenario:

    We want to apply a report template on the incident object where a boolean attribute will define whether a picture showing "Yes" or "No" is displayed in a query.

     

    Step by Step:

     

    All the steps below are illustrated in this video: How to use embedded images in report templates.mp4

     

    Object Structure
    • Go to the Object Designer
    • On the Incident Object, create a boolean attribute. Let's call it "Boolean test" for this example;
    • Create in the Incident Management Module a reference list called Images Object. This object will contain a name and the file (picture)

     

    You will want to set the "Deletion Type" property on "Soft Deletion" to avoid any constraint issue later on where you'll delete an exiting record of this object

     

    • Therefore create two attributes in this object:
      • A string attribute with the property "IsName?" set on true. Let's call it "Image Name"
      • An attachment attribute with the Attachment Type set on "Image". Let's call it "Image File"

    1) Attachment attribute.png

    • Save : This will create automatically two new attributes "Deleted" and "Guid" as on the above screenshot (if the deletion type is set on "Soft").
    • Link this object on Incident and click on "No" when you are asked to create a collection. Now, Incident should have a unique link to the object "Images Object"

    2) Incident link to Images.png

     

     

    Creation of our "Images Object" records

    • Go to the Window Manager
    • Create a window for our new reference list "Images Object" so that we can see the attributes "Image Name" and "Image File" on the window

    Trick: you can also use the "New Window Wizard" from the Object Designer to quickly create a new window for this object: highlight the object and select "New Window Wizard" from the top-left action panel

    3) New Window Wizard.png

    • Go to the administration component
    • On the bottom select the "Reference Lists" section end browse in the hierarchy tree to find your "Images Object" in the Incident Management module
    • Create two new records: For each of them specify a title and a picture

    4) Creation of records.png

     

    Calculate which picture to display on the report

    In order to know which record of the "Images Object" related attribute of Incident will be called, depending on the value of the "Boolean Test" attribute, we must create a calculation on the Incident related attribute "Images Object".

    • Go back to the Object Designer > Incident Object > "Images Object" attribute
    • Highlight this attribute and in the properties set the calculation type to the one which is suitable enough for you. Let's use "Before Save" in this example
    • Use the template of the following calculation:
    import System static def GetAttributeValue(Incident):   if Incident._BooleanTest == false:   Value = Incident.GetObjectByAttribute("IncidentManagement._ImagesObject", "_ImageName","No")   else:   Value = Incident.GetObjectByAttribute("IncidentManagement._ImagesObject", "_ImageName","Yes")   return Value               

     

     

    The above calculation must obviously be adapted to your own environment depending on which object you want to apply the report template on (here, Incident), the name and the module of your image object (here "IncidentManagement._ImagesObject") and the attribute names (here "_ImageName").

    The above calculation uses the GetObjectByAttribute(" ", " ",) function. To understand how to use it properly, you are kindly invited to have a look on the following Community article: Calculation Writing Tutorial - 8. Working with Dropdown Lists (Objects)

    The above calculation uses the GetObjectByAttribute(" ", " ",) function. If you have issues with this function, this is probably because you didn't specify the right name of neither the Module, the Object or the Attribute. To be sure of the syntax, please refer to the following article: How To: Write correctly arguments of Framework Object Calculation Functions

     

    • Save: we are almost at the end !

     

    Apply the report template

    • In the Object Designer, highlight the Incident object
    • In the properties, go to the section Templates > Reports
    • Create a new template or select your existing template
    • To call the image, you'll just need to call the attachment attribute via a placeholder, and place it in a <imd src=''> HTML tag. In this example, {_ImagesObject/_ImageFile}

    5) Report Template window.png

    • Click OK when your template is ready and Save
    • Log on Web Access and create a query to display all the incidents
    • On the top right of the query, click on the drop-down arrow and select "View as a report"
    • Select your report template within the first drop-down list and click OK

     

    To go further:

    If you understood how to create such a template with images embedded in attachment attributes, you won't have any difficulty for example to apply it for SLA KPIs' for instance.

     

    Related articles:

    Image placeholders in Report Templates are no longer displayed.

    How to modify the image representing the status on a report template

    Calculation Writing Tutorial - 8. Working with Dropdown Lists (Objects)