function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tena Wolver 32Tena Wolver 32 

Invalid type: Approval.ProcessSubmitRequest

I get the error Invalid type: Approval.ProcessSubmitRequest when I have the statement 
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();

which I need to submit a request.  I don't understand why.  Even Salesforces own documentation show this way to create the object.  Any help?

 
Best Answer chosen by Tena Wolver 32
VineetKumarVineetKumar
can you check if there is any class with similar name "Approval" in your org.
Seems like there is, it is conflicting with the approval object, please rename that class to something else.

All Answers

Manish BhatiManish Bhati
What is your class name and method consisting this code?
VineetKumarVineetKumar
can you check if there is any class with similar name "Approval" in your org.
Seems like there is, it is conflicting with the approval object, please rename that class to something else.
This was selected as the best answer
Tena Wolver 32Tena Wolver 32
Yes I created an approval class that was conflicting.   SMH
VineetKumarVineetKumar
It will, as when you try referring Approval.<something> salesforce will search your whole workspace for any matches.
Here it got 2 matches and was not able to identify which one to refer, throwing that particular error.

Usually, classes having static methods are executed directly without instantiating the object.
Something like : ClassName.ObjectName();

Do mark my answer as best answer if it helped you.
Tena Wolver 32Tena Wolver 32
Yes I had created a class called Approval.  I didn't think of that at the time :(  Thanks for everyones reply.  It was due to a class I created called "Approval"  all answers above are correct.
VineetKumarVineetKumar
Mark the answer as best answer by checking it right under the comments.
So as to help if someone facing the same problem hits this page.