Setting the order of the products under opportunity in Salesforce lightning and syncing to invoice with the same order


Issue

The order of the products under the opportunity wouldn’t be synced in the same order to invoice unless the changes are made in the advanced query builder of the DBSync.


The Query for unsorted order:


Query:

SELECT {!.},Account.Id,(SELECT {!OpportunityLineItems/records} FROM OpportunityLineItems) FROM Opportunity where  Opportunity.AVSFQB__Generate_Object__c= 'Invoice' and AVSFQB__Products_Count__c > 0


Solution  

Step 1:

  • Navigate to products under opportunity.  

  • Click on the dropdown present on the rightmost top corner.



Step 2:

    Make the necessary changes mentioned below in the Advanced query builder section 

    for the respective project after logging into your DBSync account.

 

The Query for sorted order:


Query:

SELECT {!.},Account.Id,(SELECT {!OpportunityLineItems/records} FROM OpportunityLineItems Order By SortOrder) FROM Opportunity where  Opportunity.AVSFQB__Generate_Object__c= 'Invoice' and AVSFQB__Products_Count__c > 0