0

I have a generic function to validate CRUD before DML which uses stripInaccessible().

public static SObjectAccessDecision validateCRUD(AccessType access, List<SObject> records, Boolean enforceRootObjectCRUD){
        SObjectAccessDecision decision = Security.stripInaccessible(access, records,enforceRootObjectCRUD);
        return decision;
    }

In the org, I have an object Integration_Tracker__c which has Opportunity as the master through the field 'LoanApp__c'. Before upserting a record of type Integration_Tracker__c, I use the following :

SObjectAccessDecision integrationTrackerDecision = CAS_OMPL_Utility.validateCRUD(AccessType.UPSERTABLE, new List<Integration_Tracker__c>{createIntegrationTracker(response,opp)}, true);
System.debug('integrationTrackerDecision'+ integrationTrackerDecision.getRecords());
System.debug('removedFields'+ integrationTrackerDecision.getRemovedFields());
upsert integrationTrackerDecision.getRecords();

This always fails and the debug statements reveal 'LoanApp_c' for 'removedFields'. The debug statement before it shows me a record without the LoanApp__c field set.

At profile level, I've given Edit access to all the fields of Integration_Tracker__c and Opportunity object to the System Administrator. Yet for some reason, the LoanApp_c fails.

If I have a child Integration_Tracker__c record already created, the record gets updated successfully. But to create, it keeps on failing.

What am I missing ?

  • Could you please add detail for your object model - for example, what type of field is LoanApp__c? – Phil W Aug 3 at 14:52
  • @PhilW LoanApp_c is of type Master-Detail(Opportunity). I have some integrations which involve the Opportunity records and to track the integration's results on a separate object, I've created the Integration_Tracker__c custom object which is child of Opportunity. – N_H1922 Aug 3 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.