liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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)}