• borat
  • NEWBIE
  • 5 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

I've run into a problem doing some DML operations and then making a callout, from reading other posts it seems this is "expected" behavior so if anyone has devised a workaround for this I would appreciate any feedback.

 

I've built a VF page that allows a user to save a lead, activity and campaign member record at once. Now I am adding some integration to an ordering system that makes a callout.

 

So this page will save a lead, activity and campaign member. These 3 record inserts are done with Database setpoints because sometimes I insert the lead and then the activity and an exception occurs so I need to roll the transaction back. This all works fine today. The problem that I am running into is that I want to make a callout after these 3 records have been inserted to an ordering system to pass over the Lead information. However, when I attempt to do this I get the following exception :

 

You have uncommitted work pending. Please commit or rollback before calling out

 

The error is rather funny in that salesforce actually doesn't permit you to do a commit. I've searched on the discussion boards and it's suggested to perform the callout first and then save the data afterwards. This doesn't work for 2 reasons, 1. I have to send the Lead Id as part of the transaction and 2. There are 50+ validation rules on the lead, so I have to save it first to ensure the data I am passing to the order system is valid in salesforce.

 

According to what I've read even if I performed a straight insert of these 3 records (and didn't add transactional control), I would still face this problem. It's also been suggested to perform the callout asynchronously, which also will not work for me since I need to wait for the response because the ordering system may reject my transaction and I need to let the end user know.

 

As a side note, I've built (and have it working properly) an ability to click a button from the Lead to send the Order data over a web service call. This of course will work since I am not inserting or updating the lead prior to making the web service call. If anyone has run into a problem like this and has some suggestions, I would appreciate hearing them.

 

Thanks.

  • December 23, 2010
  • Like
  • 0
I am getting the following CalloutException while making a web service call (to .NET) from a @future method.  I have 4 other web service calls that are not having any problems going to the same destination, but this one is. 

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: 
Server was unable to read request. ---> There is an error in XML document (1, 302). --->
Input string was not in a correct format. faultcode=soap:Client faultactor=


Where do I start with this? Can I get more details about the SOAP message. What input string is it referring to?

Thanks.


  • November 03, 2008
  • Like
  • 0

Hi,

 

The Problem I’m having is that the actionSupport function SearchTemplates from my dependent picklist is only running once when I set the value. When I change the values again it does not run my SearchTemplates method. What is happening is that Salesforce is removing the onchange event from my select list after running the action once. I think this maybe a Salesforce bug. Is there a workaround with out changing my data model?

 

Below is a simple code example of what I am trying to do:

 

Visualforce Page

 

<apex:page controller="TemplateCont" >
<apex:form >
<apex:actionRegion >
<apex:inputField value="{!aTemplate.Category__c}"/>
<apex:inputField value="{!aTemplate.Subcategory__c}">
<apex:actionSupport action="{!SearchTemplates}" event="onchange" rerender="matchingTemplates" status="status"/>
</apex:inputField>
<apex:actionStatus startText=" Please wait..." id="status"/>
</apex:actionRegion>

<apex:pageBlock title="Matching Templates" id="matchingTemplates" >

{!MatchingTemplates.size}

</apex:pageBlock>

</apex:form>
</apex:page>

Controller

 

 

public with sharing class TemplateCont {
public Template__c aTemplate{get; set;}
public List<Template__c> matchingTemplates{get; private set;}
public TemplateCont(){ aTemplate = new Template__c(); matchingTemplates = new List<Template__c>(); } public void SearchTemplates(){ matchingTemplates = [SELECT name, category__c, subcategory__c FROM Template__c where category__c=:aTemplate.Category__c and subCategory__c=:aTemplate.Subcategory__c]; } }

 

 

Would be greatfull for any help.

 

Thanks

 

Peter

  • July 30, 2010
  • Like
  • 0
Hi,
 
We have the following visualforce page for new Lead that uses an ActionSupport tag. The functionality is to rerender the Street name field to auto-populate the information based on the postal code information entered. The issue is that the page does a validation before submitting the information to server when user enters the postal code; and the auto-population of street name fails. But if all the madatory information is entered in the VF lead page like (Lead name,Company,Street Number,etc) before the request is submittied with the postal code, then it works fine and populates the rest of the address.
 
We also tried using the "immediate"  attribute of actionSupport tag byt setting it to false like this, but in vain.
 
Please find the attached VF page and Controller. This is the snippet of VF code that is having issues:
 
Code:
            <apex:inputField value="{!lead.Postal_Code__c}" required="true" id="postal_code">           
                 <apex:actionSupport event="onblur"   action="{!addressAutoPop}"  reRender="sname" immediate="true" />
            </apex:inputField>            
             <apex:inputField id="snumber" value="{!lead.Street_Number__c}" required="true"/><b/>
                <apex:inputField id="sname" value="{!lead.Street_Name__c}" />           


 
Appreciate all your valuable feedbacks.

Thanks and regards
  • November 04, 2008
  • Like
  • 0

I have a problem: we should fire a trigger after a file was attached to a custom object. Unfortunately the “after insert” and the “before insert” event on the Attachment object doesn’t get fired (but the after delete event does but we don't need that).

Does anybody has an  idea why? It can't be the code, it's just debugoutput. Or any workaroung?


  • April 17, 2008
  • Like
  • 0