liuyn
2024-03-22 e8be4d964c6b336ed39dba5900b1b9a8f3181b96
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
import { LightningElement, track, wire,api } from 'lwc';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
import Object_History_Field_API_Name from '@salesforce/label/c.Object_History_Field_API_Name';
import Object_History_NewValue from '@salesforce/label/c.Object_History_NewValue';
import Object_History_OldValue from '@salesforce/label/c.Object_History_OldValue';
import Object_History_Update_Datetime from '@salesforce/label/c.Object_History_Update_Datetime';
import Object_History_Update_User from '@salesforce/label/c.Object_History_Update_User';
import getObjectHistoryList from '@salesforce/apex/ObjectHistoryShowController.getObjectHistoryList';
 
export default class ObjectHistoryShow extends LightningElement {
    @api recordId;
 
    ohiInfoList = [];
    columns = [
        { label: Object_History_Update_Datetime, fieldName: 'updateDatetime', type: 'text' },
        { label: Object_History_Field_API_Name, fieldName: 'fieldAPINameLabel', type: 'text' },
        { label: Object_History_Update_User, fieldName: 'updateUser', type: 'text' },
        { label: Object_History_OldValue, fieldName: 'oldValue', type: 'text' },
        { label: Object_History_NewValue, fieldName: 'newValue', type: 'text' },
    ];
 
    connectedCallback() {
        getObjectHistoryList({recordId : this.recordId})
        .then(result => {
            this.ohiInfoList = result.ohiInfoList;
        })
        .catch(error => {
            window.console.log(' Error Occured ', error);
        })
        .finally(()=>{
            //this.isLoaded = false;
            window.console.log(this.ohiInfoList);
            window.console.log(this.recordId);
        })
    }
 
    handleOnLoad(){
        this.isLoaded = false;
    }
 
    showToast (title,message,variant){
        const event = new ShowToastEvent({
            title: title,
            message: message,
            variant : variant
 
        });
        this.dispatchEvent(event);
    }
 
    analysisError (error){
        var msg = '';
        var errBody = error.body;
        if (errBody){
            if (errBody.pageErrors){
                errBody.pageErrors.forEach(item =>{
                    msg = msg + item.message;
                });
            }
        }
        return msg;
    }
}