-
-
Save britishboyindc/e471313957e8f66c26794e673cab0fb8 to your computer and use it in GitHub Desktop.
<apex:page controller="DemoController" applyHtmlTag="false" showHeader="false" lightningStylesheets="true" sidebar="false"> | |
<html> | |
<body> | |
<apex:form > | |
<apex:slds /> | |
<div class="slds-grid"> | |
<div class="slds-col"> | |
<apex:panelGrid columns="1" width="100%"> | |
<apex:pageBlock mode="Account"> | |
<apex:pageBlockSection title="Section 1" columns="1" collapsible="true"> | |
<apex:selectRadio label="Question 1?" | |
value="{!objNew1.Test_Parent_Question_1__c}" | |
required="true" | |
> | |
<apex:selectOptions value="{!yesNoOptions}" /> | |
</apex:selectRadio> | |
</apex:pageBlockSection> | |
</apex:pageBlock> | |
</apex:panelGrid> | |
</div> | |
<div class="slds-m-top_medium" align="Center"> | |
<apex:commandButton value="SUBMIT" action="{!submit}"/> | |
</div> | |
</div> | |
</apex:form> | |
</body> | |
</html> | |
</apex:page> | |
//Main Controller | |
/** | |
* Created by peter on 1/29/2024. | |
*/ | |
public with sharing class DemoController { | |
public Custom_Obj_1__c objNew1 {get;set;} | |
public Custom_Obj_1__c objExisting; | |
public Custom_Obj_2__c clist; | |
public String recordId; | |
public DemoController() { | |
recordId = ApexPages.currentPage().getParameters().get('id'); | |
if (String.isNotBlank(recordId)) { | |
getData(); | |
} | |
} | |
private void getData() { | |
List<Custom_Obj_1__c> records = [Select Id, Test_Parent_Question_1__c FROM Custom_Obj_1__c WHERE Id = :recordId]; | |
if (records.size() > 0) { | |
objExisting = records[0]; | |
objNew1 = objExisting.clone(false); | |
} | |
} | |
public PageReference submit() { | |
objNew1.Id = objExisting.Id; | |
DemoController_WS.updateObject(objNew1); | |
Custom_Obj_2__c clist = new Custom_Obj_2__c(); | |
clist.Custom_Obj_1__c = objExisting.Id; | |
System.debug(objNew1.Test_Parent_Question_1__c); | |
clist.Test_Question_1__c = objNew1.Test_Parent_Question_1__c; | |
System.debug(clist.Test_Question_1__c); | |
DemoController_WS.insertObject(clist); | |
objNew1.Id = NULL; | |
PageReference pageref = new PageReference('/apex/Thankyoupage'); | |
return pageref; | |
} | |
public List<SelectOption> getYesNoOptions() { | |
List<SelectOption> options = new List<SelectOption>(); | |
options.add(new SelectOption('Yes', 'Yes')); | |
options.add(new SelectOption('No', 'No')); | |
return options; | |
} | |
} | |
public without sharing class DemoController_WS { | |
public static void updateObject(sObject recordToUpdate) { | |
update recordToUpdate; | |
} | |
public static void insertObject(sObject recordToUpdate) { | |
insert recordToUpdate; | |
} | |
} |
Smartronics99
commented
Apr 2, 2024
via email
Hi @britishboyindc,
I still keep getting this error as GSU.
core.apexpages.exceptions.ApexPagesGenericException: system.security.NoAccessException: Update access denied for BPA_Summary_Detail__c, controller action methods may not execute.
Do I need to check any other permissions? As of now did, setup sharing rule on BPA_Summary_Detail__c owner id not equal to 0
I don't think sharing rules won't help you here - GSU can never have edit access to the records.
Did you check the sharing setting for the lookup to BPA_Summary_Detail__c from BPAAttestationResponseDetails__c .
Is it Read/Write or Read Only? If read \ write, that might be an issue
yes, its public read/write BPA_Summary_Detail__c
Can you change it to only read access and see if that solves it?
Yes,did but still got same error