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
@@ -6,19 +6,20 @@
|
||||
<template for:each={formFields} for:item="formField">
|
||||
<lightning-input-field key={formField.apiName} field-name={formField.apiName} value={formField.value}></lightning-input-field>
|
||||
</template>
|
||||
<div class="slds-col slds-size_1-of-1">
|
||||
<h2 class="slds-text-heading_medium">Child Records to Clone</h2>
|
||||
</div>
|
||||
<div class="slds-col slds-size_1-of-1">
|
||||
<lightning-combobox name="childRelationships" label="Child Relationships" placeholder="Select To Clone"
|
||||
options={childRelationshipDisplayList} onchange={handleChildRelationshipSelection}></lightning-combobox>
|
||||
</div>
|
||||
<div class="slds-col slds-size_1-of-1">
|
||||
<lightning-pill-container items={childRelationshipSelectionList} onitemremove={handleChildSelectionRemoval}></lightning-pill-container>
|
||||
</div>
|
||||
<lightning-button type="submit" label="Submit"></lightning-button>
|
||||
</lightning-record-edit-form>
|
||||
</div>
|
||||
<div class="slds-col slds-size_1-of-1">
|
||||
<h2 class="slds-text-heading_medium">Child Records to Clone</h2>
|
||||
</div>
|
||||
<div class="slds-col slds-size_1-of-1">
|
||||
<lightning-combobox name="childRelationships" label="Child Relationships" placeholder="Select To Clone"
|
||||
options={childRelationshipDisplayList} onchange={handleChildRelationshipSelection}></lightning-combobox>
|
||||
</div>
|
||||
<div class="slds-col slds-size_1-of-1">
|
||||
<lightning-pill-container items={childRelationshipSelectionList} onitemremove={handleChildSelectionRemoval}></lightning-pill-container>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</lightning-card>
|
||||
</template>
|
||||
@@ -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