You need to sign in to do that
Don't have an account?
Compile Error: Variable does not exist: when adding criteria to Trigger
Hello Community,
I have a trigger on the Lead that I would like to execute only when the Lead custom_field_1_c is not populated and Lead custom_field_2_c has the value of approved, but I keep having either syntax errors or an error saying that my variable does not exist. Any help would be appreciated. I have included my current trigger & class that aren't throwing errors. Thank you!
My Current Trigger (not giving an error):
trigger SalesCloudOnboardLead on Lead (after insert, after update) {
for(Lead leadRecord : Trigger.New){
SalesCloudOnboardClass.makeCallout(leadRecord.Id,'Lead');
}
}
My Current Trigger (giving an error):
trigger SalesCloudOnboardLead on Lead (after insert, after update) {
for(Lead leadRecord : Trigger.New){
(Lead.custom_field_1_c=null && Lead.custom_field_2_c==('Approved'));
SalesCloudOnboardClass.makeCallout(leadRecord.Id,'Lead');
}
}
My Class (not giving an error):
global class SpheraCloudOnboardClass {
@future(callout=true)
public static void makeCallout(String recordID,String recordType) {
String endpoint='';
if(recordType == 'Lead'){
endpoint = 'https://demo.salessolutions.com/onboard/trial/type/Lead/id/'+recordID;
}else if(recordType == 'Contact'){
endpoint = 'https://demo.salessolutions.com/onboard/trial/type/Contact/id/'+recordID;
}
HttpRequest request = new HttpRequest();
// Set the endpoint URL.
request.setEndPoint(endpoint);
// Set the HTTP verb to POST.
request.setMethod('POST');
// Send the HTTP request and get the response.
HttpResponse response = new HTTP().send(request);
}
}
I have a trigger on the Lead that I would like to execute only when the Lead custom_field_1_c is not populated and Lead custom_field_2_c has the value of approved, but I keep having either syntax errors or an error saying that my variable does not exist. Any help would be appreciated. I have included my current trigger & class that aren't throwing errors. Thank you!
My Current Trigger (not giving an error):
trigger SalesCloudOnboardLead on Lead (after insert, after update) {
for(Lead leadRecord : Trigger.New){
SalesCloudOnboardClass.makeCallout(leadRecord.Id,'Lead');
}
}
My Current Trigger (giving an error):
trigger SalesCloudOnboardLead on Lead (after insert, after update) {
for(Lead leadRecord : Trigger.New){
(Lead.custom_field_1_c=null && Lead.custom_field_2_c==('Approved'));
SalesCloudOnboardClass.makeCallout(leadRecord.Id,'Lead');
}
}
My Class (not giving an error):
global class SpheraCloudOnboardClass {
@future(callout=true)
public static void makeCallout(String recordID,String recordType) {
String endpoint='';
if(recordType == 'Lead'){
endpoint = 'https://demo.salessolutions.com/onboard/trial/type/Lead/id/'+recordID;
}else if(recordType == 'Contact'){
endpoint = 'https://demo.salessolutions.com/onboard/trial/type/Contact/id/'+recordID;
}
HttpRequest request = new HttpRequest();
// Set the endpoint URL.
request.setEndPoint(endpoint);
// Set the HTTP verb to POST.
request.setMethod('POST');
// Send the HTTP request and get the response.
HttpResponse response = new HTTP().send(request);
}
}
Use == when comparing two values :
Lead.custom_field_1_c==null && Lead.custom_field_2_c==('Approved'))
Hope it helps you.
Thanks
Varaprasad
Let me know if you face any problem.
Regards,
Jitendra Kawale