+ Start a Discussion
Ramesh SomalagariRamesh Somalagari 

Authorization Required

I have created simple site that create a new case.

User-added image
Note :

- I have given the Site permissions Visualforce page,Controller ,Lead Object and Case Object.
- While execute the site Lead is created similarly I tried to create a new case it not happens.
- I have given the case Object create permission but why it is not created
Can someone please help me.
While executing the site it showing the error:

**Visualforce Page**

    <apex:page controller="Controller" action="{!init}" showHeader="false" sidebar="false">
        <center>
            <apex:pageBlock title="Request Listener"></apex:pageBlock>         
        </center>
    </apex:page>
**Controller :**
  

         public with sharing class Controller
                {           
                    public PageReference init()
                    {
                    try
                    {                   
                    // Lead l1 = new Lead(FirstName='first name1',LastName = 'lead last name',phone ='9876543210');//testing
                     //insert l1;   testing       
                   Case c = new Case(Subject = 'Subject Test',Description ='Description Test');
                  insert c;
                }
                  }
                   catch(exception e){}
                    RETURN null;
                   } 
                }



bob_buzzardbob_buzzard
Have you set up field level security for the case object also? That always catches me out.
praveen murugesanpraveen murugesan
Hi,

I have tested with same code as you return. Its working fine for me.

For site home page i have used that VF page.

<apex:page controller="SitePageController" action="{!init}" showHeader="false" sidebar="false">
        <center>
            <apex:pageBlock title="Request Listener"></apex:pageBlock>         
        </center>
    </apex:page>
public with sharing class SitePageController 
  {           
                    public PageReference init()
                    {
                    try
                    {                   
                    // Lead l1 = new Lead(FirstName='first name1',LastName = 'lead last name',phone ='9876543210');//testing
                     //insert l1;   testing       
                   Case c = new Case(Subject = 'Subject Test',Description ='Description Test');
                  insert c;
                }
                  
                   catch(exception e){}
                    RETURN null;
                   } 



}

Thanks

Ramesh SomalagariRamesh Somalagari
Hi @bob_buzzard ,
Can you tell me how many security levels are  accessible to for the  site URL.
I need to check all permissions for Case Object .Then Case Object Field Level Security and Object Level security for the site url .
Ramesh SomalagariRamesh Somalagari
@praveen murugesan,
Can you tell me what permmission should give for case Object?
praveen murugesanpraveen murugesan
HI,

You can give all the permissions. and see on the site profile.
Ramesh SomalagariRamesh Somalagari
I have checked all permission's again once Now it is workin for me.
praveen murugesanpraveen murugesan
Hi,

Good..
Ramesh SomalagariRamesh Somalagari
Hi All,

While execute the same code I got a exception

Exception: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

How to re-solve the exception?
bob_buzzardbob_buzzard
That sounds like you have a web service callout after a DML operation (e.g. in a trigger or in a VF controller after updating the record).  You have to use an @future method in that case, as you can't hold up the database while waiting for a response.