import { LightningElement,wire,track,api} from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { NavigationMixin } from 'lightning/navigation'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; // import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner'; import init from '@salesforce/apex/LexCICInputSolutionController.initCustomClone'; // import { updateRecord } from 'lightning/uiRecordApi'; export default class lexCustomClone extends NavigationMixin(LightningElement) { @api recordId; IsLoading = true; inquirydetail; answerdetailcontent; RecordType; inquiry_type__c; solutuion__c; prod__c; Other_company_product__c; Competitor_info__c; @wire(CurrentPageReference) getStateParameters(currentPageReference) { console.log(111); console.log(currentPageReference); if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; console.log("str"); console.log(str); this.recordId = str; } } } connectedCallback () { init({ recordId: this.recordId }).then(result => { this.IsLoading = false; if (result != null) { console.log(result); this.initData = result; if(result !=null) { if(result.caseList.length>0) { this.inquirydetail = result.caseList[0].inquiry_detail__c; this.answerdetailcontent = result.caseList[0].answer_detail_content__c; this.inquiry_type__c = result.caseList[0].inquiry_type__c; this.solutuion__c = result.caseList[0].solutuion__c; this.prod__c = result.caseList[0].prod__c; this.Other_company_product__c = result.caseList[0].Other_company_product__c; this.Competitor_info__c = result.caseList[0].Competitor_info__c; console.log('Other_company_product__c>>>>>>' + result.caseList[0].Other_company_product__c); } this.RecordType = result.caseRecordType; this.navigateToNewObjectPage(); this.dispatchEvent(new CloseActionScreenEvent()); } } /* this.cancelSubmit().then(res=>{ this.IsLoading=false; this.dispatchEvent(new CloseActionScreenEvent()); }); */ // var url = "/500/e?retURL="+this.recordId+"&RecordType=01210000000QsYp&ent=Case"+ // "&00N10000003M4vA="+this.inquirydetail+ // "&00N10000003M4v8="+this.answerdetailcontent; // window.open(url); }).catch(error => { console.log('error='+error); }).finally(() => { }); } navigateToNewObjectPage() { const defaultFieldValues =encodeDefaultFieldValues({ inquiry_detail__c: this.inquirydetail, answer_detail_content__c: this.answerdetailcontent, inquiry_type__c: this.inquiry_type__c, solutuion__c: this.solutuion__c, prod__c: this.prod__c, Other_company_product__c: this.Other_company_product__c, Competitor_info__c: this.Competitor_info__c }); console.log(defaultFieldValues); this[NavigationMixin.Navigate]({ type: 'standard__objectPage', attributes: { objectApiName: 'Case', actionName: 'new' }, state: { // nooverride:'1', defaultFieldValues: defaultFieldValues, recordTypeId:this.RecordType } }); this.dispatchEvent(new CloseActionScreenEvent()); } async cancelSubmit(){ // window.open('/apex/NewAndEditCase?retURL='+this.recordId+'&RecordType='+this.RecordType+'&inquiry_detail__c='+this.inquirydetail+'&answer_detail_content__c='+this.answerdetailcontent); window.open('/apex/NewAndEditCase?retURL='+this.recordId+'&RecordType='+this.RecordType+'&inquiry_detail__c='+this.inquirydetail+'&answer_detail_content__c='+this.answerdetailcontent); } } //oldjs // /500/e?retURL={!Case.Id}&RecordType=01210000000QsYp&ent=Case // &00N10000003M4vA={!HTMLENCODE(Case.inquiry_detail__c)} // &00N10000003M4v8={!HTMLENCODE(Case.answer_detail_content__c)}