global class Event_Confirmation{ @AuraEnabled webService static String checkMinister(List idList){ User u = [select id, Post__c from User where id =:UserInfo.getUserId()]; List eList = [select id, Minister__c, Manager__c, Daily_Report__r.Reporter__c, Daily_Report__r.Reporter__r.ManagerId from Event__c where id =:idList]; for(Event__c e : eList){ if(UserInfo.getUserId() == e.Daily_Report__r.Reporter__c){ return '自己不能承认自己。'; } // TODO xud ここでチェックすべき? // if(UserInfo.getUserId() != e.Daily_Report__r.Reporter__r.ManagerId){ // return '上司才可以选择。'; // } } if(u.Post__c == '部长' || u.Post__c == '副部长' || u.Post__c == '总监' || u.Post__c == '副总监'){ for(Event__c e : eList){ e.Minister__c = true; e.Minister_Check_Time__c = Datetime.now(); } } else if(u.Post__c == '经理' || u.Post__c == '副经理'){ for(Event__c e : eList){ e.Manager__c = true; e.Manager_Check_Time__c = Datetime.now(); } } else{ return System.Label.Error_Message26; } try{ update eList; } catch(Exception e){ return e.getMessage(); } return System.Label.Save_Completion; } }