Created
February 1, 2024 16:06
-
-
Save britishboyindc/e471313957e8f66c26794e673cab0fb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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; | |
} | |
} |
Can you change it to only read access and see if that solves it?
Yes,did but still got same error
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes, its public read/write BPA_Summary_Detail__c