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
knthornt1knthornt1 

Invalid Cross Reference ID error for Site users

I have an authenticated site where some users can switch the account which drives the data displayed on the site. The account could be either the one tied to the portal users account (the one the contact record is tied to) or another account which is a child account (though the parent account hierarchy).

 

Users can submit a record which essentailly just updates a date on the record. This date triggers an workflow email alert. When the user submits a record tied to "their" account, there is no problem, but when the user submits a record against a different account an Invalid Cross Reference ID error is thrown. The error occurs as the workflow is evaluated. Turning off the email alert results in a successful submission.

 

The workflow email alert does use a visualforce template, but I removed all the markup from that template and no error was thrown.

 

Error log below. Any help at all would be appreciated.

 

16:41:02.646 (1646850000)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:01IA0000001wgKG
16:41:02.691 (1691668000)|WF_RULE_EVAL_BEGIN|Assignment
16:41:02.691 (1691690000)|WF_RULE_EVAL_BEGIN|Response
16:41:02.691 (1691699000)|WF_RULE_EVAL_BEGIN|Workflow
16:41:02.691 (1691724000)|WF_CRITERIA_BEGIN|[Shipping Schedule Header: Order-00015 a2AA00000000Bn1]|Portal Shipping - Placed Thank You|01QA00000005Dqb|ON_CREATE_OR_TRIGGERING_UPDATE
16:41:02.698 (1698456000)|WF_RULE_FILTER|[Shipping Schedule Header : Ordered Date not equal to null]
16:41:02.698 (1698480000)|WF_RULE_EVAL_VALUE|2012-03-29 00:00:00
16:41:02.698 (1698488000)|WF_CRITERIA_END|true
16:41:02.715 (1715916000)|WF_CRITERIA_BEGIN|[Shipping Schedule Header: Order-00015 a2AA00000000Bn1]|Portal Shipping 6 month confirm|01QA00000005Dqc|ON_CREATE_OR_TRIGGERING_UPDATE
16:41:02.715 (1715985000)|WF_RULE_FILTER|[Shipping Schedule Header : Confirmation Date equals null]
16:41:02.716 (1716005000)|WF_RULE_EVAL_VALUE|2012-03-29 00:00:00
16:41:02.716 (1716014000)|WF_CRITERIA_END|false
16:41:02.716 (1716029000)|WF_CRITERIA_BEGIN|[Shipping Schedule Header: Order-00015 a2AA00000000Bn1]|Portal Place Order reminder|01QA00000005DqZ|ON_CREATE_OR_TRIGGERING_UPDATE
16:41:02.716 (1716455000)|WF_RULE_NOT_EVALUATED
16:41:02.716 (1716540000)|WF_SPOOL_ACTION_BEGIN|Workflow
16:41:02.716 (1716564000)|WF_RULE_INVOCATION|[Shipping Schedule Header: Order-00015 a2AA00000000Bn1]
16:41:02.716 (1716578000)|WF_EMAIL_ALERT|Id=01WA00000008rih|CurrentRule:Portal Shipping - Placed Thank You (Id=01QA00000005Dqb)
16:41:02.809 (1809641000)|WF_ACTION| Email Alert: 1;
16:41:02.809 (1809660000)|WF_RULE_EVAL_BEGIN|Escalation
16:41:02.809 (1809667000)|WF_RULE_EVAL_END
16:41:02.809 (1809675000)|WF_TIME_TRIGGERS_BEGIN
16:41:02.809 (1809751000)|WF_ACTIONS_END| Email Alert: 1;
16:41:02.809 (1809757000)|CODE_UNIT_FINISHED|Workflow:01IA0000001wgKG
16:41:02.809 (1809920000)|DML_END|[258]
16:41:02.810 (1810050000)|EXCEPTION_THROWN|[258]|System.DmlException: Update failed. First exception on row 0 with id a2AA00000000Bn1MAE; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
16

 

Best Answer chosen by Admin (Salesforce Developers) 
knthornt1knthornt1

We ended up having to remove the "with" sharing from out classes. be sure to put your code through the securty scanner before releasing to production: http://security.force.com/sourcescanner

All Answers

DevNVDevNV

I'm getting a similar problem - I have a sites page that takes in data for a custom object and saves.  This custom object has workflow alerts, one of which is a VisualForce email template with a VF component inside.  My error is slightly different: INSUFFICIENT_ACCESS_OR_READONLY, user does not have access to use approval assignment email template: []  I don't have approval processes setup so I can only imagine this is a buggy error message.  When I remove that VF email from the workflow all is good.

 

I've added the component's controller into the sites guest profile but that didn't help.  Any thoughts on VF email templates trigger by sites users?

 

16:53:37.292 (292420000)|WF_SPOOL_ACTION_BEGIN|Workflow
16:53:37.292 (292436000)|WF_RULE_INVOCATION|[Compost Coaching Session: Niki Vankerk: 123 main, CNV a09Q0000006aADE]
16:53:37.292 (292443000)|WF_EMAIL_ALERT|Id=01WQ00000000Fb5|CurrentRule:Send Booking Confirmation and Reminders (Id=01QQ000000098EO)
16:53:37.356 (356435000)|WF_EMAIL_SENT|Template:00XQ0000000INUQ|Recipients:niki@vankerksolutions.com |CcEmails:
16:53:37.356 (356462000)|WF_RULE_INVOCATION|[Compost Coaching Session: Niki Vankerk: 123 main, CNV a09Q0000006aADE]
16:53:37.356 (356470000)|WF_EMAIL_ALERT|Id=01WQ00000000Fly|CurrentRule:Send Booking Confirmation and Reminders (Id=01QQ000000098EO)
16:53:37.393 (393371000)|WF_ACTION| Email Alert: 3;
16:53:37.393 (393396000)|WF_RULE_EVAL_BEGIN|Escalation
16:53:37.393 (393403000)|WF_RULE_EVAL_END
16:53:37.393 (393423000)|WF_TIME_TRIGGERS_BEGIN
16:53:37.393 (393494000)|WF_ACTIONS_END| Email Alert: 3;
16:53:37.393 (393501000)|CODE_UNIT_FINISHED|Workflow:01IQ0000000DNkH
16:53:37.393 (393718000)|DML_END|[159]
16:53:37.393 (393838000)|EXCEPTION_THROWN|[159]|System.DmlException: Update failed. First exception on row 0 with id a09Q0000006aADEIA2; first error: INSUFFICIENT_ACCESS_OR_READONLY, user does not have access to use approval assignment email template: []

 

knthornt1knthornt1

We ended up having to remove the "with" sharing from out classes. be sure to put your code through the securty scanner before releasing to production: http://security.force.com/sourcescanner

This was selected as the best answer
fgwarb_devfgwarb_dev

I'm getting the 

INSUFFICIENT_ACCESS_OR_READONLY, user does not have access to use approval assignment email template

error and the class is set to "without sharing" ...

 

 

SOLVED

It seems that the error was related to the fact that the "everything" was being deployed in a single package.  I commented out the offending test code and deployed successfully.  Then uncommented the offending test code and redeployed and the error did not recur.