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
Travis SeilerTravis Seiler 

Custom Object won't insert from public access visualforce site

I have a VisualForce page and controller that works great when I test it using preview from within the developer console, but when I try to access it from my VisualForce public access site, the record does not get inserted.  I have been checking all of the permissions, but have not been able to find anywhere that has allowed the records to be created.  Let me know if I need to add code, etc.  But I know the code works, it just seems like a permissions issue somewhere that I am missing...

 

Thanks for the help.

Devendra@SFDCDevendra@SFDC

Hi,

 

You need to check site settings.

 

Navigate to Develop--> Sites--> Site Name--> Click on Public Access Settings Button and Provide Necessary settings.

 

Thanks,

Devendra

Travis SeilerTravis Seiler

So, I have already looked through all of the settings under Public access, and have granted all permissions on the custom objects but when accessing the site from the a browser, and filling out my simple web form, the record does not get created.  The form just takes in a couple of fields and creates a new custom object.  

 

Like I already said it works find through the developer console, and I can access the page fine, it just won't create the object.  I have checked all of the field accessibility options on the custom objects and have no idea where else to look.  

 

 

Devendra@SFDCDevendra@SFDC

Hi,

 

Go through this blog and check debug log for site user, which can give us an idea what is happening when code gets executed under site user context.

 

Thanks,

Devendra

Travis SeilerTravis Seiler

Here is the debug log file (below), I changed the controller to show the new created record, but now it shows an unauthorized page.  Looking through the log, it actually looks like it is creating the record, but I go into the view later on and the record does not exist.

 

27.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
01:19:30.018 (18704000)|EXECUTION_STARTED
01:19:30.018 (18755000)|CODE_UNIT_STARTED|[EXTERNAL]|066i000000167Af|VF: /apex/Travis_Registration
01:19:30.018 (18974000)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066i000000167Af
01:19:30.022 (22478000)|VF_DESERIALIZE_VIEWSTATE_END
01:19:30.023 (23354000)|CODE_UNIT_STARTED|[EXTERNAL]|01pi00000016zUm|RegistrationPageController get(person1)
01:19:30.023 (23371000)|SYSTEM_MODE_ENTER|true
01:19:30.023 (23864000)|CODE_UNIT_STARTED|[EXTERNAL]|01pi00000016zUm|RegistrationPageController invoke(getperson1)
01:19:30.024 (24336000)|METHOD_ENTRY|[1]|01pi00000016zUm|RegistrationPageController.RegistrationPageController()
01:19:30.024 (24464000)|METHOD_EXIT|[1]|RegistrationPageController
01:19:30.024 (24518000)|CODE_UNIT_FINISHED|RegistrationPageController invoke(getperson1)
01:19:30.024 (24530000)|CODE_UNIT_FINISHED|RegistrationPageController get(person1)
01:19:30.026 (26669000)|CODE_UNIT_STARTED|[EXTERNAL]|01pi00000016zUm|RegistrationPageController get(RoleTypeList)
01:19:30.026 (26684000)|SYSTEM_MODE_ENTER|true
01:19:30.026 (26696000)|CODE_UNIT_STARTED|[EXTERNAL]|01pi00000016zUm|RoleTypeList
01:19:30.026 (26845000)|SYSTEM_CONSTRUCTOR_ENTRY|[16]|<init>()
01:19:30.026 (26887000)|SYSTEM_CONSTRUCTOR_EXIT|[16]|<init>()
01:19:30.026 (26990000)|SYSTEM_METHOD_ENTRY|[17]|Schema.SObjectField.getDescribe()
01:19:30.027 (27304000)|SYSTEM_METHOD_EXIT|[17]|Schema.SObjectField.getDescribe()
01:19:30.028 (28280000)|SYSTEM_METHOD_ENTRY|[20]|LIST<Schema.PicklistEntry>.iterator()
01:19:30.028 (28598000)|SYSTEM_METHOD_EXIT|[20]|LIST<Schema.PicklistEntry>.iterator()
01:19:30.028 (28630000)|SYSTEM_METHOD_ENTRY|[20]|system.ListIterator.hasNext()
01:19:30.028 (28657000)|SYSTEM_METHOD_EXIT|[20]|system.ListIterator.hasNext()
01:19:30.028 (28756000)|SYSTEM_METHOD_ENTRY|[22]|LIST<System.SelectOption>.add(Object)
01:19:30.028 (28809000)|SYSTEM_METHOD_EXIT|[22]|LIST<System.SelectOption>.add(Object)
01:19:30.028 (28823000)|SYSTEM_METHOD_ENTRY|[20]|system.ListIterator.hasNext()
01:19:30.028 (28836000)|SYSTEM_METHOD_EXIT|[20]|system.ListIterator.hasNext()
01:19:30.028 (28876000)|SYSTEM_METHOD_ENTRY|[22]|LIST<System.SelectOption>.add(Object)
01:19:30.028 (28897000)|SYSTEM_METHOD_EXIT|[22]|LIST<System.SelectOption>.add(Object)
01:19:30.028 (28906000)|SYSTEM_METHOD_ENTRY|[20]|system.ListIterator.hasNext()
01:19:30.028 (28918000)|SYSTEM_METHOD_EXIT|[20]|system.ListIterator.hasNext()
01:19:30.028 (28954000)|SYSTEM_METHOD_ENTRY|[22]|LIST<System.SelectOption>.add(Object)
01:19:30.028 (28973000)|SYSTEM_METHOD_EXIT|[22]|LIST<System.SelectOption>.add(Object)
01:19:30.028 (28982000)|SYSTEM_METHOD_ENTRY|[20]|system.ListIterator.hasNext()
01:19:30.028 (28994000)|SYSTEM_METHOD_EXIT|[20]|system.ListIterator.hasNext()
01:19:30.029 (29029000)|SYSTEM_METHOD_ENTRY|[22]|LIST<System.SelectOption>.add(Object)
01:19:30.029 (29049000)|SYSTEM_METHOD_EXIT|[22]|LIST<System.SelectOption>.add(Object)
01:19:30.029 (29058000)|SYSTEM_METHOD_ENTRY|[20]|system.ListIterator.hasNext()
01:19:30.029 (29074000)|SYSTEM_METHOD_EXIT|[20]|system.ListIterator.hasNext()
01:19:30.029 (29135000)|CODE_UNIT_FINISHED|RoleTypeList
01:19:30.029 (29145000)|CODE_UNIT_FINISHED|RegistrationPageController get(RoleTypeList)
01:19:30.029 (29252000)|CODE_UNIT_STARTED|[EXTERNAL]|01pi00000016zUm|RegistrationPageController get(SelectRoleType)
01:19:30.029 (29264000)|SYSTEM_MODE_ENTER|true
01:19:30.029 (29275000)|CODE_UNIT_STARTED|[EXTERNAL]|01pi00000016zUm|SelectRoleType
01:19:30.029 (29290000)|CODE_UNIT_FINISHED|SelectRoleType
01:19:30.029 (29297000)|CODE_UNIT_FINISHED|RegistrationPageController get(SelectRoleType)
01:19:30.029 (29724000)|CODE_UNIT_STARTED|[EXTERNAL]|RegistrationPageController set(SelectRoleType,Administrator)
01:19:30.029 (29736000)|SYSTEM_MODE_ENTER|true
01:19:30.029 (29749000)|CODE_UNIT_STARTED|[EXTERNAL]|RegistrationPageController set(SelectRoleType,Administrator)
01:19:30.029 (29789000)|CODE_UNIT_FINISHED|RegistrationPageController set(SelectRoleType,Administrator)
01:19:30.029 (29798000)|CODE_UNIT_FINISHED|RegistrationPageController set(SelectRoleType,Administrator)
01:19:30.029 (29946000)|CODE_UNIT_STARTED|[EXTERNAL]|01pi00000016zUm|RegistrationPageController invoke(save)
01:19:30.030 (30130000)|METHOD_ENTRY|[36]|01pi00000016zUm|RegistrationPageController.__sfdc_SelectRoleType()
01:19:30.030 (30180000)|METHOD_EXIT|[36]|01pi00000016zUm|RegistrationPageController.__sfdc_SelectRoleType()
01:19:30.030 (30294000)|DML_BEGIN|[39]|Op:Insert|Type:Person__c|Rows:1
01:19:30.078 (78699000)|DML_END|[39]
01:19:30.078 (78779000)|SYSTEM_METHOD_ENTRY|[45]|String.valueOf(Object)
01:19:30.078 (78819000)|SYSTEM_METHOD_EXIT|[45]|String.valueOf(Object)
01:19:30.078 (78880000)|SYSTEM_METHOD_ENTRY|[47]|System.PageReference.setRedirect(Boolean)
01:19:30.078 (78922000)|SYSTEM_METHOD_EXIT|[47]|System.PageReference.setRedirect(Boolean)
01:19:30.081 (81752000)|CODE_UNIT_FINISHED|RegistrationPageController invoke(save)
01:19:30.082 (82662000)|VF_APEX_CALL|j_id12|{!save}|PageReference:/a00i0000002TVeWAAW
01:19:30.655 (84470000)|CUMULATIVE_LIMIT_USAGE
01:19:30.655|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 1 out of 150
  Number of DML rows: 1 out of 10000
  Number of code statements: 16 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 1 out of 100
  Number of future calls: 0 out of 10

01:19:30.655|CUMULATIVE_LIMIT_USAGE_END

01:19:30.084 (84528000)|CODE_UNIT_FINISHED|VF: /apex/Travis_Registration
01:19:30.084 (84534000)|EXECUTION_FINISHED
Srinath TeramSrinath Teram

Hi,

 

Just a basic question, have you added the page to which the site redirects post creation of object for the guest profile?