Additional feature to pre-determine children list to clone
This commit is contained in:
1 parent
21df2d0bd2
commit
a33604b498
10 files changed
+267
-37
No files matched your search
@@ -1,12 +1,13 @@
|
||||
import { LightningElement, api, wire, track } from 'lwc';
|
||||
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
|
||||
import { getRecord } from 'lightning/uiRecordApi';
|
||||
import { NavigationMixin} from 'lightning/navigation';
|
||||
import OPPORTUNITY_OBJECT from '@salesforce/schema/Opportunity';
|
||||
import ObtainCloneOpportunityFields from '@salesforce/apex/OpportunityCloneService.ObtainCloneOpportunityFields';
|
||||
import ObtainChildRelationships from '@salesforce/apex/OpportunityCloneService.ObtainOpporunityChildRelationships';
|
||||
import CloneOpportunityWithChildren from '@salesforce/apex/OpportunityCloneService.CloneOpportunityWithChildren';
|
||||
|
||||
export default class OpportunityCustomClone extends LightningElement {
|
||||
export default class OpportunityCustomClone extends NavigationMixin(LightningElement) {
|
||||
@api recordId;
|
||||
|
||||
formObjectApiName;
|
||||
@@ -100,7 +101,30 @@ export default class OpportunityCustomClone extends LightningElement {
|
||||
handleSubmit(evt){
|
||||
evt.preventDefault();
|
||||
var fields = evt.detail.fields;
|
||||
window.console.log('Fields Submitted: %s',JSON.stringify(fields,null,"\t"));
|
||||
var childRelList = [];
|
||||
this.childRelationshipSelectionList.forEach( selection => {
|
||||
childRelList.push(selection.value);
|
||||
});
|
||||
window.console.log('Child Relationships Selected: %s',JSON.stringify(childRelList,null,"\t"));
|
||||
CloneOpportunityWithChildren({'oppId':this.recordId,'newValues':fields,'childRelationshipsToClone':childRelList})
|
||||
.then((results)=>{
|
||||
window.console.log('Successful callout. %s',JSON.stringify(results,null,"\t"));
|
||||
this.sendToOpp(results);
|
||||
})
|
||||
.catch((err)=>{
|
||||
window.console.log('There was an error attempting to clone records.');
|
||||
});
|
||||
}
|
||||
sendToOpp(oppId){
|
||||
window.console.log('Send to Opp executed.');
|
||||
this[NavigationMixin.Navigate]({
|
||||
type:'standard__recordPage',
|
||||
attributes:{
|
||||
recordId:oppId,
|
||||
objectApiName:OPPORTUNITY_OBJECT.objectApiName,
|
||||
actionName:'view'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
get formFields(){
|
||||
|
||||
Reference in new issue
Block a user