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:
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:
- Add these fields the IR Expense Reports object:
Recommended Fields to Add to the IR Expense Report Object Field Data Type Description Processed Checkbox To be used to indicate whether an expense report has been converted to a payable invoice. Process Checkbox To be used to indicate whether an expense report is to be converted to a payable invoice. - 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 Item Value ClickLink Rule Name Convert Expense Report to Payable Invoice Source Object ExpenseReport__c Source Object Name Field Name Source Object Processed Field Processed__c Source Object Process Field Process__c Target Object c2g__codaPurchaseInvoice__c Target Object Name Field Name - 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 On Mapping Type Mapping Literal Source Field Target Field Source Record Source Field Date__c c2g__InvoiceDate__c Source Record Source Field Employee__c c2g__Account__c Source Record Source Field Name c2g__AccountInvoiceNumber__c Source Record Source Field CurrencyIsoCode CurrencyIsoCode Source Record Literal True ffap__DeriveDueDate__c - 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 Item Value ClickLink Rule Name Convert Expense Report to Payable Invoice Line Items Source Object ExpenseReport__c Source Object Name Field Name Target Object c2g__codaPurchaseInvoiceExpenseLineItem__c Target Object Name Field Name - 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 Type Target Record Based On Mapping Type Mapping Literal Source Field Target Field Default Source Record Source Field Amount1__c c2g__NetValue__c Default Source Record Source Field Description1__c c2g__LineDescription__c Default Source Record Literal Hotel c2g__GeneralLedgerAccount__c Default Source Record Literal False ffap__SetGLAToDefault__c Subsistence Source Record Source Field Amount3__c c2g__NetValue__c Subsistence Source Record Source Field Description3__c c2g__LineDescription__c Subsistence Source Record Literal Subsistence c2g__GeneralLedgerAccount__c Subsistence Source Record Literal False ffap__SetGLAToDefault__c Travel Source Record Source Field Amount2__c c2g__NetValue__c Travel Source Record Source Field Description2__c c2g__LineDescription__c Travel Source Record Literal Travel c2g__GeneralLedgerAccount__c Travel Source Record Literal False ffap__SetGLAToDefault__c - 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 Description Detail ClickLink Rule Source Object Target Object Target Relationship Field Link Master Payable Invoice to Line Item Convert Expense Report to Payable Invoice Line Items ExpenseReport__c c2g__codaPurchaseInvoiceExpenseLineItem__c c2g__PurchaseInvoice__c - 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> - In the master ClickLink rule Convert Expense Report to Payable Invoice, create ClickLink rule buttons to access the pages created in the previous step.
- 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.
- 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.
The Processed checkbox is populated on the Expense Reports that you processed.