Skip to Content
Author's profile photo John Paul

Custom PDF summary for C4C Ticket & Sub Tickets

Any coding or configuration examples provided in this document are only examples and are NOT intended for use in a productive system. The example is only done to better explain and visualize the topic.

The objective of this blog is to explain how can we create Custom PDF summary for Tickets & It’s Sub Tickets with extension fields.

Below is the detailed scope of this Blog: –

  • Create a Custom BO to retrieve Tickets & It’s Sub Tickets.
  • Create PDF Form for this custom BO
  • Include the PDF generation option to standard Ticket UI.

Implementation Details: –

  1. Create a solution in PDI.
  2. Add extension Fields to Ticket UI through PDI (C4C SDK).
  3. Create Custom BO.
  4. Populate data for the new Custom BO.
  5. Create Print Form.
  6. Create a Embedded Component for Custom BO.
  7. Include “Preview Summary” Button to newly added EC for generating PDF.

Below will be our targeted Sub ticket facet in Ticket TI with “Preview Summary” button to generate PDF summary.

1. Create a solution in PDI

Provide required information for the creation of Solution.

2. Add extension Fields to Ticket UI through PDI (C4C SDK).

We will add an extension field called “Ext_SpecialNote” to Ticket Header, using PDI logic.

import AP.Common.GDT;
import AP.CRM.Global;

[Extension] businessobject AP.CRM.Global:ServiceRequest {
     [Label ("Special Note")] element Ext_SpecialNote:LANGUAGEINDEPENDENT_EXTENDED_Text;
   		node Item {
   		node ServiceReferenceObject {

Add this Extension field to the targeted Ticket TI – /BYD_COD/ServiceOnDemand/AgentWorkspace/COD_SEOD_Agent_Workspace_TI.TI.uicomponent

3. Create Custom BO.

Create a custom BO to retrieve Tickets and Sub Tickets and it’s associated Extension fields.

The custom BO should have the same set of elements at Root & Sub Node level, which needed in the PDF template. For this add transient elements to the custom BO(To hold the standard information).

import AP.Common.GDT as apCommonGDT;
import AP.CRM.Global;

businessobject Custom_Ticket {

       	      [Transient] element TicketID : BusinessTransactionDocumentID;
              [Transient] element TicketDesc : LANGUAGEINDEPENDENT_LONG_Description;
	      [Transient] element Ext_SpecialNote : LANGUAGEINDEPENDENT_EXTENDED_Text;

              node SubTickets [0,n] { 
                  [Transient] element Sub_TicketID : BusinessTransactionDocumentID;
	          [Transient] element Sub_TicketDesc : LANGUAGEINDEPENDENT_LONG_Description;
		  [Transient] element Sub_TicketExt_SpecialNote : LANGUAGEINDEPENDENT_EXTENDED_Text;

4. Populate data for the new Custom BO.

Now we have the Custom BO and elements ready, we need to fill data into it. For this we need to implement After Modify Event at root level.

Below will be the code you can add to retrieve Tickets and It’s associated Sub tickets.

import ABSL;
import AP.CRM.Global;
import AP.Common.GDT;

if ( !this.GetFirst().TicketID.content.IsInitial())
	var requiredTicket = ServiceRequest.Retrieve(this.GetFirst().TicketID);
	this.GetFirst().TicketDesc = requiredTicket.Name.content;
	this.GetFirst().Ext_SpecialNote = requiredTicket.Ext_SpecialNote;

	var SubItems = requiredTicket.BusinessTransactionDocumentReference;
	foreach(var current in SubItems)
			if(current.BusinessTransactionDocumentReference.TypeCode == "118" && current.BusinessTransactionDocumentRelationshipRoleCode == "14")
				var subTicket = ServiceRequest.Retrieve(current.BusinessTransactionDocumentReference.UUID);
					var extSubNode = this.GetFirst().SubTickets.Create();
					extSubNode.Sub_TicketID = subTicket.ID;
					extSubNode.Sub_TicketDesc = subTicket.Name.content;
					extSubNode.Sub_TicketExt_SpecialNote = subTicket.Ext_SpecialNote;


5. Create Print Form.

Navigate to Custom BO and click on “Create Print Form“. This first step to create the PDF template and it’s data source.

The Form Template Group Header is generated (with a Unique ID) along with the “*.xdp” file.

If you open “*.ftgd” file you can find the unique form group code.

The Form Interface structure includes all the fields from the BO including the Sub-Nodes. You can select fields from the Form Interface for Form Template Creation.

Open “*.xdp” file (which will launch the form in adobe livecycle designer) – One can copy the content of an existing form template (“*.xdp” file) to reduce the effort in designing the template again.

Use Adobe LIVECYCLE Designer to create a Adobe Form Template and to bind the field.

Data View – This view show the hierarchy of information being exposed/available to the form template.

Hierarchy – This will give the details of PDF template’s fields and tables.

Use below window to bind the fields:-

Once form is designed, Save and Activate the form. Click on Check-In against the “*.xdp” file in C4C SDK to merge the changes back into Studio – You also need deploy the business configuration.

6. Create a Embedded Component for Custom BO.

Create an Embedded Component with an Inport, with Ticket ID as the incoming parameter. Configure an event to be fired after the trigger of inport.

Configure “EV_Initialize” to read the data for passed Ticket ID and it’s associated Sub tickets.

Configure the below operations to set the context.

  • First operation should be ‘BO Read’, which initially checks if the data has already been buffered in Custom BO? If yes, then it avoids re-reading the data back into BO.
  • Second operation should be ‘Condition’, which checks if the attribute ‘ROOT/TICKETID’ gets a result from READ Operation, if NO (blank) then it create an instance.
    • If the Condition is met, i.e. /ROOT/TICKETID= “ “, then :- Do a Data Operation where assign incoming InportData/TicketID to ROOT/TicketID and do a exclusive SyncContainer operation.

7. Include Preview Summary Button to newly added EC for generating PDF.

  • Create a button in the same Embedded Component to launch the custom preview form for Ticket & Sub Tickets.
  • Create an Outport to pass the FORM Group Code and the parameter to force front-end preview as-is below

  • Create the Event Handler to trigger outport and assign this Event Handler to “ON CLICK” properties of the Button – Add FireOutport operation of previously added Outport.
  • Add the PREVIEW Modal Dialog (from the reuse SAP BYD Application UI folder – /SAP_BYD_APPLICATION_UI/Reuse/OutputManagement/Preview.MD.uicomponent)

Also do a NodeReferenceBinding on ROOT

Next add the Embedded Component using a Stable Anchor in the Ticekt TI – /BYD_COD/ServiceOnDemand/AgentWorkspace/COD_SEOD_Agent_Workspace_TI.TI.uicomponent

And do the Outport-Inport Binding.

With above enhancement:- Ticket->Sub ticket will look as shown below.

If you click on the button “Preview Summary” It will generate the below PDF.

You can find more details on this concept from this link -:-




Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      I did the same but I think there is a problem in Preview compionent now, It says invalid or incoorect Embedded component preview.

      Can you please check that?