You need to sign in to do that
Don't have an account?
Kalue Her
Code Coverage Failure - Lead Assignment by Zipcode Trigger
I don't have any developer or coding knowledge. I try to learn as I go, but for the past two days, I have not figured out how to resolve my issue. I hope that the forum will help guide me in the right direction so that I can move forward.
What I've done is created a trigger to assign leads to a particular zipcode based off this suggestion (https://developer.salesforce.com/forums/?id=906F0000000Af9nIAC). It litterally is the same trigger. All I did was substitute the database and sales field name with my custom object fields. It worked great in the sandbox production. So I created two more triggers for the Account and Contact records. Both of those worked as well.
The issue I'm running into now is deployment into production. Validation failed. My org has 0% coverage. I've read as much documentation and examples as I could, and tested what I could understand. Nothing is making much sense at this point.
Appreciate it.
What I've done is created a trigger to assign leads to a particular zipcode based off this suggestion (https://developer.salesforce.com/forums/?id=906F0000000Af9nIAC). It litterally is the same trigger. All I did was substitute the database and sales field name with my custom object fields. It worked great in the sandbox production. So I created two more triggers for the Account and Contact records. Both of those worked as well.
The issue I'm running into now is deployment into production. Validation failed. My org has 0% coverage. I've read as much documentation and examples as I could, and tested what I could understand. Nothing is making much sense at this point.
Appreciate it.
Zip_Code__c zip = Zip_Code__c(Name='123456',Outreach_Specialist__c=UserInfo.getUserId());
I am trying to assign a Name and Outreach_Specialist__c in the Zip_Code__c field.
Try this:
This code will not give a good coverage, but will at least let you deploy the Trigger.
All Answers
The issue here is that the trigger you have written has 0% code coverage, and Salesforce as a Standard requires that overall 75% Code coverage should be there for Apex Classes. Triggers need at least 1% Code coverage so that they can be deployed to Production.
So, in a single sentence, you need to write a Test Class for your trigger.
Something like this will help you (for Lead Trigger):
This code will give your trigger at least 1 % code coverage and you will be able to deploy the Trigger.
Veenesh
Below is my lead trigger, and the test class that is created. I am definitely missing something, and am reading up on more documentation. I appreciate the patience and help.
And the test class:
Can you try this one:
Let me know if this helps!
Veenesh
"Error: Compile Error: Variables cannot be marked as tests at line 3 column 28"
I'm trying to locate any documentation on this error, but I am not having much luck from the knowledge base. I'll keep looking, but any suggestion is welcome.
Let me know if it works!
Veenesh
Does "Name" need to be the field name or does it link it self to the trigger? I'm trying to understand as much as possible.
Thanks Veenesh.
Zip_Code__c zip = Zip_Code__c(Name='123456',Outreach_Specialist__c=UserInfo.getUserId());
I am trying to assign a Name and Outreach_Specialist__c in the Zip_Code__c field.
Try this:
This code will not give a good coverage, but will at least let you deploy the Trigger.
Have a wonderful day!