hema priya (.qr) fragte in #Apex8. Juni 2016, 07:54Hi,Can anyone help pls ...very urgent....for this for "u have committed fund" error,when this method called ,i am getting an error: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out*public static void createInvestmentBooking(String investorId, String bookingOrderId, String loanApplicationId, Decimal investmentAmount, Decimal certificateRate, Decimal serviceRate, String Authorization) { System.debug('Inside createInvestmentBooking method.'); JSONGenerator generator = JSON.createGenerator(true); generator.writeStartObject(); generator.writeStringField('investorId', investorId); generator.writeStringField('bookingOrderId', bookingOrderId); generator.writeStringField('loanApplication', loanApplicationId); generator.writeNumberField('investmentAmount', investmentAmount); generator.writeNumberField('certificateRate', certificateRate); generator.writeNumberField('serviceRate', serviceRate); generator.writeEndObject(); String jsonString = generator.getAsString(); System.debug('jsonString = '+jsonString); HttpRequest request = new HttpRequest(); request.setMethod('POST'); String urlName = URL.getSalesforceBaseUrl().toExternalForm()+'/services/apexrest/peer/v/inves'; System.debug('Booking URL = '+urlName); request.setEndpoint(urlName); request.setHeader('Authorization', Authorization); request.setHeader('Content-Type', 'application/json'); request.setBody(jsonString); Http http = new Http(); response = http.send(request); System.debug('response.getStatus() in createInvestmentBooking = '+response.getStatus()); System.debug('Fulfillment service returned in createInvestmentBooking'+ response.getBody());Mehr anzeigen1 AntwortSortierenNach Datum sortierenNach "Am hilfreichsten" sortierenNach Datum sortierenAshish Sharma (Oak tree software PVT ltd)8. Juni 2016, 08:13Dear gyan,We can not do DML operation and callouts in the same execution context.You can use future method to do callout .Let me know if it helps you .RegardsAshishashish.sharma.devsfdc@gmail.comMehr anzeigenIn Slack antworten
Ashish Sharma (Oak tree software PVT ltd)8. Juni 2016, 08:13Dear gyan,We can not do DML operation and callouts in the same execution context.You can use future method to do callout .Let me know if it helps you .RegardsAshishashish.sharma.devsfdc@gmail.comMehr anzeigen