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
AutobatAutobat 

One Class can update an object the other one cant (already checked CRUD, FLS, page + apex security)

Hey Guys,

 

I have two classes, one updates 2 fields on a record and the other class updates a different field on the record.  Sounds simple......

 

The first class is working perfectly and is encrypting some user entered data perfectly and storing it against the record.  The second class can read the record and access the encrypted data, however, i try and set a third field and update the record and all hell breaks loose!  The site goes straight to the Unauthorized page and there is nothing in the debug log around a failure and i cant catch any exceptions.

 

Checked apex security, page security, object CRUD and FLS and all is how it should be...

 

 

Any ideas where i should check next? 

Best Answer chosen by Admin (Salesforce Developers) 
AutobatAutobat

Found it!!

 

it was the old allowDML="true" chestnut when defining the Component.

 

Many thanks for all your inputs,

 

Chris 

All Answers

AutobatAutobat

The plot thickens!

 

Just hitting the page again and again with different System.Debug statements and it worked.... once.... and now it doesnt work again.

 

Something strange happening in the view state maybe?  I'm grasping at straws here, think it might be time for sleep >:/ 

BulentBulent

try creating a profile that matches the site public access settings

and try the same use case with a user that is tied to the new profile you created above.

You would be able to see the real error on the ui rather than the unauthorized error you see on the public page. 

AutobatAutobat

That sounds like a plan!

 

Sadly clients will get in the way of me trying this out until the weekend, i'll let you know how it goes.

 

Cheers 

AutobatAutobat

Found it!!

 

it was the old allowDML="true" chestnut when defining the Component.

 

Many thanks for all your inputs,

 

Chris 

This was selected as the best answer