@RestResource(urlMapping='/OFSEventSelect/*') global with sharing class OFSEventSelectRest { @HttpPost global static void doPost(String eid) { system.debug('OFSEventSelectRest.start eid=' + eid); RestResponse res = RestContext.response; res.addHeader('Content-Type', 'application/json'); String jsonResponse; Event e = [select Id, Subject, Activity_Type2__c, Purpose_Type__c, ActivityDate, StartDateTime, EndDateTime, EventC_ID__c, whatid__c, Location, Main_Visit_Location__c, Related_Opportunity1__c, Related_Opportunity1_ID__c, Related_Service1__c, Related_Service1_ID__c from Event where Id = :eid]; String eventCId = e.EventC_ID__c; if (String.isBlank(eventCId)) { Map responseMap = OFSEventEditRest.createDailyReport2(e.ActivityDate, e, e.Subject, e.Activity_Type2__c, e.Purpose_Type__c, e.StartDateTime.getTime(), e.EndDateTime.getTime(), e.Id, '', e.whatid__c, e.Location, e.Main_Visit_Location__c, e.Related_Opportunity1_ID__c, e.Related_Opportunity1__c, null, null, null, null, e.Related_Service1_ID__c, e.Related_Service1__c); if (responseMap.get('System.Label.OFSErrorStatus') == System.Label.OFSErrorFailure) { String eventResponse = JSON.serialize(responseMap); res.responseBody = blob.valueOf(eventResponse); return; } eventCId = responseMap.get(System.Label.OFSErrorMessage); } Event__c ec = [Select Id, Daily_Report__c, Daily_Report__r.Reporter__c, Daily_Report__r.Status__c, Subject__c, Activity_Type2__c, Purpose_Type__c, ActivityDate__c, StartDateTime__c, EndDateTime__c, Description__c, Location__c, Main_Visit_Location__c, Event_ID__c, NTC_ID__c,Lead_ID__c,OPD_ID__c,Visitor1_ID__c,Visitor2_ID__c,Visitor3_ID__c,Visitor4_ID__c,Visitor5_ID__c, Account_ID__r.Hospital__r.Name,Account_ID__r.Hospital__r.Id,Account_ID__r.Department_Class__r.Id,Account_ID__r.Department_Class__r.Name,Account_ID__c, Related_Opportunity1__c,Related_Opportunity1_ID__c,Related_Opportunity2__c,Related_Opportunity2_ID__c,Related_Opportunity3__c,Related_Opportunity3_ID__c,Related_Opportunity4_ID__c,Related_Opportunity5_ID__c, Related_Service1__c,Related_Service1_ID__c from Event__c where Id =: eventCId]; // JSONを戻す jsonResponse = '{"'+ System.Label.OFSErrorStatus +'": "'+ System.Label.OFSErrorSuccess +'", "'+ System.Label.OFSErrorMessage +'":' + JSON.serialize(ec) + '}'; res.responseBody = blob.valueOf(jsonResponse); return; } }