zhangchunxu
2023-07-21 9cf6073e08e6c398de348b5856ce1265753a7567
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
public with sharing class NewLeadFromContact2 {
    @AuraEnabled
    public static InitData NewLeadFromContact2(String recordId) {
        InitData res = new initData();
        try{
            Contact report= [SELECT Id,Name,AccountId FROM Contact WHERE Id = :recordId LIMIT 1];
            res.Id = report.Id;
            res.Name = report.Name;
            res.AccountId = report.AccountId;
            Account acc =  [SELECT Id,Name,Department_Class__c  FROM Account WHERE id =: report.AccountId]; 
            res.accountIds = acc.Id;
            res.accountName = acc.Name;
            res.accountDepartmentClass = acc.Department_Class__c;
            res.NewDailyReport = Schema.SObjectType.Lead.getRecordTypeInfosByDeveloperName().get('NewDaily_Report').getRecordTypeId();
            System.debug(LoggingLevel.INFO, '*** xu: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** xu: ' + e);
        }
        return res;
    }
    public class InitData{
        @AuraEnabled
        public String Id;
        @AuraEnabled
        public String Name;
        @AuraEnabled
        public String AccountId;
        @AuraEnabled
        public String accountIds;
        @AuraEnabled
        public String accountName;
        @AuraEnabled
        public String accountDepartmentClass;
        @AuraEnabled
        public String NewDailyReport;
    }
}