Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Lightning solution to clone opportunity with products

License

Notifications You must be signed in to change notification settings

ministe2003/cloneOppWithProducts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloneOppWithProducts

Lightning solution to clone opportunity with products

Overview

Based on the CloneOpp component by Naval Sharma - this project extends his excellent work to try and improve and expand it's abilities.

Salesforce Idea

Here's a link to the Idea for Salesforce to restore this as standard.

Differences from CloneOpp (correct as of February 2019)

  • In CloneOpp the opportunity is cloned without any input from the user, based on fields which are placed in a fieldset. There is no way for changes to be made to the opportunity before the clone takes place
    • This component replicates Salesforce's own Clone behaviour by displaying the opportunity page layout and allowing changes before the clone takes place
  • In CloneOpp, the opportunity product fields are hard coded into the table meaning you can only change the values of Quantity, Sales Price, Date and Description
    • This component builds the table dynamically using the using lightning:datatable component, and displays whatever fields you decide to add to a fieldset
  • In CloneOpp some errors are suppressed
    • Some errors are only logged to the console and aren't displayed to the user. This component uses improved error handling to keep the user informed along the way

Usage Instructions

Once the package has been installed and set up, clicking the Clone with Products button will first open a window where you can edit the opportunity before you clone it. This is to repliace the behaviour of the standard Clone button. Once the opportunity has been saved the lines will appear in a table.

  • If you press Save without making any changes, the lines will be cloned as they are.
  • If you press Cancel, the lines will not be cloned. This replicates the standard Clone with Products behaviour in Salesforce Classic.
  • Alternatively you can inline-edit any editable fields or delete any lines you do not want to clone. When you're finished press Save to clone the lines. Once the clone has completed you will be redirected to the new opportunity.

Setup Instructions

  1. Install the package by clicking the relevant link for your org, either Sandbox or Production. It's recommended to test this in your Sandbox first.
  2. Add the 'Clone with Products' lightning action to your page layout(s)
  3. You will need to update 2 fieldsets to decide which Opportunity Line Item fields to clone, and which to make available for editing before performing the clone:
  • Navigate to the Opportunity Product object
    • In classic: Setup | Customize | Opportunities | Opportunity Products | Field Sets
    • In lightning: Setup | Objects and Fields | Object Manager | Opportunity Product | Field Sets
  • Select fields to clone
    • Open 'Clone Opportunity Field Set' for editing
    • Add and remove fields to the fieldset which you wish to be included in the clone operation and Save
  • Select fields to make editable
    • Open 'Clone Opportunity Editable Field Set' for editing
    • Add and remove fields to the field set which you wish to be made available for editing before the lines are cloned. Fields included in this field set will be displayed in a table so users can modify the values. Field Level Security is respected and formula fields added to this field set will be displayed in the table but not editable.

Packages (version 1.4)

This package is only available as an unmanaged package

Changelog

version 1.4 (2019-02-20)

Fixed

  • Trying to clone lines without ever opening an inline-edit field causes 'changes' function parameter to be null, causing an exception in the apex controller. Updated controller to handle null

version 1.3 (2019-02-19)

Removed

  • Removed org requirements for opportunity record types and multi-currency

version 1.2 (2019-02-06)

  • Initial published version

Limitations

  • Relationship fields (lookup and master detail) cannot be added to the 'Clone Opportunity Editable Field Set' or you will receive an error when attempting to clone the lines. This is due to a limitation in the Lightning:Datatable component
  • This has not been tested in multiple orgs so other limitations may exist which I'm not yet aware of

Credit

Again, credit must be given to Naval Sharma and his CloneOpp component which formed the basis for this project.

About

Lightning solution to clone opportunity with products

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published