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
kabukabu 

Getting error Invalid Cross Reference Key on Approval Process start

I am not sure what I am missing.
when I assigning first  approver getting error. 
(1873818027)|WF_NEXT_APPROVER|Tibisay Montilva|Usuario relacionado|: Channel Manager User 09:40:29.527 (2527557929)|PUSH_NOTIFICATION_INVALID_APP|sf_app_internal|Chatter_for_iOS_Enterprise 09:40:29.687 (2687899006)|PUSH_NOTIFICATION_NO_DEVICES|sf_chttr_apps|Chatter_for_Android 09:40:29.687 (2687919613)|PUSH_NOTIFICATION_NO_DEVICES|sf_chttr_apps|Chatter_for_iOS 09:40:30.344 (3344372401)|CODE_UNIT_FINISHED|Workflow:ApprovalProcessActions 09:40:30.344 (3344506164)|DML_END|[120] 09:40:30.344 (3344608924)|EXCEPTION_THROWN|[120]|System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] 09:40:30.345 (3345319343)|SYSTEM_METHOD_EXIT|[120]|Approval.process(Approval.ProcessRequest) 09:40:30.345 (3345348108)|METHOD_EXIT|[88]|01pU0000001CTpf|My_Class.submitToApprovalProcess(Custom_Object__c)
09:40:30.345 09:40:30.345 (3345518872)|USER_DEBUG|[92]|DEBUG|****ExceptionSystem.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] 09:40:30.345 (3345525814)|SYSTEM_METHOD_EXIT|[92]|System.debug(ANY) 09:40:30.345 (3345555691)|SYSTEM_METHOD_ENTRY|[93]|System.DmlException.getMessage() 09:40:30.345 (3345586143)|SYSTEM_METHOD_EXIT|[93]|System.DmlException.getMessage() 09:40:30.345 (3345661592)|SYSTEM_METHOD_ENTRY|[93]|ApexPages.addMessage(ApexPages.Message) 09:40:30.345 (3345690763)|VF_PAGE_MESSAGE|Exception occuredProcess failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] 

The same code works fine in sandbox for same profile and in prod .it is failing.
For some other Partner user it works fine

My code looks like this
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
        req.setComments('Request submitted for approval automatically.');
        req.setObjectId(newApplication.id);
        req.setSkipEntryCriteria(true);
        req.setNextApproverIds(new Id[] {newApplication.Channel_Manager__c});
        Approval.ProcessResult result = Approval.process(req);

Am I missing any permission or configuration that is causing this error on submitting from partner Portal user.

I have prrovided all the permissions for the object for this user profile.

thanks
Kab.

 
Parvinder SinghParvinder Singh
Is this code in a with sharing class, if yes can you make sure the user has FLS access to the Channel_Manager__c field and its not blank for testing.

Also try to set the process id on the request using setProcessDefinitionNameOrId method, details in https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_ProcessSubmitRequest.htm#apex_Approval_ProcessSubmitRequest_setProcessDefinitionNameOrId
kabukabu

 Thanks for your reply. It is without sharing class and  the profile has access to the field read/write.
Also I tried to skip the entry criteria and and setting next approverID and setProcessDefinitionNameOrId and did not help.
The same code and permissions works in sandbox.
Parvinder SinghParvinder Singh
I am out of wits here, sorry lets wait if some one else can help on it.
kabukabu
Thanks Parvinder. I will wait.
kabukabu
Does partner portal need to have special some setting on the profile?
tural sadiktural sadik

Did you manage to solve this problem?

What I think about this is , it tries to do push notifications to Salesforce1

Just disable salesforce1 push notification and retry to make sure

Documentation says: PUSH_NOTIFICATION_INVALID_APP

App namespace, app name. Apex Code ERROR
This event occurs when Apex code is trying
to send a notification to an app that doesn't
exist in the org, or is not push-enabled.

kabukabu
Hi Trual
I disabled and now getting following error

14:25:35.547 (3547485975)|WF_NEXT_APPROVER|User1 User1Usuario relacionado|: Channel Manager User
14:25:36.698 (4698327184)|CODE_UNIT_FINISHED|Workflow:ApprovalProcessActions 14:25:36.698 (4698445915)|DML_END|[120] 14:25:36.698 (4698572514)|EXCEPTION_THROWN|[120]|System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] 14:25:36.700 (4700547360)|SYSTEM_METHOD_EXIT|[120]|Approval.process(Approval.ProcessRequest) 14:25:36.700 (4700589657)|METHOD_EXIT|[88]|01pK0000000GCYT|MyApex_Class.submitToApprovalProcess(Object1__c) 14:25:36.700 (4700686275)|SYSTEM_METHOD_ENTRY|[92]|String.valueOf(Object) 14:25:36.700 (4700753070)|SYSTEM_METHOD_EXIT|[92]|String.valueOf(Object) 14:25:36.700 (4700775067)|SYSTEM_METHOD_ENTRY|[92]|System.debug(ANY) 14:25:36.700 (4700790930)|USER_DEBUG|[92]|DEBUG|****ExceptionSystem.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] 14:25:36.700 (4700798608)|SYSTEM_METHOD_EXIT|[92]|System.debug(ANY)
14:25:36.700 (4700832301)|SYSTEM_METHOD_ENTRY|[93]|System.DmlException.getMessage()
14:25:36.700 (4700873434)|SYSTEM_METHOD_EXIT|[93]|System.DmlException.getMessage()
14:25:36.700 (4700954746)|SYSTEM_METHOD_ENTRY|[93]|ApexPages.addMessage(ApexPages.Message)
14:25:36.700 (4700985981)|VF_PAGE_MESSAGE|Exception occuredProcess failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] 14:25:36.700 (4700995404)|SYSTEM_METHOD_EXIT|[93]|ApexPages.addMessage(ApexPages.Message)
14:25:37.265 (5265517569)|CODE_UNIT_FINISHED|L\\MyApex_Class invoke(myObj)
14:25:37.267 (5267218140)|VF_APEX_CALL|j_id36|{!saveleadReferralObj}|PageReference:/partner/apex/page1Landing

Not sure what is happening
thanks for your response
 
tural sadiktural sadik
I am not sure but I would check if objects have their relations set. May be lookup or master relation id is set to empty string or something wrong. 
Suraj Tripathi 47Suraj Tripathi 47
Hi,
Greetings!

In this error, you are not the correct user who has permission for the approval process.
Please check the approval process rules and profile to fix this issue.

If you find your Solution then mark this as the best answer. 

Thank you!

Regards,
Suraj Tripathi