You need to sign in to do that
Don't have an account?
Kris Webster
Deployment Error PLEASE HELP
Hello Community ! I am attemptimng to deploy a Apex Trigger to update resource requests on Opportunites with a Project name and change the status of the request as well. I want all this to occur when the opportunity hits closed won.
WITH that said I have written the code and have it executing fully in the Sandbox wihtout any erros, and have my code coverage passing 100% when I run the tests for the test class in the SB..
What I am struggling with is deploying the code to Production..
When I attempt to deplot the code I am recieving the following error and I am not sure why i am at all..
Here is my Code
And here is my Test Class to go along with it.
In the test code the test data factory is creating an opp for me, and setting it all up to be ready to close win, and then the test data factory is creating a resource request for me with the associated opportunity on the respource request set to the same opportunity the test data factory just created.
With all this said the error message I am recieving when attempting to deploy the code to Production reads..
"Methods defined as TestMethod do not support Web service callouts
Stack Trace: null"
PLEASE HELP.
I have spent 3 days trying to uncover the error and still nothing, so any help would be MUCH appreciated!
WITH that said I have written the code and have it executing fully in the Sandbox wihtout any erros, and have my code coverage passing 100% when I run the tests for the test class in the SB..
What I am struggling with is deploying the code to Production..
When I attempt to deplot the code I am recieving the following error and I am not sure why i am at all..
Here is my Code
public override void afterUpdate(SObject oldSo, SObject so) { Opportunity newOpp = (Opportunity)so; Opportunity oldOpp = (Opportunity)oldSo; if (newOpp.StageName == Constants.OPTY_STAGE_CLOSED_WON && newopp.Does_Not_Need_Resource_Request__c == FALSE){ list<pse__Resource_Request__c> resourceRequests = [select ID, pse__Opportunity__c, Pse__Status__c FROM pse__Resource_Request__c]; list<opportunity> opps = [Select ID, pse__Primary_Project__c from Opportunity]; boolean isValid = false; for (pse__Resource_Request__c resourceRequest : resourceRequests) { if (resourceRequest.pse__Opportunity__c == newOpp.Id) { //there is a resource request that has the opportunity id of the current opp meaning the opp is valid isValid = true; resourceRequest.pse__Project__c = newOpp.pse__Primary_Project__c; resourceRequest.pse__Status__c = 'Assigned'; } } // if we get out of the loop and isValid is false, it means there were 0 opps that matched the resource request // return error if (!isValid) { so.addError('Please add Resource Requests to this Opportunity before marking it as "Closed Won." If no Resource Requests need to be added to the Opportunity please check the "Does Not Need Resource Request" checkbox in order to Close Win.'); } } }
And here is my Test Class to go along with it.
@isTest static void aftUpTest() { TestDataFactory.initPermissionControls(); //Prep the data TestDataFactory.projects = TestDataFactory.createprojects(2); TestDataFactory.opportunities = TestDataFactory.createOpportunities(2); TestDataFactory.createResourceRequests(1, TestDataFactory.opportunities[0], TRUE); system.test.startTest(); TestDataFactory.opportunities[0].StageName = Constants.OPTY_STAGE_CLOSED_WON; TestDataFactory.opportunities[0].Does_Not_Need_Resource_Request__c = FALSE; TestDataFactory.opportunities[0].Create_Project__c = FALSE; TestDataFactory.opportunities[0].Info_Complete__c = TRUE; TestDataFactory.opportunities[0].Pse__Primary_Project__c = TestDataFactory.projects[0].id; update TestDataFactory.opportunities; system.test.stopTest(); } }
In the test code the test data factory is creating an opp for me, and setting it all up to be ready to close win, and then the test data factory is creating a resource request for me with the associated opportunity on the respource request set to the same opportunity the test data factory just created.
With all this said the error message I am recieving when attempting to deploy the code to Production reads..
"Methods defined as TestMethod do not support Web service callouts
Stack Trace: null"
PLEASE HELP.
I have spent 3 days trying to uncover the error and still nothing, so any help would be MUCH appreciated!
Create Resource Requests looks like this
Create Projects Looks like this
@Kaustubh Labhe
The setMock is pulling from a class that looks like this..
The error I get when trying to deploy the test class like this looks like this..
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
Stack Trace: Class.SlackPublisher.QueueableSlackPost.execute: line 51, column 1
NOW WHEN READING THAT ERROR we can look at the class it is refrencing here..
the error is coming from the very last line of the code "HttpResponse res = http.send(req);"
SO I am really unsure why I am getting an error from a class that is not even referenced in my initial test class. I hope this gives you all the information needed to potentially give me some help.. I REALLY APPRECIATE IT!!
@System Admin 995