+ Start a Discussion
KarthikThotaSFDCKarthikThotaSFDC 

Process failed.: NO_APPLICABLE_PROCESS, No applicable approval process found error

Hi,

 

trigger QuoteSubmitForApproval on QuoteLineItem (after insert,after update)
{
List<QuoteLineItem> qLineItem =new List<QuoteLineItem>();
qLineItem=[select id,quoteId,quote.status,PricebookEntryId,PricebookEntry.Pricebook2Id,Discount,PricebookEntry.Product2Id,PricebookEntry.Product2.name,PricebookEntry.Product2.UAE_Discount__c from QuoteLineItem where id=:Trigger.newMap.keySet()];
//User u = [select id,ManagerId from User where Id =: Userinfo.getUserId()];
Set<String> quoteIds=new Set<String>();
for(Integer i = 0;i<qLineItem.Size();i++)
{
System.debug('----i-----'+i);
System.debug('-----QlineItem Discount----'+qLineItem[i].Discount);
System.debug('------Product Discount------'+qLineItem[i].PricebookEntry.Product2.UAE_Discount__c);
if((qLineItem[i].Discount > qLineItem[i].PricebookEntry.Product2.UAE_Discount__c) && (qLineItem[i].quote.status <> 'Approved') && (qLineItem[i].quote.status <> 'Accepted') /*&& (u.ManagerId!=null)*/ )
{
if(!(quoteIds.contains(qLineItem[i].QuoteId)))
{
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for Approval. Please Review');
req.setNextApproverIds(new Id[] {UserInfo.getUserId()});
req.setObjectId(qLineItem[i].QuoteId);
Approval.ProcessResult result = Approval.Process(req);
System.debug('Submitted for approval successfully: '+result.isSuccess());
quoteIds.add(qLineItem[i].QuoteId);
}
}
else
{
System.debug('No Manager for this User');
}
}
}

 

 

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger QuoteSubmitForApproval caused an unexpected exception, contact your administrator: QuoteSubmitForApproval: execution of AfterInsert caused by: System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process found.: []: Trigger.QuoteSubmitForApproval: line 20, column 1

 

.......When i am trying to create a quote, i was throwing the above exception.

 

Anyone please suggest, how to overcome on this ...

 

 

 

 

 

PremanathPremanath

Hi Here ,

 

Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();

 

This class Have only

getComments

setComments

getNextApproverIds

setNextApproverIds

getObjectId

setObjectId

These methods

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_ProcessSubmitRequest.htm

 

 

I think i.e your problm 

or

Check your permissions 

rodrigoBFrodrigoBF

Hi,

 

check if in your approval process, there's a criteria that match with this case.

If there's a criteria, this quoteLineItem should attend for these conditions of approval process criteria.

 

Regards

Vinit_KumarVinit_Kumar

Agreed with Rodrigo,please make sure that you are meeting the criteria which is required to invoke the Approval process in your record  which is being inserted.

KarthikThotaSFDCKarthikThotaSFDC

It was not solved :(

 

1 ) Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();

 

req.setComments('Submitted for Approval. Please Review');
req.setNextApproverIds(new Id[] {UserInfo.getUserId()});
req.setObjectId(qLineItem[i].QuoteId);

 

I am using the methods as mentioned above. Even i am getting the above exception.

 

2 )  if((qLineItem[i].Discount) > (qLineItem[i].PricebookEntry.Product2.UAE_Discount__c) && qLineItem[i].quote.status <> 'Approved' && qLineItem[i].quote.status <> 'Accepted')

 

from above statement, i am specifying the entry criteria as, if quotelineitem discount percent is greater than that particular product UAE_Discount__c percent, then it should go for approval.

i.e ; (qLineItem[i].Discount) > (qLineItem[i].PricebookEntry.Product2.UAE_Discount__c)

 

so what is bug  in my code,

please specify the bug n my code..

 

Thanks in Advance,

Karthik.

KarthikThotaSFDCKarthikThotaSFDC

Still i am getting the same error as abpve ..

 

Anyone of u suggest me , how to overcome this ..

 

Thanks in Advance

crop1645crop1645

The way to debug this is to go to your Debug Log and ensure you are logging Workflow events. Here is an example from my org:

 

07:13:44.818 (818112000)|WF_APPROVAL_SUBMIT|[Approval Request: null-Test REST Service-doc upload test a04Z0000006J2zd]
07:13:44.838 (838689000)|WF_RULE_FILTER|[Approval Request : Status equals Ready] 
AND [Approval Request : Type equals Quote]
07:13:44.838 (838720000)|WF_RULE_EVAL_VALUE|1
07:13:44.838 (838726000)|WF_RULE_EVAL_VALUE|
07:13:44.838 (838740000)|WF_EVAL_ENTRY_CRITERIA|Approve: Quote|00Xd0000001APev|false
07:13:44.838 (838749000)|WF_NO_PROCESS_FOUND

 As you can see, the NO_PROCESS_FOUND error occurs if one doesn't have any Approval Processes for the object in question whose entry criteria is met.  

testdemo11.3939560947047168E12testdemo11.3939560947047168E12
Create an approval Process for that Object and Criteria as TRUE..And make it Active..And execute code
Ravi Chandra 64Ravi Chandra 64
Hey guys!
when I'm trying to create an approval process for a chatter feed, it throwing an error called..

System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []

Plz help me.

Regards 
Ravi Chandra