import { LightningElement,wire,track,api } from 'lwc'; import { CurrentPageReference,NavigationMixin } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; import HospitalAccountrecordTypeId from '@salesforce/label/c.HospitalAccountrecordTypeId'; export default class LexCreateHospital extends NavigationMixin(LightningElement) { @api recordId; @wire(CurrentPageReference) getStateParameters(currentPageReference) { console.log(currentPageReference); if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; console.warn("str"); console.warn(str); this.recordId = str; } } } connectedCallback(){ debugger // console.warn('recordId'+this.recordId); // var url = '/001/e?' + '00N10000009HFQT=基建项目&AccountSource=基建项目' + '&RecordType=01210000000QemG' + '&retURL=%2F' + this.recordId; // window.open(url); const defaultValues = encodeDefaultFieldValues({ Hospital_Source__c: '基建项目', AccountSource: '基建项目', Infrastructure_Project__c : this.recordId //DB202311157614 WYL new }); console.log('defaultValues = ' + defaultValues); this[NavigationMixin.Navigate]({ type: 'standard__objectPage', attributes: { objectApiName: 'Account', actionName: 'new' }, state: { nooverride: '1', defaultFieldValues: defaultValues, recordTypeId: HospitalAccountrecordTypeId } }); this.dispatchEvent(new CloseActionScreenEvent()); } }