Introduced new flows
In Oneflow package versions 4.xx and later, we have made some changes to Oneflow Mapping: Products flow and introduced three new flows to support the two-way synchronization of product fields between Salesforce and Oneflow. The Oneflow Mapping: Products flow manages the transfer of Salesforce product information to Oneflow contracts. The other new flows handle the synchronization of product updates from Oneflow to Salesforce. By default, these flows handle product updates for the Opportunity line item object, so if you are only using the Opportunity line item as a product in Salesforce and don’t need to change the default mappings, no need to customize these flows. If you want these flows to work with a different Salesforce object you use as a product, or if you need to adjust the default mapping, you may need to customize them.
Note: Before customizing the Two-Way sync flows, ensure you make the necessary customizations to the Oneflow Mapping: Products flow. Refer to the Customizing Product Mapping for Contracts (Salesforce v4.x.x and above) article for more information.
1. Oneflow Products Update Flow
This flow is designed to handle product updates from Oneflow to Salesforce (To get Oneflow product updates to related Salesforce products). By default, this flow handles the Oneflow to Salesforce updates for opportunity line items. However, you can customize this flow for any other object as well.
You can find this flow at Setup > Process Automation > Flows > Oneflow Products Update
Flow inputs
There are 4 flow input parameters in this flow.
- OneflowProducts - Updated Oneflow products converted into OFapp__OneflowProduct object type
- ProductIds - Updated Oneflow product IDs
- ProductSobjectTypes - All the SObject type names of the mapped products (If you map another Salesforce object as a product it will also included here)
- ProductAttributesThatCanBeSynced - Oneflow to Salesforce Sync enabled product attributes.
When you fetch Oneflow updates to Salesforce, this flow updates Oneflow to Salesforce sync-enabled product fields in the related Salesforce opportunity line items. Oneflow provides product field configuration for the following product attributes in the default flow configuration.
- Name
- Price 1 Base Amount
- Price 1 Discount
- Quantity Type
- Quantity
Note: To enable or disable product attributes sync behavior, go to Oneflow Configuration > Product Attributes.
- Salesforce >> Oneflow: Activating this will start syncing product updates from Salesforce to Oneflow contracts (You have to click the update button to push updates to Oneflow contract).
- Oneflow >> Salesforce: Activating this will sync product updates from Oneflow to Salesforce (If the contract state is draft you have to click Fetch Oneflow Updates button to fetch updates from Oneflow. Otherwise the updates will be automatically synced to Salesforce).
You can add additional mapping for Price 2 Base Amount, and Price 2 Discount or change the existing mapping.
- To add additional mappings for Price 2 Base Amount or Discount - Add a new assignment in the relevant flow path (Discount 2, Price 2) and assign the Opportunity field that you want to map with the Oneflow attribute.
For example, you can assign Opportunity line item List price as Oneflow product price 2. - To change the existing mapping - Change the assigned opportunity property to the property that you want to map as a Oneflow attribute. Please note that the Opportunity field you are going to map with the OFapp__OneflowProduct field should be of the same data type of OFapp__OneflowProduct field(e.g., Number, Text, etc.).
2. Oneflow Handle Deselected Products flow
This flow is designed to delete the products in Salesforce whenever a user deselects a product or sets the product quantity to 0 in a Oneflow contract. By default, this flow is based on the opportunity line items, but you can configure it for other Salesforce objects as well.
You can find this flow at Setup > Process Automation > Flows > Oneflow Handle Deselected Products
Flow input variables
- OneflowContractProducts - Oneflow Contract Products to be updated
- ProductsIds - Product IDs to be deleted
- ProductSObjectType - SObject types of the mapped products (In default configuration only the value is OpportunityLineItem).
First, this flow queries all the products related to the input product SObject type and product IDs. After that, the flow assign all the opportunity line items (deselected or quantity 0 products in the Oneflow contract) information to a new instance of OFapp__Oneflow_Deselected_Product__c object. OFapp__Oneflow_Deselected_Product__c object fields represents the Oneflow deselected product fields and mapped Salesforce product fields information. So that whenever the user re-selects the product or adds a quantity amount greater than 0 we can create the opportunity line item in the Salesforce again using the saved data in OFapp__Oneflow_Deselected_Product__c object records.
In the default flow configuration following product attributes are mapped to the OneflowDeselectedProduct (OFapp__Oneflow_Deselected_Product__c object fields)
- Oneflow contract product Id
- Opportunity line item sales price
- Opportunity line item discount
- Opportunity line item quantity
- Opportunity line item name
- Opportunity line item Description
- Opportunity line item Id
- Opportunity line item product Id
- Opportunity Id
- Product SObject Type
- Opportunity line item Quantity Type
Note:
- If you have changed the default mapping in OneflowProductLineItem by adding additional fields in the Oneflow Mapping: Products flow, make sure to create new fields in the OFapp__Oneflow_Deselected_Product__c object to save the corresponding field values.
- For that go to the Setup > Object Manager > Oneflow Deselected Product > Fields and Relationships > New.
![](https://s3-eu-central-1.amazonaws.com/euc-cdn.freshdesk.com/data/helpdesk/attachments/production/77177176080/original/kYrBmA8Jrvecj_msZXQPdno6sqv9aZUuoA.png?1721629146)
- Make sure to select the correct field type when you are creating the field.
- After that map the required field to the Opportunity line item field by adding a new assignment in the Create new Oneflow Deselected Product step.
![](https://s3-eu-central-1.amazonaws.com/euc-cdn.freshdesk.com/data/helpdesk/attachments/production/77177177142/original/4EiyQtiyR0DzsHOA7DoMjrcYaeCyfofzug.png?1721629537)
In the next step, flow adds the assigned object to OneflowDeselectedProductsList collection variable. At the end, it will save the OneflowDeselectedProductsList records in the DB and retrieve saved deselected products and adds to the NewCreatedOneflowDeselectedProducts record collection variable. After that, the flow output the NewCreatedOneflowDeselectedProducts flow record collection variable as a output.
3. Oneflow Add Reselected Products
This flow handles the product re-selection in Oneflow contract products. When you re-select the product or set the quantity to greater than zero in the Oneflow contract product and fetch the updates to Salesforce, the flow will recreate the product in Salesforce. By default, this flow is based on the opportunity line items, but you can configure it for other Salesforce objects as well.
You can find this flow at Setup > Process Automation > Flows > Oneflow Add Reselected Products
Flow Input Variables
- DeselectedProductIds : IDs of Oneflow deselected products.
- OneflowContractProductsWithDeselected : Deselected Oneflow contract products.
When this flow executes, it first fetches all the Oneflow Deselected Products (OFapp__Oneflow_Deselected_Product__c) that have the IDs provided in the DeselectedProductIds flow input variable.
Next, there is a loop to iterate over all the queried products (Loop Deselected Products) and a decision variable to filter the products that are opportunity line items based on the Deselected product SObject type (Which type of SObject Decision variable).
In the following step (New Opportunity Product Assignment Variable), the flow assigns the field values of the Oneflow Deselected Products to the OpportunityProduct Record Variable (Since it handles the opportunity line items by default).
If you have mapped additional opportunity line item fields or changed the default field mappings in the flows described above, ensure to make the necessary changes here as well.
Afterwards, the flow adds that opportunity line item instances to the NewOpportunityProductsCollection collection variable and adds the deselected products to the DeselectedProductsToBeDeleted collection variable. Then, the flow creates new opportunity line items using the NewOpportunityProductsCollection. The flow then queries those newly created products again and updates the relevant fields according to the OneflowContractProductsWithDeselected flow input.
In the following step, it assigns the new line item IDs to the mapped Oneflow contract products and changes the Deselected field to False. In the final step, it commits the Oneflow contract products update section as a batch using the OneflowContractProductsToUpdate updated product list and outputs the DeselectedProductsToBeDeleted list.
Trigger for Deselected Products
You need to implement the trigger to handle push updates product deletions in the Oneflow contract for the other objects that you mapped as products. You don't need to implement this for opportunity line items, as this is already created when the Oneflow package is installed.
- First, create a trigger on the object you mapped as a product.
- Paste the following code. Only the object API name (Account_Product__c) needs to be changed for any other product type (Object API name); the rest of the code remains the same.
trigger AccountProductTrigger on Account_Product__c (before delete) { Set<Id> ids = new Set<Id>(); for (Account_Product__c item : Trigger.old){ ids.add(item.Id); } OFapp.OneflowContractProductService oneflowService = new OFapp.OneflowContractProductService(); oneflowService.updateOneflowContractProductsToBeDeleted(ids); }