Scenario A Creating a Target Document from a Source Document
In this scenario a ClickLink rule is created to generate a target record from a source record. The source and target records have child records.
Problem
You are a sales clerk and want to turn a work order into a sales invoice when the work order has been flagged as "To Invoice". When the sales invoice has been created, you want the work order to be marked "Invoiced". You also want the new sales invoice to be linked to the work order.
Solution
Create ClickLink rules to map the fields on the work order and work order line items onto a sales invoice and the sales invoice line items. In this scenario, these fields in the work order object will be mapped to the sales invoice object using a master level ClickLink rule:
Source in Work Order Object | Source Field Data Type | Target Field in Sales Invoice |
---|---|---|
Account | Lookup to Account | Account |
Date | Date | Invoice Date |
Summary Description | Text | Invoice Description |
Id | Work Order |
These fields in the sales order line item object will be mapped to the sales invoice line item object using a detail level ClickLink rule:
Source in Work Order Line | Source Field Data Type | Target in Sales Invoice Line Item |
---|---|---|
Service Code | Lookup(Product) | Product Name |
Hours | Number(4, 0) | Quantity |
Rate | Currency(5, 2) | Unit Price |
To create the solution using ClickLink:
- If the fields described previously do not exist in the Work Order and Work Order Line Item objects create them.
- Add these custom fields of type Checkbox to the Work Order object with a Default Value of Unchecked:
- To Invoice
- Invoiced.
- Create the master level ClickLink rule Convert Work Order to Sales Invoice. For instance:
Recommended Values for the Convert Work Order to Sales Invoice ClickLink Rule Item Value ClickLink Rule Name Convert Work Order to Sales Invoice Source Object Work_Order__c Source Object Name Field Name Source Object Processed Field Invoiced__c Source Object Process Field To_Invoice__c Target Object c2g__codaInvoice__c Target Object Name Field Name - Create the ClickLink mappings for the rule you created in the previous step:
Recommended Mappings for the Convert Work Order to Sales Invoice ClickLink Rule Target Record Based On Mapping Type Mapping Literal Source Field Target Field Source Record Source Field Account__c c2g__Account__c Source Record Source Field Date__c c2g__InvoiceDate__c Source Record Source Field Summary_Description__c c2g__InvoiceDescription__c Source Record Source Field WorkOrder__c Id Source Record Literal False ffbilling__CopyAccountValues__c - Create the detail level ClickLink rule to convert work order line items to sales invoice line items:
Recommended Values for the Convert Work Order Line to Sales Invoice Line ClickLink Rule Item Value ClickLink Rule Name Convert Work Order Line to Sales Invoice Line Source Object WO_Detail__c Source Object Name Field Name Target Object c2g__codaInvoiceLineItem__c Target Object Name Field Name - Create the following ClickLink mappings for the rule you created in the previous step:
Recommended Mappings for the Convert Work Order Line to Sales Invoice Line ClickLink Rule Target Record Based On Mapping Type Mapping Literal Source Field Target Field Source Record Source Field Service_Code__c c2g__Product__c Source Record Literal False ffbilling__DeriveUnitPriceFromProduct__c Source Record Source Field Hours__c c2g__Quantity__c Source Record Source Field Rate__c c2g__UnitPrice__c - In the master level ClickLink rule, create a ClickLink relationship to relate the master level ClickLink rule to the detail level ClickLink rule:
Recommended Relationship for the Convert Work Order to Sales Invoice ClickLink Rule Master ClickLink Rule Detail ClickLink Rule Description Source Relationship Name Target Relationship Field Convert Work Order to Sales Invoice Convert Work Order Line to Sales Invoice Line Link Work Order to Sales Invoice Work_Order_Details__r c2g__Invoice__c - Create Visualforce pages to create the sales invoice records. For instance, you can use this Visualforce markup to create a single record from the work order details.
<apex:page standardController="Work_Order__c" extensions="ffirule.IntegrationRuleEngine" action="{!convert}"> <ffirule:IntegrationRule engine="{!engine}"/></apex:page>
You can use this Visualforce markup to create multiple records from a work order list view.
<apex:page standardController="Work_Order__c" extensions="ffirule.IntegrationRuleEngine" action="{!convert}" recordSetVar="records"> <ffirule:IntegrationRule engine="{!engine}"/></apex:page>
- In the in the Convert Work Order to Sales Invoice rule, create ClickLink buttons for the Visualforce pages you created in the previous step.
- In the Work Order custom object create a custom button and a custom link to access the Visualforce pages.
- Add the custom button to the Work Order page layout and the custom link to the Work Orders List View.
To test the ClickLink rule:
- Open a work order.
- Select the To Invoice checkbox and save the change.
- Click the Create Invoice button you created earlier.