hema priya (.qr) asked in #ApexJun 8, 2016, 7:54 AMHi,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());Show More1 answerSortSort by DateSort by Most HelpfulSort by DateAshish Sharma (Oak tree software PVT ltd)Jun 8, 2016, 8:13 AMDear 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.comShow More
Ashish Sharma (Oak tree software PVT ltd)Jun 8, 2016, 8:13 AMDear 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.comShow More