public with sharing class HosipitalToDeptController { @AuraEnabled public static InitData init(String recordId){ InitData res = new initData(); try { Account report = [SELECT Id, GI_Main__c, BF_owner__c, ET_owner__c, SP_Main__c, URO_owner_ID__c, GYN_owner__c, ENT_owner_ID__c, Tender_information__c, Is_upload_file__c, Name, Attribute_Type__c FROM Account WHERE Id = :recordId]; res.GiMain = report.GI_Main__c; res.BFowner = report.BF_owner__c; res.ETowner = report.ET_owner__c; res.SPMain = report.SP_Main__c; res.UROownerID = report.URO_owner_ID__c; res.GYNowner = report.GYN_owner__c; res.ENTownerID = report.ENT_owner_ID__c; res.SoakupHPDeptTeam = System.Label.Confirm_SoakupHPDeptTeam; res.Tenderinformation = report.Tender_information__c; res.Isuploadfile = report.Is_upload_file__c; res.Name = report.Name; res.AttributeType = report.Attribute_Type__c; } catch (Exception e) { throw new AuraHandledException(e.getMessage()); } return res; } @AuraEnabled public static string updataAccount(String recordId,Boolean HosipitalToDept){ Account a = new Account(); try { a.Id = recordId; a.HosipitalToDept__c = HosipitalToDept; update a; } catch (Exception e) { throw new AuraHandledException(e.getMessage()); } return 'ok'; } @AuraEnabled public static string submitApproval(String recordId){ try { Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest(); psr.setObjectId(recordId); Approval.ProcessResult submitResult = Approval.process(psr); return 'ok'; } catch (Exception e) { throw new AuraHandledException(e.getMessage()); } } public class InitData{ @AuraEnabled public string GiMain; @AuraEnabled public string BFowner; @AuraEnabled public string ETowner; @AuraEnabled public string SPMain; @AuraEnabled public string UROownerID; @AuraEnabled public string GYNowner; @AuraEnabled public string ENTownerID; @AuraEnabled public string SoakupHPDeptTeam; @AuraEnabled public string Tenderinformation; @AuraEnabled public Boolean Isuploadfile; @AuraEnabled public string Name; @AuraEnabled public string AttributeType; } }