0

I am invoking a web service callout from a buttons below:

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}
sforce.apex.execute("ClientPortal_lead","Lead_Approval", {email:"{!Lead.Email}"});
window.alert("Data sent to Client Portal" );
window.location.reload();

Class for invoking webservice:

global class ClientPortal_lead{
  WebService  static void Lead_Approval(String email) {
       comAdssClientportalSfapi.ClientServiceSoap11 stub = new comAdssClientportalSfapi.ClientServiceSoap11();
       comAdssClientportalSfapi.ApprovalResponse approveResponse = stub.Approval(email);
       if(!approveResponse.success) {
         throw new LeadConversionException(approveResponse.errorCode);
       }
  }
}

Part of class generated from WSDL class generatedfrom WSDL

public class ClientServiceSoap11 {
        public String endpoint_x = 'https://my.ads-securities.com/client-portal-web/endpoints';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x = 'London_CP';
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://com/adss/clientportal/sfapi', 'comAdssClientportalSfapi'};
        public comAdssClientportalSfapi.RejectionResponse Rejection(String emailAddress) {
            comAdssClientportalSfapi.RejectionRequest request_x = new comAdssClientportalSfapi.RejectionRequest();
            request_x.emailAddress = emailAddress;
            comAdssClientportalSfapi.RejectionResponse response_x;
            Map<String, comAdssClientportalSfapi.RejectionResponse> response_map_x = new Map<String, comAdssClientportalSfapi.RejectionResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://com/adss/clientportal/sfapi',
              'RejectionRequest',
              'http://com/adss/clientportal/sfapi',
              'RejectionResponse',
              'comAdssClientportalSfapi.RejectionResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }

public comAdssClientportalSfapi.ApprovalResponse Approval(String emailAddress) {
            comAdssClientportalSfapi.ApprovalRequest request_x = new comAdssClientportalSfapi.ApprovalRequest();
            request_x.emailAddress = emailAddress;
            comAdssClientportalSfapi.ApprovalResponse response_x;
            Map<String, comAdssClientportalSfapi.ApprovalResponse> response_map_x = new Map<String, comAdssClientportalSfapi.ApprovalResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://com/adss/clientportal/sfapi',
              'ApprovalRequest',
              'http://com/adss/clientportal/sfapi',
              'ApprovalResponse',
              'comAdssClientportalSfapi.ApprovalResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }

Error Mesaage:

{faultcode:'soapenv:Client', faultstring:'System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: WebApplicationException [locale=null, username=null, messages=[An error has occurred], cause=null] faultcode=SOAP-ENV:Server faultactor=

Class.comAdssClientportalSfapi.ClientServiceSoap11.Approval: line 312, column 1 Class.ClientPortal_lead.Lead_Approval: line 11, column 1', }

1

By design SFDC prevents leads from converting if they are in a time-based workflow queue; see

  • Help page
  • A workaround (involving setting a field that terminates the time-based workflow, is given here
  • An Idea to change behavior is here

You'll probably want to detect that the Lead is in a time-based workflow and if Lead Conversion request comes in, force the Lead out of the time-based workflow using the workaround above before submitting the lead Conversion DML (or whatever makes sense for your business process)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.