You need to sign in to do that
Don't have an account?
Abiola Enifeni 23
Good day all, I keep getting this error : "Variable does not exist"
public with sharing class myLeadToursController
{
@AuraEnabled public User u {get;set;}
@AuraEnabled
public static String getLeadTour(Id objectId)
{
system.debug('objectId : '+objectId);
List<Lead> leadtourList = [SELECT Id,
VOICE_LEAD_ID__c
FROM Lead WHERE Id=:objectId] ;
String vcId = leadtourList[0].VOICE_LEAD_ID__c;
String body =JSON.Serialize( '{"leadId" : "'+ vcId +'"}');
String httpVerb = 'POST';
system.debug(body);
ServiceMarketingJson ws = new ServiceMarketingJson();
//Convert voice lead id to long to call tours web service
Long voiceLeadIDNumber = long.valueOf(vcId);
ServiceMarketingRequests.GetLeadInfoRequest myrequest = new ServiceMarketingRequests.GetLeadInfoRequest(voiceLeadIDNumber);
list<ServiceMarketingJSONObjects.LeadTour> leadTourResponse = new list<ServiceMarketingJSONObjects.LeadTour>();
String serviceMethod = 'GetLeadTours';
String jsonResponse = SendJSONRequest(httpVerb, JSON.serialize(myRequest), serviceMethod);
if (!test.isRunningTest()) {
try {
jsonResponse =SendJSONRequest(httpVerb, JSON.serialize(myRequest), serviceMethod);
}
catch(Exception e) {
if(u.Business_Unit__c != null && u.Business_Unit__c == 'VIP Reservations') {
//send the error email to the dev team
Error_Email.sendErrorEmail('VIPRes - myLeadToursController', 'myLeadToursController (constructor - GetLeadTours)', System.UserInfo.getName(), e.getMessage());
//log the error in SFDC
Error_Exception.logException('VIPRes - myLeadToursController', 'myLeadToursController (constructor - GetLeadTours)', System.UserInfo.getUserId(), e);
} else {
Error_Exception.logException('myLeadToursController', 'myLeadToursController (constructor - GetLeadTours)', System.UserInfo.getUserId(), e);
}
}
} else {
jsonResponse = '[{"ConfirmationStatus":4,"HasSales":false,"LeadId":1474999137,"ManifestCode":"39","ManifestDescription":"LV BLVD - TOWER 1","Office":39,"OfficeDescription":"LVB Action Line","Status":8,"StatusDescription":"CANCELLED","TourBooked":"/Date(-62135578800000-0500)/","TourDate":"/Date(1465444800000-0400)/","TourSeq":1,"TourTime":"","TourWave":12,"TourWaveDescription":"2:00 PM","Type":3,"TypeDescription":"VIP TOUR","UnicaCampaignCode":null,"UnicaHumanId":0,"UnicaLocationId":0,"UnicaOfferCode":null,"UnicaTreatmentCode":null,"UnicaWebServiceName":null,"UnicaXmlMetaData":null,"WasUpdated":false}]';
}
if (jsonResponse != null && jsonResponse.length() != 0)
{
leadTourResponse = ServiceMarketingJSONObjects.parseLeadTours(jsonResponse);
Integer tourCounter = 0;
}
system.debug(leadTourResponse);
return jsonResponse;
}
@AuraEnabled
public static String getReservation(Id objectId)
{
system.debug('objectId : '+objectId);
List<Lead> reservationList = [SELECT Id,
VOICE_LEAD_ID__c
FROM Lead WHERE Id=:objectId] ;
String resId = reservationList[0].VOICE_LEAD_ID__c;
String body =JSON.Serialize( '{"leadId" : "'+ resId +'"}');
String httpVerb = 'POST';
ServiceMarketingJson ws = new ServiceMarketingJson();
//Convert voice lead id to long to call res web service
Long voiceLeadIDNumber = long.valueOf(resId);
ServiceMarketingRequests.GetLeadInfoRequest myRequest = new ServiceMarketingRequests.GetLeadInfoRequest(voiceLeadIDNumber);
ServiceMarketingGetResResponse.GetResResponseParent grResponse = new ServiceMarketingGetResResponse.GetResResponseParent();
String serviceMethod = 'GetReservation';
String jsonResponse = SendJSONRequest(httpVerb, JSON.serialize(myRequest), serviceMethod);
if (jsonResponse != null && jsonResponse.length() != 0){
grResponse = ServiceMarketingGetResResponse.parseGetResResponseParent(jsonResponse);
Integer resCounter = 0;
}
system.debug(grResponse);
return jsonResponse;
}
@AuraEnabled
public static string SendJSONRequest(String httpVerb, String body, String serviceMethod)
{
HttpRequest req = new HttpRequest();
req.setEndpoint(system.label.ESB_SvcMkt_BookTourFull + serviceMethod);
req.setMethod(httpVerb);
req.setTimeout(60000);
req.setHeader('Content-Type', 'application/json;charset=utf-8');
if(!test.isRunningTest())
{
req.setHeader('Authorization', ServiceAuthenticateJsonESB.GetAuthorizationBearer()); //'Bearer '+myTempToken);
}
else
{
req.setHeader('Authorization', 'Bearer 123NO'); //'Bearer '+myTempToken);
}
req.setBody(body);
Http http = new Http();
HTTPResponse res;
String response;
system.debug('Request Header: ' + req.getHeader('Content-Type'));
system.debug('Request Header: ' + req.getHeader('Authorization'));
system.debug('Request URL & Method: ' + req);
system.debug('Request BODY: ' + req.getBody());
if(!test.isRunningTest())
{
res = http.send(req);
response = res.getbody();
system.debug(res);
// response = response.replace('\\','');
}
else
{
response = 'Nope, go away';
}
system.debug('Service URL: ' + req.getEndpoint());
system.debug('BODY ' + req.getBody());
system.debug('RESPONSE ' + response);
system.debug('Auth Header: ' + req.getHeader('Authorization'));
return response;
}
@AuraEnabled
public static datetime convertEPOCHBackToDT(string str)
{
DateTime ret = null;
if (str != null)
ret = DateTime.newInstance(long.valueOf(str.substring(str.indexOf('(')+1, str.indexOf('-'))));
return ret;
}
}
{
@AuraEnabled public User u {get;set;}
@AuraEnabled
public static String getLeadTour(Id objectId)
{
system.debug('objectId : '+objectId);
List<Lead> leadtourList = [SELECT Id,
VOICE_LEAD_ID__c
FROM Lead WHERE Id=:objectId] ;
String vcId = leadtourList[0].VOICE_LEAD_ID__c;
String body =JSON.Serialize( '{"leadId" : "'+ vcId +'"}');
String httpVerb = 'POST';
system.debug(body);
ServiceMarketingJson ws = new ServiceMarketingJson();
//Convert voice lead id to long to call tours web service
Long voiceLeadIDNumber = long.valueOf(vcId);
ServiceMarketingRequests.GetLeadInfoRequest myrequest = new ServiceMarketingRequests.GetLeadInfoRequest(voiceLeadIDNumber);
list<ServiceMarketingJSONObjects.LeadTour> leadTourResponse = new list<ServiceMarketingJSONObjects.LeadTour>();
String serviceMethod = 'GetLeadTours';
String jsonResponse = SendJSONRequest(httpVerb, JSON.serialize(myRequest), serviceMethod);
if (!test.isRunningTest()) {
try {
jsonResponse =SendJSONRequest(httpVerb, JSON.serialize(myRequest), serviceMethod);
}
catch(Exception e) {
if(u.Business_Unit__c != null && u.Business_Unit__c == 'VIP Reservations') {
//send the error email to the dev team
Error_Email.sendErrorEmail('VIPRes - myLeadToursController', 'myLeadToursController (constructor - GetLeadTours)', System.UserInfo.getName(), e.getMessage());
//log the error in SFDC
Error_Exception.logException('VIPRes - myLeadToursController', 'myLeadToursController (constructor - GetLeadTours)', System.UserInfo.getUserId(), e);
} else {
Error_Exception.logException('myLeadToursController', 'myLeadToursController (constructor - GetLeadTours)', System.UserInfo.getUserId(), e);
}
}
} else {
jsonResponse = '[{"ConfirmationStatus":4,"HasSales":false,"LeadId":1474999137,"ManifestCode":"39","ManifestDescription":"LV BLVD - TOWER 1","Office":39,"OfficeDescription":"LVB Action Line","Status":8,"StatusDescription":"CANCELLED","TourBooked":"/Date(-62135578800000-0500)/","TourDate":"/Date(1465444800000-0400)/","TourSeq":1,"TourTime":"","TourWave":12,"TourWaveDescription":"2:00 PM","Type":3,"TypeDescription":"VIP TOUR","UnicaCampaignCode":null,"UnicaHumanId":0,"UnicaLocationId":0,"UnicaOfferCode":null,"UnicaTreatmentCode":null,"UnicaWebServiceName":null,"UnicaXmlMetaData":null,"WasUpdated":false}]';
}
if (jsonResponse != null && jsonResponse.length() != 0)
{
leadTourResponse = ServiceMarketingJSONObjects.parseLeadTours(jsonResponse);
Integer tourCounter = 0;
}
system.debug(leadTourResponse);
return jsonResponse;
}
@AuraEnabled
public static String getReservation(Id objectId)
{
system.debug('objectId : '+objectId);
List<Lead> reservationList = [SELECT Id,
VOICE_LEAD_ID__c
FROM Lead WHERE Id=:objectId] ;
String resId = reservationList[0].VOICE_LEAD_ID__c;
String body =JSON.Serialize( '{"leadId" : "'+ resId +'"}');
String httpVerb = 'POST';
ServiceMarketingJson ws = new ServiceMarketingJson();
//Convert voice lead id to long to call res web service
Long voiceLeadIDNumber = long.valueOf(resId);
ServiceMarketingRequests.GetLeadInfoRequest myRequest = new ServiceMarketingRequests.GetLeadInfoRequest(voiceLeadIDNumber);
ServiceMarketingGetResResponse.GetResResponseParent grResponse = new ServiceMarketingGetResResponse.GetResResponseParent();
String serviceMethod = 'GetReservation';
String jsonResponse = SendJSONRequest(httpVerb, JSON.serialize(myRequest), serviceMethod);
if (jsonResponse != null && jsonResponse.length() != 0){
grResponse = ServiceMarketingGetResResponse.parseGetResResponseParent(jsonResponse);
Integer resCounter = 0;
}
system.debug(grResponse);
return jsonResponse;
}
@AuraEnabled
public static string SendJSONRequest(String httpVerb, String body, String serviceMethod)
{
HttpRequest req = new HttpRequest();
req.setEndpoint(system.label.ESB_SvcMkt_BookTourFull + serviceMethod);
req.setMethod(httpVerb);
req.setTimeout(60000);
req.setHeader('Content-Type', 'application/json;charset=utf-8');
if(!test.isRunningTest())
{
req.setHeader('Authorization', ServiceAuthenticateJsonESB.GetAuthorizationBearer()); //'Bearer '+myTempToken);
}
else
{
req.setHeader('Authorization', 'Bearer 123NO'); //'Bearer '+myTempToken);
}
req.setBody(body);
Http http = new Http();
HTTPResponse res;
String response;
system.debug('Request Header: ' + req.getHeader('Content-Type'));
system.debug('Request Header: ' + req.getHeader('Authorization'));
system.debug('Request URL & Method: ' + req);
system.debug('Request BODY: ' + req.getBody());
if(!test.isRunningTest())
{
res = http.send(req);
response = res.getbody();
system.debug(res);
// response = response.replace('\\','');
}
else
{
response = 'Nope, go away';
}
system.debug('Service URL: ' + req.getEndpoint());
system.debug('BODY ' + req.getBody());
system.debug('RESPONSE ' + response);
system.debug('Auth Header: ' + req.getHeader('Authorization'));
return response;
}
@AuraEnabled
public static datetime convertEPOCHBackToDT(string str)
{
DateTime ret = null;
if (str != null)
ret = DateTime.newInstance(long.valueOf(str.substring(str.indexOf('(')+1, str.indexOf('-'))));
return ret;
}
}
Eric Pepin NH
Any other information in the error message? like a line number maybe?
Raj Vakati
try like this