• Jacobus
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 29
    Replies
Hi,
I am trying to find a way to update an existing profile with a new user license type, ex Force.com App Subscription -> Company Community using java script without having to clone. I am unfortunately battling with the code.
Any advise is welcome. See code below.
 
{!REQUIRESCRIPT("/soap/ajax/37.0/connection.js")} 

var all_select = document.getElementsByTagName("userLicense");
var myArray = new Array(500)
for (i = 0; i < all_select.length; i++) {
    
myArray.push(all_select[i].id +".value="+all_select[i].value);
}
for (var i = 0; i < myArray.length; i++) {
    alert("Profile : " + myArray[i]);
}

 
Hi,
I am inserting invoices and invoice line items in bulk using an apex trigger.
There is a few workflow rules on the invoice line item that should run "when a record is created and everytime it is updated".
These workflows does not run after the bulk trigger insert, but it works when I manually update an invoice line item.

Any ideas?

Thank you,
Hi,

Is it possible to copy for ex, Lead History tracked fields to another custom object, ex Booking History via a java custom button?

Thank you,
Jacobus
Hi,

Please help with the following,

I have this @future class that calls a SOAP web service
 
global class UpliftmentRequestFutureWebService {
	
	@future (callout=true)
	public static void sendvehiclerequest (String dateofrequest, 
										   Integer insurer, 
										   String claimno, 
										   String dateofloss, 
										   Integer vehiclecondition, 
										   String customerlastname,
										   String customerfirstname,
										   String vehiclecommercialpassenger, 
										   String vehiclemake,
										   String vehiclemodel, 
										   String vehicleMMCode,
										   String vehicleyear, 
										   String vehicleregistrationno, 
										   String locationname, 
										   String locationcontactperson,
										   String locationcontactno,
										   String locationemailaddress, 
										   String locationstreetaddress, 
										   String locationsuburb, 
										   String locationpostalcode,
										   String locationcity,
										   String locationprovince, 								   
										   String salesforcecapturer, 
										   String salesforcerefno) {									   	
										   		   	
				//GetSalesforceInsurerDDL					   	
				FAMExternalWebservice.SumbitReleaseFromThirdParty stub = new FAMExternalWebservice.SumbitReleaseFromThirdParty();
				FAMExternalWebservice.ArrayOfGenericListItem insurers = stub.GetSalesForceInsurersDDL();
				
				
				system.debug ('List of vehicle insurers :' + insurers);
		

				//FAMExternalWebservice.ArrayOfString vehiclemakes = stub.GetVehicleMakesDDL();
				//system.debug('List of vehicle makes : ' + vehiclemakes);
				//stub.GetVehicleModelsByMakeDDL('');
				FAMExternalWebservice.ThirdPartyReleaseEntry tpr = new FAMExternalWebservice.ThirdPartyReleaseEntry();	

				tpr.DateOfRequest = dateofrequest;
				tpr.Insurer = Insurer;
				tpr.ClaimNumber = claimno;
				tpr.DateOfLoss = dateofloss;
				tpr.VehicleCondition = vehiclecondition;
				tpr.CustomerSurname = customerlastname;
				tpr.CustomerName = customerfirstname;
				tpr.VehicleCommercialPassenger = vehiclecommercialpassenger;				
				tpr.VehicleMake = vehiclemake;
				tpr.VehicleModel = vehiclemodel;
				tpr.VehicleMMCode = vehicleMMCode;
				tpr.VehicleYear = vehicleyear;
				tpr.VehicleRegistrationNumber = vehicleregistrationno;
				tpr.LocationName = locationname;
				tpr.LocationContactPerson = locationcontactperson;
				tpr.LocationContactNumber = locationcontactno;
				tpr.LocationEmailAddress = locationemailaddress;
				tpr.LocationStreetAddress = locationstreetaddress;
				tpr.LocationSuburb = locationsuburb;
				tpr.LocationPostalCode = locationpostalcode;
				tpr.LocationCity = locationcity;
				tpr.LocationProvince = locationprovince;
				tpr.SalesForceCapturer = salesforcecapturer;
				tpr.SalesForceReferenceNumber = salesforcerefno;	 
				
				system.debug('The vehicle salesforce object to be send to the web services : ' + tpr);						

			  	//stub.SumbitReleaseFromThirdParty(tpr);	
										   		
	}
}

This line of code retrieves an array of values
FAMExternalWebservice.ArrayOfGenericListItem insurers = stub.GetSalesForceInsurersDDL();
I was advised to you a wrapper class to add and retrieve values. 
All I want to do is put the results in a list/ map and use the values.
I am not very familiar with wrapper classes. 
Can I use this wrapper class within my @future class?
Please can someone provide sample code where this was done before?

Thanks,
 
Hi,

I am trying to read the array list of a web service response.
Lets say this is my web service declaration.
FAMExternalWebservice.SumbitReleaseFromThirdParty stub = new FAMExternalWebservice.SumbitReleaseFromThirdParty();
and this is to call the web service method generated from the wsdl2apex
FAMExternalWebservice.ArrayOfGenericListItem insurers = stub.GetSalesForceInsurersDDL();
This would return an arraylist of insurers.
I want to now put this in a map or list which I can read from?

Thanks 

 
Hi,

When I deploy my 2 web service mock classes to production, it fails with "File name mismatch with class name"?

Here are my 2 mock test classes :

@isTest(SeeAllData=true)

global class WebServiceMockImpl implements WebServiceMock {
   global void doInvoke(
           Object stub,
           Object request,
           Map<String, Object> response,
           String endpoint,
           String soapAction,
           String requestName,
           String responseNS,
           String responseName,
           String responseType) {
                 
              FAMExternalWebservice.SumbitReleaseFromThirdPartyResponse_element respElement = new FAMExternalWebservice.SumbitReleaseFromThirdPartyResponse_element();
              respElement.SumbitReleaseFromThirdPartyResult = 'Mock response';
           response.put('response_x', respElement); 
             
           }  
}

@isTest

private class UpliftmentRequestWSDLTest {

    @isTest static void testWSDL() {      
                  

        // This causes a fake response to be generated
        Test.setMock(WebServiceMock.class, new WebServiceMockImpl ());
        
        FAMExternalWebservice.ThirdPartyReleaseEntry tpr = new FAMExternalWebservice.ThirdPartyReleaseEntry();    
        FAMExternalWebservice.SumbitReleaseFromThirdParty stub = new FAMExternalWebservice.SumbitReleaseFromThirdParty();    
        
                tpr.DateOfRequest = 'system.now()';
                tpr.Insurer = 1;
                tpr.ClaimNumber = 'claimno';
                tpr.DateOfLoss = 'system.now()';
                tpr.VehicleCondition = 1;
                tpr.CustomerSurname = 'customerlastname';
                tpr.CustomerName = 'customerfirstname';
                tpr.VehicleCommercialPassenger = 'vehiclecommercialpassenger';                
                tpr.VehicleMake = 'vehiclemake';
                tpr.VehicleModel = 'vehiclemodel';
                tpr.VehicleMMCode = 'vehicleMMCode';
                tpr.VehicleYear = 'vehicleyear';
                tpr.VehicleRegistrationNumber = 'vehicleregistrationno';
                tpr.LocationName = 'locationname';
                tpr.LocationContactPerson = 'locationcontactperson';
                tpr.LocationContactNumber = 'locationcontactno';
                tpr.LocationEmailAddress = 'locationemailaddress';
                tpr.LocationStreetAddress = 'locationstreetaddress';
                tpr.LocationSuburb = 'locationsuburb';
                tpr.LocationPostalCode = 'locationpostalcode';
                tpr.LocationCity = 'locationcity';
                tpr.LocationProvince = 'locationprovince';
                tpr.SalesForceCapturer = 'salesforcecapturer';
                tpr.SalesForceReferenceNumber = 'salesforcerefno';    


        // Call the method that invokes a callout
        Test.startTest() ;
        String output = stub.SumbitReleaseFromThirdParty(tpr);
        Test.stopTest();
         
        // Verify that a fake result is returned
        System.assertEquals('Mock response', output);

    }
}
Hi,

I need urgent help with test class a SOAP web service!

Followed this article - https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex_testing.htm on how to create mock responses.

My test class however still fails.

Appreciate any help!

Thank you,



 
Hi,

I have the below trigger that makes an @future call to an apex class.
This line  UpliftmentRequestFutureWebService.sendvehiclerequest makes the call.

I have tried various things in my test class such as test.startTest() and test.stopTest() and still fails with a "Methods defined as TestMethod do not support Web service callouts, test skipped".

Any guidance is very welcome on this!


trigger UpliftmentRequestCreate on Vehicle__c (after insert) {
    
    DateTime createdate = system.now();
    String dateofrequest;
    Integer insurer;
    String claimno;
    DateTime dateoflossconvert;
    String dateofloss;
    Integer vehiclecondition;
    String customerfirstname;
    String customerlastname;
    String vehiclemake;
    String vehiclemodel;
    String vehiclemmcode;
    String vehicleyear;
    String vehicleregistrationno;
    String vehiclecommercialpassenger;
    String locationname;
    String locationcontactperson;
    String locationcontactno;
    String locationemailaddress;
    String locationstreetaddress;
    String locationsuburb;
    String locationpostalcode;
    String locationcity;
    String locationprovince;
    String createuserfirstname;
    String createuserlastname;
    String salesforcecapturer;
    String salesforcerefno;
    String refno;
    id customer;
    id vehicleid;
        
    User currentuser=[Select FirstName, LastName from User Where Id =: UserInfo.getUserId() LIMIT 1];
    createuserfirstname = currentuser.FirstName;
    createuserlastname = currentuser.LastName;
    salesforcecapturer = createuserfirstname+' '+createuserlastname;
    system.debug ('Current User : ' + createuserfirstname +' '+createuserlastname);

    for (Vehicle__c v : Trigger.new) {
        vehicleid = v.id;
        customer = v.Customer__c;
        //
        //DateOfRequest    
        if (v.Insurance_Group__c == 'AFI' || v.Insurance_Group__c == 'Zurich'){
            
        dateofrequest = createdate.format('yyyy/MM/dd HH:mm:ss');
        system.debug ('Date of Request New : ' + dateofrequest);                               
        //
        //Insurer
        if (v.Insurance_Group__c != null){
                if (v.Insurance_Group__c == 'AFI'){
                    insurer = 26;
                }
                
                else if (v.Insurance_Group__c == 'Zurich'){
                    insurer = 347;
                }
                else{
                    insurer = 1;
                }
        }
        else{
                insurer = 0;
        }
        system.debug('Insurer : ' + insurer);
        //
        //ClaimNumber                
        if (v.PolicyNo__c != null){
                claimno = v.PolicyNo__c;
        }
        else{
                claimno = 'Not Specified';
        }
        system.debug('Claim No : ' + claimno);
        //
        //DateOfLoss    
        if (v.Date_Of_Loss__c != null){
                
                dateoflossconvert = DateTime.newInstance(v.Date_Of_Loss__c.year(), v.Date_Of_Loss__c.month(), v.Date_Of_Loss__c.day());
                dateofloss = dateoflossconvert.format('yyyy/MM/dd HH:mm:ss');
        }
        else{
                dateofloss = null;
        }        
        system.debug('Date of Loss : ' + dateofloss);
        //
        //VehicleCondition        
        if(v.Vehicle_Condition__c != null){
                if (v.Vehicle_Condition__c == 'Repairable'){
                    vehiclecondition = 1;
                }
                else if (v.Vehicle_Condition__c == 'WriteOff'){
                    vehiclecondition = 2;
                }
                else{
                    vehiclecondition = 0;
                }
        }
        else{
                vehiclecondition = 0;
        }
        system.debug('Vehicle Condition : ' + vehiclecondition);
        //
        //VehicleCommercialPassenger
        if(v.Vehicle_Commercial_Passenger__c != null){
                vehiclecommercialpassenger = v.Vehicle_Commercial_Passenger__c;
        }
        else{
                vehiclecommercialpassenger = 'Not Specified';
        }
        system.debug ('Vehicle Commercial Passenger : ' + vehiclecommercialpassenger);
        //
        //VehicleMake
        if(v.Make__c != null){
            vehiclemake = v.Make__c;
        }    
        else{
            vehiclemake = 'Not Specified';
        }
        system.debug ('Vehicle Make : ' + vehiclemake);
        //
        //VehicleModel
        if (v.Model__c != null){
                vehiclemodel = v.Model__c;
        }        
        else{
                vehiclemodel = 'Not Specified';
        }
        system.debug('Vehicle Model : ' + vehiclemodel);
        //
        //VehicleMMCode
        if (v.MMCode__c != null){
            vehiclemmcode = v.MMCode__c;
        }
        else{
            vehiclemmcode = 'Not Specified';
        }
        system.debug ('Vehicle MMCode : ' + vehiclemmcode);
        //
        //VehicleYear
        if (v.Reg_Year__c != null){
                vehicleyear = v.Reg_Year__c;    
        }
        else{
                vehicleyear = 'Not Specified';
        }
        system.debug('Vehicle Year : ' + vehicleyear);
        //
        //VehicleRegistrationNumber
        if(v.RegNo__c != null){
                vehicleregistrationno = v.RegNo__c;    
        }
        else{
                vehicleregistrationno = 'Not Specified';
        }
        system.debug('Vehicle Registration No : ' + vehicleregistrationno);
        //
        //LocationName
        if (v.MBR_Name__c != null){
                locationname = v.MBR_Name__c;    
        }
        else {
                locationname = 'Not Specified';
        }
        system.debug('Location Name : ' + locationname);
        //
        //LocationContactPerson    
        if (v.MBR_Contact_Person__c != null){
                locationcontactperson = v.MBR_Contact_Person__c;    
        }
        else{
                locationcontactperson = 'Not Specified';
        }
        system.debug('Location Contact Person : ' + locationcontactperson);
        //
        //LocationEmailAddress    
        if (v.MBR_Email__c != null) {
                locationemailaddress = v.MBR_Email__c;    
        }
        else {
                locationemailaddress = 'Not Specified';
        }
        system.debug('Location Email Address : ' + locationemailaddress);
        //
        //LocationStreetAddress    
        if (v.MBR_Address__c != null){
                locationstreetaddress = v.MBR_Address__c;    
        }
        else {
                locationstreetaddress = 'Not Specified';
        }
        system.debug('Location Address : ' + locationstreetaddress);
        //
        //LocationSuburb    
        if (v.MBR_Suburb__c != null){
                locationsuburb = v.MBR_Suburb__c;    
        }
        else{
                locationsuburb = 'Not Specified';
        }
        system.debug('Location Suburb : ' + locationsuburb);
        //
        //LocationPostalCode
        if (v.MBR_Postal_Code__c != null){
            locationpostalcode = v.MBR_Postal_Code__c;
        }
        else{
            locationpostalcode = '';
        }
        //
        //LocationCity
        if (v.MBR_City__c != null){
            locationcity = v.MBR_City__c;
        }
        else{
            locationcity = '';
        }
        //
        //LocationProvince    
        if (v.MBR_Province__c != null){
                locationprovince = v.MBR_Province__c;    
        }
        else {
                locationprovince = 'Not Specified';
        }        
        system.debug('Location Province : ' + locationprovince);    
        //
        //LocationContactNumber    
        if (v.MBR_Contact_No__c != null){
                locationcontactno = v.MBR_Contact_No__c;
        }
        else{
                locationcontactno = 'Not Specified';
        }
        system.debug('Location Province : ' + locationcontactno);
        //
        //SalesforceReferenceNumber    
        if (v.StockNo__c != null){
                salesforcerefno = v.StockNo__c;    
        }
        else{
                salesforcerefno = 'Not Specified';
        }
        //
        }    
    }
    
    for (Account a : [Select Id, FirstName, LastName from Account where Id =: customer LIMIT 1]) {
        
        if (a.FirstName != null){
            customerfirstname = a.FirstName;    
        }
        else {
            customerfirstname = 'Not Specified';
        }
        
        if (a.LastName != null){
            customerlastname = a.LastName;    
        }
        else{
            customerlastname = 'Not Specified';
        }
        system.debug('Customer Name : ' + customerfirstname +' '+ customerlastname);
    }
    
        
    for (Vehicle__c v : Trigger.new) {
        
        if (v.Insurance_Group__c == 'AFI' || v.Insurance_Group__c == 'Zurich'){ 
    
                try {
                
                system.debug ('About to call the web service class');
                UpliftmentRequestFutureWebService.sendvehiclerequest(dateofrequest, insurer, claimno, dateofloss, vehiclecondition, customerlastname, customerfirstname, vehiclecommercialpassenger, vehiclemake, vehiclemodel, 
                                                                     vehicleMMCode, vehicleyear, vehicleregistrationno, locationname, locationcontactperson, locationcontactno, locationemailaddress, locationstreetaddress, 
                                                                     locationsuburb, locationpostalcode, locationcity, locationprovince, salesforcecapturer, salesforcerefno);        
                }
                    catch(DmlException e){
                    system.debug('The following exception has occured: ' + e.getMessage());
                }
        }
    }            
}
Hi everyone,

I am trying to call a method on an external web service from my apex class and passing a few parameters
The values is passed from a trigger to the class which is successfully received.
My issue is now to pass those values to the external web service method.

Please see my code below and let me know what I am doing wrong here.
Thanks



public with sharing class UpliftmentRequestWebService {
    
    @future (callout=true)
    public static void sendvehiclerequest(String dateofrequest, String claimno, String dateoflossformat, String vehiclemodel, String vehicleyear, String vehicleregistrationno, String locationname, String locationcontactperson,
                                         String locationemailaddress, String locationstreetaddress, String locationsuburb, String locationprovince, String customerfirstname, String customerlastname,
                                         String createuserfirstname, String createuserlastname){
                                             
        system.debug('Date of Request : ' + dateofrequest);
        system.debug('Claim No : ' + claimno);
        system.debug('Date of Loss : ' + dateoflossformat);
        system.debug('Vehicle Model : ' + vehiclemodel);
        system.debug('Vehicle Year : ' + vehicleyear);
        system.debug('Vehicle Registration No : ' + vehicleregistrationno);
        system.debug('Location Name : ' + locationname);
        system.debug('Location Contact Person : ' + locationcontactperson);
        system.debug('Location Email Address : ' + locationemailaddress);
        system.debug('Location Address : ' + locationstreetaddress);
        system.debug('Location Suburb : ' + locationsuburb);
        system.debug('Location Province : ' + locationprovince);
        system.debug('Customer Name : ' + customerfirstname+' '+customerlastname);
        system.debug('Create User : ' + createuserfirstname+' '+createuserlastname);
                                             
                                             
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        
        req.setEndpoint('http://releasestest.firstmanagement.co.za/FAMExternalPartyWS.asmx');
        req.setCompressed(true); // otherwise we hit a limit of 32000
        req.setMethod('POST');
        req.setBody('Date of Request='+EncodingUtil.urlEncode(dateofrequest, 'UTF-8')+
                    '&Claim No='+EncodingUtil.urlEncode(claimno, 'UTF-8')+
                    '&Date of Loss='+EncodingUtil.urlEncode(dateoflossformat, 'UTF-8')+
                    '&Vehicle Model='+EncodingUtil.urlEncode(vehiclemodel, 'UTF-8')+
                    '&Vehicle Year='+EncodingUtil.urlEncode(vehicleyear, 'UTF-8')+
                    '&Vehicle Registration No='+EncodingUtil.urlEncode(vehicleregistrationno, 'UTF-8')+
                    '&Location Name='+EncodingUtil.urlEncode(locationname, 'UTF-8')+
                    '&Location Contact Person='+EncodingUtil.urlEncode(locationcontactperson, 'UTF-8')+
                    '&Location Email Address='+EncodingUtil.urlEncode(locationemailaddress, 'UTF-8')+
                    '&Location Address='+EncodingUtil.urlEncode(locationstreetaddress, 'UTF-8')+
                    '&Location Suburb='+EncodingUtil.urlEncode(locationsuburb, 'UTF-8')+
                    '&Location Province='+EncodingUtil.urlEncode(locationprovince, 'UTF-8')+
                    '&Customer First Name='+EncodingUtil.urlEncode(customerfirstname, 'UTF-8')+
                    '&Customer Last Name='+EncodingUtil.urlEncode(customerlastname, 'UTF-8')+
                    '&Create User First Name='+EncodingUtil.urlEncode(createuserfirstname, 'UTF-8')+
                    '&Create User Last Name='+EncodingUtil.urlEncode(createuserlastname, 'UTF-8'));                 
        
        
        
        try {
            res = http.send(req);
            res.getBody();            
        }
        catch(System.calloutexception e){
            system.debug('Callout error has occured : ' + e);
            system.debug('RESPONSE :' + res.toString());
            system.debug('STATUS : ' + res.getStatus());
              system.debug('STATUS_CODE : ' + res.getStatusCode());
        }    
    }
}

Hi,

 

I am new to outbound message workflow and would like to know how one would call a method when specifying your endpoint url.

 

 

I came accross this article - http://developer.force.com/cookbook/recipe/sending-outbound-messages-with-workflow and noticed that they call an external webservice as follows - http://localhost/salesforce/"MyWebService".asmx.

It does not specify a method to use within your web service.

 

Thank you,

Hi,
I am inserting invoices and invoice line items in bulk using an apex trigger.
There is a few workflow rules on the invoice line item that should run "when a record is created and everytime it is updated".
These workflows does not run after the bulk trigger insert, but it works when I manually update an invoice line item.

Any ideas?

Thank you,
Hi,

When I deploy my 2 web service mock classes to production, it fails with "File name mismatch with class name"?

Here are my 2 mock test classes :

@isTest(SeeAllData=true)

global class WebServiceMockImpl implements WebServiceMock {
   global void doInvoke(
           Object stub,
           Object request,
           Map<String, Object> response,
           String endpoint,
           String soapAction,
           String requestName,
           String responseNS,
           String responseName,
           String responseType) {
                 
              FAMExternalWebservice.SumbitReleaseFromThirdPartyResponse_element respElement = new FAMExternalWebservice.SumbitReleaseFromThirdPartyResponse_element();
              respElement.SumbitReleaseFromThirdPartyResult = 'Mock response';
           response.put('response_x', respElement); 
             
           }  
}

@isTest

private class UpliftmentRequestWSDLTest {

    @isTest static void testWSDL() {      
                  

        // This causes a fake response to be generated
        Test.setMock(WebServiceMock.class, new WebServiceMockImpl ());
        
        FAMExternalWebservice.ThirdPartyReleaseEntry tpr = new FAMExternalWebservice.ThirdPartyReleaseEntry();    
        FAMExternalWebservice.SumbitReleaseFromThirdParty stub = new FAMExternalWebservice.SumbitReleaseFromThirdParty();    
        
                tpr.DateOfRequest = 'system.now()';
                tpr.Insurer = 1;
                tpr.ClaimNumber = 'claimno';
                tpr.DateOfLoss = 'system.now()';
                tpr.VehicleCondition = 1;
                tpr.CustomerSurname = 'customerlastname';
                tpr.CustomerName = 'customerfirstname';
                tpr.VehicleCommercialPassenger = 'vehiclecommercialpassenger';                
                tpr.VehicleMake = 'vehiclemake';
                tpr.VehicleModel = 'vehiclemodel';
                tpr.VehicleMMCode = 'vehicleMMCode';
                tpr.VehicleYear = 'vehicleyear';
                tpr.VehicleRegistrationNumber = 'vehicleregistrationno';
                tpr.LocationName = 'locationname';
                tpr.LocationContactPerson = 'locationcontactperson';
                tpr.LocationContactNumber = 'locationcontactno';
                tpr.LocationEmailAddress = 'locationemailaddress';
                tpr.LocationStreetAddress = 'locationstreetaddress';
                tpr.LocationSuburb = 'locationsuburb';
                tpr.LocationPostalCode = 'locationpostalcode';
                tpr.LocationCity = 'locationcity';
                tpr.LocationProvince = 'locationprovince';
                tpr.SalesForceCapturer = 'salesforcecapturer';
                tpr.SalesForceReferenceNumber = 'salesforcerefno';    


        // Call the method that invokes a callout
        Test.startTest() ;
        String output = stub.SumbitReleaseFromThirdParty(tpr);
        Test.stopTest();
         
        // Verify that a fake result is returned
        System.assertEquals('Mock response', output);

    }
}
Hi,

I need urgent help with test class a SOAP web service!

Followed this article - https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex_testing.htm on how to create mock responses.

My test class however still fails.

Appreciate any help!

Thank you,



 
Hi,

I have the below trigger that makes an @future call to an apex class.
This line  UpliftmentRequestFutureWebService.sendvehiclerequest makes the call.

I have tried various things in my test class such as test.startTest() and test.stopTest() and still fails with a "Methods defined as TestMethod do not support Web service callouts, test skipped".

Any guidance is very welcome on this!


trigger UpliftmentRequestCreate on Vehicle__c (after insert) {
    
    DateTime createdate = system.now();
    String dateofrequest;
    Integer insurer;
    String claimno;
    DateTime dateoflossconvert;
    String dateofloss;
    Integer vehiclecondition;
    String customerfirstname;
    String customerlastname;
    String vehiclemake;
    String vehiclemodel;
    String vehiclemmcode;
    String vehicleyear;
    String vehicleregistrationno;
    String vehiclecommercialpassenger;
    String locationname;
    String locationcontactperson;
    String locationcontactno;
    String locationemailaddress;
    String locationstreetaddress;
    String locationsuburb;
    String locationpostalcode;
    String locationcity;
    String locationprovince;
    String createuserfirstname;
    String createuserlastname;
    String salesforcecapturer;
    String salesforcerefno;
    String refno;
    id customer;
    id vehicleid;
        
    User currentuser=[Select FirstName, LastName from User Where Id =: UserInfo.getUserId() LIMIT 1];
    createuserfirstname = currentuser.FirstName;
    createuserlastname = currentuser.LastName;
    salesforcecapturer = createuserfirstname+' '+createuserlastname;
    system.debug ('Current User : ' + createuserfirstname +' '+createuserlastname);

    for (Vehicle__c v : Trigger.new) {
        vehicleid = v.id;
        customer = v.Customer__c;
        //
        //DateOfRequest    
        if (v.Insurance_Group__c == 'AFI' || v.Insurance_Group__c == 'Zurich'){
            
        dateofrequest = createdate.format('yyyy/MM/dd HH:mm:ss');
        system.debug ('Date of Request New : ' + dateofrequest);                               
        //
        //Insurer
        if (v.Insurance_Group__c != null){
                if (v.Insurance_Group__c == 'AFI'){
                    insurer = 26;
                }
                
                else if (v.Insurance_Group__c == 'Zurich'){
                    insurer = 347;
                }
                else{
                    insurer = 1;
                }
        }
        else{
                insurer = 0;
        }
        system.debug('Insurer : ' + insurer);
        //
        //ClaimNumber                
        if (v.PolicyNo__c != null){
                claimno = v.PolicyNo__c;
        }
        else{
                claimno = 'Not Specified';
        }
        system.debug('Claim No : ' + claimno);
        //
        //DateOfLoss    
        if (v.Date_Of_Loss__c != null){
                
                dateoflossconvert = DateTime.newInstance(v.Date_Of_Loss__c.year(), v.Date_Of_Loss__c.month(), v.Date_Of_Loss__c.day());
                dateofloss = dateoflossconvert.format('yyyy/MM/dd HH:mm:ss');
        }
        else{
                dateofloss = null;
        }        
        system.debug('Date of Loss : ' + dateofloss);
        //
        //VehicleCondition        
        if(v.Vehicle_Condition__c != null){
                if (v.Vehicle_Condition__c == 'Repairable'){
                    vehiclecondition = 1;
                }
                else if (v.Vehicle_Condition__c == 'WriteOff'){
                    vehiclecondition = 2;
                }
                else{
                    vehiclecondition = 0;
                }
        }
        else{
                vehiclecondition = 0;
        }
        system.debug('Vehicle Condition : ' + vehiclecondition);
        //
        //VehicleCommercialPassenger
        if(v.Vehicle_Commercial_Passenger__c != null){
                vehiclecommercialpassenger = v.Vehicle_Commercial_Passenger__c;
        }
        else{
                vehiclecommercialpassenger = 'Not Specified';
        }
        system.debug ('Vehicle Commercial Passenger : ' + vehiclecommercialpassenger);
        //
        //VehicleMake
        if(v.Make__c != null){
            vehiclemake = v.Make__c;
        }    
        else{
            vehiclemake = 'Not Specified';
        }
        system.debug ('Vehicle Make : ' + vehiclemake);
        //
        //VehicleModel
        if (v.Model__c != null){
                vehiclemodel = v.Model__c;
        }        
        else{
                vehiclemodel = 'Not Specified';
        }
        system.debug('Vehicle Model : ' + vehiclemodel);
        //
        //VehicleMMCode
        if (v.MMCode__c != null){
            vehiclemmcode = v.MMCode__c;
        }
        else{
            vehiclemmcode = 'Not Specified';
        }
        system.debug ('Vehicle MMCode : ' + vehiclemmcode);
        //
        //VehicleYear
        if (v.Reg_Year__c != null){
                vehicleyear = v.Reg_Year__c;    
        }
        else{
                vehicleyear = 'Not Specified';
        }
        system.debug('Vehicle Year : ' + vehicleyear);
        //
        //VehicleRegistrationNumber
        if(v.RegNo__c != null){
                vehicleregistrationno = v.RegNo__c;    
        }
        else{
                vehicleregistrationno = 'Not Specified';
        }
        system.debug('Vehicle Registration No : ' + vehicleregistrationno);
        //
        //LocationName
        if (v.MBR_Name__c != null){
                locationname = v.MBR_Name__c;    
        }
        else {
                locationname = 'Not Specified';
        }
        system.debug('Location Name : ' + locationname);
        //
        //LocationContactPerson    
        if (v.MBR_Contact_Person__c != null){
                locationcontactperson = v.MBR_Contact_Person__c;    
        }
        else{
                locationcontactperson = 'Not Specified';
        }
        system.debug('Location Contact Person : ' + locationcontactperson);
        //
        //LocationEmailAddress    
        if (v.MBR_Email__c != null) {
                locationemailaddress = v.MBR_Email__c;    
        }
        else {
                locationemailaddress = 'Not Specified';
        }
        system.debug('Location Email Address : ' + locationemailaddress);
        //
        //LocationStreetAddress    
        if (v.MBR_Address__c != null){
                locationstreetaddress = v.MBR_Address__c;    
        }
        else {
                locationstreetaddress = 'Not Specified';
        }
        system.debug('Location Address : ' + locationstreetaddress);
        //
        //LocationSuburb    
        if (v.MBR_Suburb__c != null){
                locationsuburb = v.MBR_Suburb__c;    
        }
        else{
                locationsuburb = 'Not Specified';
        }
        system.debug('Location Suburb : ' + locationsuburb);
        //
        //LocationPostalCode
        if (v.MBR_Postal_Code__c != null){
            locationpostalcode = v.MBR_Postal_Code__c;
        }
        else{
            locationpostalcode = '';
        }
        //
        //LocationCity
        if (v.MBR_City__c != null){
            locationcity = v.MBR_City__c;
        }
        else{
            locationcity = '';
        }
        //
        //LocationProvince    
        if (v.MBR_Province__c != null){
                locationprovince = v.MBR_Province__c;    
        }
        else {
                locationprovince = 'Not Specified';
        }        
        system.debug('Location Province : ' + locationprovince);    
        //
        //LocationContactNumber    
        if (v.MBR_Contact_No__c != null){
                locationcontactno = v.MBR_Contact_No__c;
        }
        else{
                locationcontactno = 'Not Specified';
        }
        system.debug('Location Province : ' + locationcontactno);
        //
        //SalesforceReferenceNumber    
        if (v.StockNo__c != null){
                salesforcerefno = v.StockNo__c;    
        }
        else{
                salesforcerefno = 'Not Specified';
        }
        //
        }    
    }
    
    for (Account a : [Select Id, FirstName, LastName from Account where Id =: customer LIMIT 1]) {
        
        if (a.FirstName != null){
            customerfirstname = a.FirstName;    
        }
        else {
            customerfirstname = 'Not Specified';
        }
        
        if (a.LastName != null){
            customerlastname = a.LastName;    
        }
        else{
            customerlastname = 'Not Specified';
        }
        system.debug('Customer Name : ' + customerfirstname +' '+ customerlastname);
    }
    
        
    for (Vehicle__c v : Trigger.new) {
        
        if (v.Insurance_Group__c == 'AFI' || v.Insurance_Group__c == 'Zurich'){ 
    
                try {
                
                system.debug ('About to call the web service class');
                UpliftmentRequestFutureWebService.sendvehiclerequest(dateofrequest, insurer, claimno, dateofloss, vehiclecondition, customerlastname, customerfirstname, vehiclecommercialpassenger, vehiclemake, vehiclemodel, 
                                                                     vehicleMMCode, vehicleyear, vehicleregistrationno, locationname, locationcontactperson, locationcontactno, locationemailaddress, locationstreetaddress, 
                                                                     locationsuburb, locationpostalcode, locationcity, locationprovince, salesforcecapturer, salesforcerefno);        
                }
                    catch(DmlException e){
                    system.debug('The following exception has occured: ' + e.getMessage());
                }
        }
    }            
}
Hi everyone,

I am trying to call a method on an external web service from my apex class and passing a few parameters
The values is passed from a trigger to the class which is successfully received.
My issue is now to pass those values to the external web service method.

Please see my code below and let me know what I am doing wrong here.
Thanks



public with sharing class UpliftmentRequestWebService {
    
    @future (callout=true)
    public static void sendvehiclerequest(String dateofrequest, String claimno, String dateoflossformat, String vehiclemodel, String vehicleyear, String vehicleregistrationno, String locationname, String locationcontactperson,
                                         String locationemailaddress, String locationstreetaddress, String locationsuburb, String locationprovince, String customerfirstname, String customerlastname,
                                         String createuserfirstname, String createuserlastname){
                                             
        system.debug('Date of Request : ' + dateofrequest);
        system.debug('Claim No : ' + claimno);
        system.debug('Date of Loss : ' + dateoflossformat);
        system.debug('Vehicle Model : ' + vehiclemodel);
        system.debug('Vehicle Year : ' + vehicleyear);
        system.debug('Vehicle Registration No : ' + vehicleregistrationno);
        system.debug('Location Name : ' + locationname);
        system.debug('Location Contact Person : ' + locationcontactperson);
        system.debug('Location Email Address : ' + locationemailaddress);
        system.debug('Location Address : ' + locationstreetaddress);
        system.debug('Location Suburb : ' + locationsuburb);
        system.debug('Location Province : ' + locationprovince);
        system.debug('Customer Name : ' + customerfirstname+' '+customerlastname);
        system.debug('Create User : ' + createuserfirstname+' '+createuserlastname);
                                             
                                             
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        
        req.setEndpoint('http://releasestest.firstmanagement.co.za/FAMExternalPartyWS.asmx');
        req.setCompressed(true); // otherwise we hit a limit of 32000
        req.setMethod('POST');
        req.setBody('Date of Request='+EncodingUtil.urlEncode(dateofrequest, 'UTF-8')+
                    '&Claim No='+EncodingUtil.urlEncode(claimno, 'UTF-8')+
                    '&Date of Loss='+EncodingUtil.urlEncode(dateoflossformat, 'UTF-8')+
                    '&Vehicle Model='+EncodingUtil.urlEncode(vehiclemodel, 'UTF-8')+
                    '&Vehicle Year='+EncodingUtil.urlEncode(vehicleyear, 'UTF-8')+
                    '&Vehicle Registration No='+EncodingUtil.urlEncode(vehicleregistrationno, 'UTF-8')+
                    '&Location Name='+EncodingUtil.urlEncode(locationname, 'UTF-8')+
                    '&Location Contact Person='+EncodingUtil.urlEncode(locationcontactperson, 'UTF-8')+
                    '&Location Email Address='+EncodingUtil.urlEncode(locationemailaddress, 'UTF-8')+
                    '&Location Address='+EncodingUtil.urlEncode(locationstreetaddress, 'UTF-8')+
                    '&Location Suburb='+EncodingUtil.urlEncode(locationsuburb, 'UTF-8')+
                    '&Location Province='+EncodingUtil.urlEncode(locationprovince, 'UTF-8')+
                    '&Customer First Name='+EncodingUtil.urlEncode(customerfirstname, 'UTF-8')+
                    '&Customer Last Name='+EncodingUtil.urlEncode(customerlastname, 'UTF-8')+
                    '&Create User First Name='+EncodingUtil.urlEncode(createuserfirstname, 'UTF-8')+
                    '&Create User Last Name='+EncodingUtil.urlEncode(createuserlastname, 'UTF-8'));                 
        
        
        
        try {
            res = http.send(req);
            res.getBody();            
        }
        catch(System.calloutexception e){
            system.debug('Callout error has occured : ' + e);
            system.debug('RESPONSE :' + res.toString());
            system.debug('STATUS : ' + res.getStatus());
              system.debug('STATUS_CODE : ' + res.getStatusCode());
        }    
    }
}