123
chenjingwu
2024-04-19 ee77be2b62907bedbcf57decddad12be83baaabb
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
/*
 * @Description: 
 * @version: 
 * @Author: chen jing wu
 * @Date: 2023-06-29 15:55:05
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-06-30 11:28:58
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import init  from '@salesforce/apex/lexAccountController.initForOTHCreateButton';
 
export default class LexOTHCreate extends LightningElement {
    @api recordId;
    recordTypeId;
    @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.recordTypeId = result.recordTypeId;
            this.OTHCreate();
        });
    }
    OTHCreate(){
        const defaultValues = encodeDefaultFieldValues({
            Account__c: this.recordId
        });
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Account_Number_of_case__c',
                actionName: 'new'
            },
            state: {
                nooverride: '1',
                defaultFieldValues: defaultValues,
                RecordTypeId: this.recordTypeId
            }
        });
    }
}