Scenario C Source Information to Target Detail Information

In this scenario a single source record is analyzed to produce a detail target record.

Problem

You receive many expense forms from your employees. Each form is entered as a single record, but you want to convert this to a payable invoice that contains one expense line for each analysis code. You already have a custom object called IR Expense Report where all the information for an employee's expenses on a particular date is entered on one record:

Example IR Expense Report Custom Object Fields
Field API Name Data Type
Expense Report Name Name Standard Name Autonumber field
Date Date__c Date
Employee Employee__c Lookup to Account
Hotel Amount Amount1__c Number(18,0)
Travel Amount Amount2__c Number(18,0)
Subsistence Amount Amount3__c Number(18,0)
Hotel Description Description1__c Text(30)
Travel Description Description2__c Text(30)
Subsistence Description Description3__c Text(30)

Solution

Create a ClickLink rule to convert the expense form to a payable invoice using a target relation of one to many:

  1. Add these fields the IR Expense Reports object:
    Recommended Fields to Add to the IR Expense Report Object
    FieldData TypeDescription
    ProcessedCheckboxTo be used to indicate whether an expense report has been converted to a payable invoice.
    ProcessCheckboxTo be used to indicate whether an expense report is to be converted to a payable invoice.
  2. Create a master level ClickLink rule to convert the Expense Report to a Payable Invoice. For instance:
    Recommended Values for the Convert Expense Report to Payable Invoice ClickLink Rule
    ItemValue
    ClickLink Rule NameConvert Expense Report to Payable Invoice
    Source ObjectExpenseReport__c
    Source Object Name FieldName
    Source Object Processed FieldProcessed__c
    Source Object Process FieldProcess__c
    Target Objectc2g__codaPurchaseInvoice__c
    Target Object Name FieldName
  3. Create ClickLink mappings for the rule you created in the previous step:
    Recommended Mappings for the Convert Expense Report to Payable Invoice ClickLink Rule
    Target Record Based OnMapping TypeMapping LiteralSource FieldTarget Field
    Source RecordSource Field  Date__c c2g__InvoiceDate__c
    Source RecordSource Field Employee__c c2g__Account__c
    Source RecordSource Field Namec2g__AccountInvoiceNumber__c
    Source RecordSource Field CurrencyIsoCodeCurrencyIsoCode
    Source RecordLiteralTrue ffap__DeriveDueDate__c
  4. Create a detail level ClickLink rule to convert the expense report detail to the Payable Invoice line items:
    Recommended Values for the Convert Expense Report to Payable Invoice Line Items ClickLink Rule
    ItemValue
    ClickLink Rule NameConvert Expense Report to Payable Invoice Line Items
    Source ObjectExpenseReport__c
    Source Object Name FieldName
    Target Objectc2g__codaPurchaseInvoiceExpenseLineItem__c
    Target Object Name FieldName
  5. Create ClickLink mappings for the rule that you created in the previous step. The Target Record Type is used to define the lines that are associated with each expense category. The mapping literal value for the detail lines must match the name of the GLA account.
    Recommended Mappings for the Convert Expense Report to Payable Invoice Line Items ClickLink Rule
    Target Record TypeTarget Record Based OnMapping TypeMapping LiteralSource FieldTarget Field
    DefaultSource RecordSource Field  Amount1__c c2g__NetValue__c
    DefaultSource RecordSource Field Description1__c c2g__LineDescription__c
    DefaultSource RecordLiteralHotel c2g__GeneralLedgerAccount__c
    DefaultSource RecordLiteralFalse ffap__SetGLAToDefault__c
    SubsistenceSource RecordSource Field  Amount3__c c2g__NetValue__c
    SubsistenceSource RecordSource Field Description3__c c2g__LineDescription__c
    SubsistenceSource RecordLiteralSubsistence c2g__GeneralLedgerAccount__c
    SubsistenceSource RecordLiteralFalse ffap__SetGLAToDefault__c
    TravelSource RecordSource Field  Amount2__c c2g__NetValue__c
    TravelSource RecordSource Field Description2__c c2g__LineDescription__c
    TravelSource RecordLiteralTravel c2g__GeneralLedgerAccount__c
    TravelSource RecordLiteralFalse ffap__SetGLAToDefault__c
  6. On the master ClickLink rule Convert Expense Report to Payable Invoice, create a ClickLink relationship with the detail level ClickLink rule. For instance:
    Recommended Relationship for the Convert Expense Report to Payable Invoice ClickLink Rule
    DescriptionDetail ClickLink RuleSource ObjectTarget ObjectTarget Relationship Field
    Link Master Payable Invoice to Line ItemConvert Expense Report to Payable Invoice Line ItemsExpenseReport__cc2g__codaPurchaseInvoiceExpenseLineItem__cc2g__PurchaseInvoice__c
  7. Create Visualforce pages to convert the journal batches to journals. For instance, you can use this mark-up to process a single Expense Report:

    <apex:page standardController="ExpenseReport__c" extensions="ffirule.IntegrationRuleEngine" action="{!convert}">
    <ffirule:IntegrationRule engine="{!engine}"/>
    </apex:page>

    You can use this mark-up to process several expense reports on a list view:

    <apex:page standardController="ExpenseReport__c" extensions="ffirule.IntegrationRuleEngine" action="{!convert}" recordSetVar="records">
    <ffirule:IntegrationRule engine="{!engine}"/>
    </apex:page>

  8. In the master ClickLink rule Convert Expense Report to Payable Invoice, create ClickLink rule buttons to access the pages created in the previous step.
  9. On the source object IR Expense Report, create a Detail Page Button custom button that uses the page that you created to process a single Expense Report.
  10. On the source object IR Expense Report, create a List Button custom button that uses the page that you created to process several ~Expense Reports on a list view.

To use the solution do one of the following on the Journal Batches tab:

  • To process several Expense Reports, select the Expense Reports that you want to process and click Create Payable Invoices.
  • To process a Expense Report, click the Expense Report Name that you want to process and then click Create Payable Invoice.
Note: If you created buttons with different names, select the buttons that you created.

The Processed checkbox is populated on the Expense Reports that you processed.