Modification to Services to process Datetime and add error toast
This commit is contained in:
1 parent
a33604b498
commit
26423a7f33
5 files changed
+77
-28
No files matched your search
@@ -2,6 +2,7 @@ import { LightningElement, api, wire, track } from 'lwc';
|
||||
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
|
||||
import { getRecord } from 'lightning/uiRecordApi';
|
||||
import { NavigationMixin} from 'lightning/navigation';
|
||||
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
||||
import OPPORTUNITY_OBJECT from '@salesforce/schema/Opportunity';
|
||||
import ObtainCloneOpportunityFields from '@salesforce/apex/OpportunityCloneService.ObtainCloneOpportunityFields';
|
||||
import ObtainChildRelationships from '@salesforce/apex/OpportunityCloneService.ObtainOpporunityChildRelationships';
|
||||
@@ -17,6 +18,21 @@ export default class OpportunityCustomClone extends NavigationMixin(LightningEle
|
||||
childRelationshipList;
|
||||
recordInfo;
|
||||
childRelationshipDisplayList = [];
|
||||
toastAttributes = {
|
||||
"success": {
|
||||
"title":"Success!",
|
||||
"message":"Your action was successful",
|
||||
"variant":"success",
|
||||
"mode":"dismissable"
|
||||
},
|
||||
"error": {
|
||||
"title":"Error",
|
||||
"message":"There was an error attempting to execute your request. {0}",
|
||||
"messageData":[],
|
||||
"variant":"error",
|
||||
"mode":"pester"
|
||||
}
|
||||
};
|
||||
@track childRelationshipSelectionList = [];
|
||||
|
||||
@wire(getRecord,{recordId:'$recordId',layoutTypes:['Full'],modes:['Edit']})
|
||||
@@ -27,7 +43,6 @@ export default class OpportunityCustomClone extends NavigationMixin(LightningEle
|
||||
}
|
||||
|
||||
if(data) {
|
||||
//window.console.log('Original Data: %s',JSON.stringify(data,null,"\t"));
|
||||
this.recordInfo = data.fields;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +100,6 @@ export default class OpportunityCustomClone extends NavigationMixin(LightningEle
|
||||
fullSelectedList.push(chosenObj);
|
||||
}
|
||||
this.childRelationshipSelectionList = fullSelectedList;
|
||||
window.console.log('Full Selected List: %s',JSON.stringify(this.childRelationshipSelectionList,null,"\t"));
|
||||
}
|
||||
|
||||
handleChildSelectionRemoval(evt){
|
||||
@@ -108,11 +122,15 @@ export default class OpportunityCustomClone extends NavigationMixin(LightningEle
|
||||
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.');
|
||||
let toastInstanceMessage = this.toastAttributes.error;
|
||||
toastInstanceMessage.messageData.push(err.body.message);
|
||||
const event = new ShowToastEvent(toastInstanceMessage);
|
||||
this.dispatchEvent(event);
|
||||
//window.console.log('There was an error attempting to clone records.');
|
||||
//window.console.dir(err.body.message);
|
||||
});
|
||||
}
|
||||
sendToOpp(oppId){
|
||||
@@ -131,7 +149,6 @@ export default class OpportunityCustomClone extends NavigationMixin(LightningEle
|
||||
var formFieldsToReturn = [];
|
||||
var fieldRequirementMap = this.requiredFieldMap;
|
||||
if(this.opportunityFields && this.displayedFields && this.recordInfo) {
|
||||
window.console.log('fieldInfo %s: ', JSON.stringify(this.recordInfo,null,"\t"));
|
||||
this.displayedFields.forEach(fieldName => {
|
||||
let fieldItem = fieldRequirementMap[fieldName];
|
||||
let fieldDisplay = JSON.parse(JSON.stringify(this.opportunityFields[fieldName]));
|
||||
|
||||
Reference in new issue
Block a user