import { LightningElement, track, wire, api } from 'lwc';
|
import { CurrentPageReference } from 'lightning/navigation';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
|
import init from '@salesforce/apex/LexCICInputSolutionController.initNewCICContact';
|
|
|
|
|
|
export default class lexNewCICContact extends LightningElement {
|
IsLoading = true;
|
@api recordId;
|
initData = {};
|
def_account_id = '';
|
RecordType = '';
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
|
this.recordId = str;
|
}
|
}
|
}
|
connectedCallback(){
|
// this.recordId ='0030l00000wy2IgAAI';
|
init({
|
recordId: this.recordId
|
}).then(result => {
|
if (result != null) {
|
console.log(result);
|
this.initData = result;
|
if(result !=null) {
|
if(result.contactList.length>0) {
|
if(result.contactList[0].RecordTypeId == result.contactRecordType) {
|
this.def_account_id = result.contactList[0].Account.Id;
|
} else {
|
this.def_account_id = result.contactList[0].Account.Parent_Parent__c;
|
}
|
|
}
|
this.RecordType = result.caseRecordType;
|
}
|
this.cancelSubmit().then(res=>{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
}
|
}).catch(error => {
|
console.log(error);
|
})
|
}
|
|
async cancelSubmit(){
|
// this.navigateToNewObjectPage();
|
window.open('/apex/NewAndEditCase?retURL='+this.recordId+'&def_contact_id='+this.recordId+'&def_account_id='+this.def_account_id+'&RecordType='+this.RecordType);
|
}
|
|
|
navigateToNewObjectPage() {
|
alert();
|
const defaultFieldValues =encodeDefaultFieldValues({
|
retURL: this.recordId,
|
def_contact_id: this.recordId,
|
def_account_id: this.def_account_id,
|
RecordType: this.RecordType
|
});
|
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Case',
|
actionName: 'new'
|
},
|
state: {
|
nooverride: '1',
|
defaultFieldValues: defaultFieldValues
|
}
|
});
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
|
|
|
}
|
|
//old js
|
// /500/e?retURL=%2F{!Contact.Id}&def_contact_id={!Contact.Id}&
|
// def_account_id={!IF(Contact.RecordTypeId='01210000000QfWi',Account.Id,Account.Parent_Parent__c)}
|
// &RecordType=01210000000QsYp&ent=Case
|
|
//01210000000QfWi: select Id,DeveloperName from RecordType where SobjectType = 'Contact' and DeveloperName = 'Agency'
|
//01210000000QsYp: select Id,DeveloperName from RecordType where SobjectType = 'Case' and DeveloperName = 'CICRecordType'
|