You need to sign in to do that
Don't have an account?
Avi Rai 8
Data Integration Specialist error #challenge 7
I am having an error in 7 challenge.
My Trigger code is:
trigger ProjectTrigger on Project__c (after update) {
//after trigger to fire if the Status is set to Billable.
If (Trigger.isAfter && Trigger.isUpdate){
for(Project__c proj : Trigger.new){
if(proj.Status__c.equals('Billable')){
BillingCalloutService.callBillingService(proj.ProjectRef__c, proj.Billable_Amount__c);
}
}
}
}
My BillingCalloutService class is as follows:
public class BillingCalloutService {
//method to run asynchronously or in future, invoked from trigger.
@future(callout=true)
public static void callBillingService(String projectRef, Decimal billingAmount){
//gets the custom settings values.
ServiceCredentials__c servCred = ServiceCredentials__c.getValues('BillingServiceCredential');
//creating the project object to be passed in argument below.
BillingServiceProxy.project project = new BillingServiceProxy.project();
project.username = servCred.Username__c;
project.password = servCred.Password__c;
project.projectid = projectRef;
project.billAmount = billingAmount;
//synchronous call to the Billing Invoice system.
BillingServiceProxy.InvoicesPortSoap11 invoiceCall = new BillingServiceProxy.InvoicesPortSoap11();
//getting the response back from billing system.
String response = invoiceCall.billProject(project);
//if the response is ok, need to change the billing status to 'Billed'
List<Project__c> proj;
if (response != null && response.equalsIgnoreCase('OK')){
proj = [SELECT Status__c FROM Project__c WHERE ProjectRef__c =: projectRef];
if(proj.size() > 0){
proj[0].Status__c = 'Billed';
}
update proj;
}
}
}
BillingServiceProxy:
//Generated by wsdl2apex
public class BillingServiceProxy {
public class billProjectRequest_element {
public BillingServiceProxy.project project;
private String[] project_type_info = new String[]{'project','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
private String[] field_order_type_info = new String[]{'project'};
}
public class project {
public String username;
public String password;
public String projectid;
public Double billAmount;
private String[] username_type_info = new String[]{'username','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] password_type_info = new String[]{'password','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] projectid_type_info = new String[]{'projectid','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] billAmount_type_info = new String[]{'billAmount','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
private String[] field_order_type_info = new String[]{'username','password','projectid','billAmount'};
}
public class billProjectResponse_element {
public String status;
private String[] status_type_info = new String[]{'status','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
private String[] field_order_type_info = new String[]{'status'};
}
public class InvoicesPortSoap11 {
public String endpoint_x = 'http://sb-integration-bs.herokuapp.com:80/ws';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
private String[] ns_map_type_info = new String[]{'http://salesforce.com/th/invoice-web-service', 'BillingServiceProxy'};
public String billProject(BillingServiceProxy.project project) {
BillingServiceProxy.billProjectRequest_element request_x = new BillingServiceProxy.billProjectRequest_element();
request_x.project = project;
BillingServiceProxy.billProjectResponse_element response_x;
Map<String, BillingServiceProxy.billProjectResponse_element> response_map_x = new Map<String, BillingServiceProxy.billProjectResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://salesforce.com/th/invoice-web-service',
'billProjectRequest',
'http://salesforce.com/th/invoice-web-service',
'billProjectResponse',
'BillingServiceProxy.billProjectResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.status;
}
}
}
Please help me to kick off this error.Thanks in advance
My Trigger code is:
trigger ProjectTrigger on Project__c (after update) {
//after trigger to fire if the Status is set to Billable.
If (Trigger.isAfter && Trigger.isUpdate){
for(Project__c proj : Trigger.new){
if(proj.Status__c.equals('Billable')){
BillingCalloutService.callBillingService(proj.ProjectRef__c, proj.Billable_Amount__c);
}
}
}
}
My BillingCalloutService class is as follows:
public class BillingCalloutService {
//method to run asynchronously or in future, invoked from trigger.
@future(callout=true)
public static void callBillingService(String projectRef, Decimal billingAmount){
//gets the custom settings values.
ServiceCredentials__c servCred = ServiceCredentials__c.getValues('BillingServiceCredential');
//creating the project object to be passed in argument below.
BillingServiceProxy.project project = new BillingServiceProxy.project();
project.username = servCred.Username__c;
project.password = servCred.Password__c;
project.projectid = projectRef;
project.billAmount = billingAmount;
//synchronous call to the Billing Invoice system.
BillingServiceProxy.InvoicesPortSoap11 invoiceCall = new BillingServiceProxy.InvoicesPortSoap11();
//getting the response back from billing system.
String response = invoiceCall.billProject(project);
//if the response is ok, need to change the billing status to 'Billed'
List<Project__c> proj;
if (response != null && response.equalsIgnoreCase('OK')){
proj = [SELECT Status__c FROM Project__c WHERE ProjectRef__c =: projectRef];
if(proj.size() > 0){
proj[0].Status__c = 'Billed';
}
update proj;
}
}
}
BillingServiceProxy:
//Generated by wsdl2apex
public class BillingServiceProxy {
public class billProjectRequest_element {
public BillingServiceProxy.project project;
private String[] project_type_info = new String[]{'project','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
private String[] field_order_type_info = new String[]{'project'};
}
public class project {
public String username;
public String password;
public String projectid;
public Double billAmount;
private String[] username_type_info = new String[]{'username','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] password_type_info = new String[]{'password','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] projectid_type_info = new String[]{'projectid','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] billAmount_type_info = new String[]{'billAmount','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
private String[] field_order_type_info = new String[]{'username','password','projectid','billAmount'};
}
public class billProjectResponse_element {
public String status;
private String[] status_type_info = new String[]{'status','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
private String[] field_order_type_info = new String[]{'status'};
}
public class InvoicesPortSoap11 {
public String endpoint_x = 'http://sb-integration-bs.herokuapp.com:80/ws';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
private String[] ns_map_type_info = new String[]{'http://salesforce.com/th/invoice-web-service', 'BillingServiceProxy'};
public String billProject(BillingServiceProxy.project project) {
BillingServiceProxy.billProjectRequest_element request_x = new BillingServiceProxy.billProjectRequest_element();
request_x.project = project;
BillingServiceProxy.billProjectResponse_element response_x;
Map<String, BillingServiceProxy.billProjectResponse_element> response_map_x = new Map<String, BillingServiceProxy.billProjectResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://salesforce.com/th/invoice-web-service',
'billProjectRequest',
'http://salesforce.com/th/invoice-web-service',
'billProjectResponse',
'BillingServiceProxy.billProjectResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.status;
}
}
}
Please help me to kick off this error.Thanks in advance
please update your trigger code as below
trigger ProjectTrigger on Project__c (after update) {
//after trigger to fire if the Status is set to Billable.
If (Trigger.isAfter && Trigger.isUpdate){
BillingCalloutService.callBillingService(trigger.new, trigger.oldMap);
}
}