You need to sign in to do that
Don't have an account?
ForceLover
Authorization Required Error Page
Hi Everyone,
I created a VF form which will seach for REFID__c(unique) field in lead object if it matches it retrives the details from lead.IT is working fine.I'm using this page in the site here while i'm clicking the seach button it is showing mw the Authorization required page.I checked all the permissions object ,fields,Apex class, VF all are correct.Here is my code
<apex:page standardController="Lead" extensions="LeadUpdate" showHeader="false" sidebar="false"> <head> <style> .startStyle{ font-size:12px; font-weight:bold; color:red; } </style> </head> <apex:image id="logo" value="{!$Resource.CompanyLogo}" style="align: left;" height="75" width="233"/> <apex:sectionHeader title="{!Lead.Name}" subtitle="Lead Form"/> <apex:form id="frm"> <div style="width:1400px; padding-left:5%; "> <apex:pageBlock mode="edit" id="block"> <apex:pageBlockButtons location="both"> <apex:commandButton action="{!save}" value="Save Records" rerender="frm"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageMessages escape="false"/> <apex:pageBlockSection > <apex:pageBlockSectionItem > <apex:outputLabel for="searchText" style="font-size:14px">RefID/FileNumber</apex:outputLabel> <apex:panelGroup > <apex:inputText id="searchText" value="{!searchText}"/> <apex:commandButton value="Search" action="{!search}" rerender="block" status="status"/> </apex:panelGroup> </apex:pageBlockSectionItem> </apex:pageBlockSection><br/> <apex:actionStatus id="status" startText="Searching... please wait..."/> <apex:pageBlockSection title="Lead Results" id="resultsBlock" columns="1"> <apex:pageBlockTable value="{!searchResults}" var="Lead" rendered="{!NOT(ISNULL(searchResults))}"> <apex:column value="{!Lead.Name}" headerValue="LeadName" width="100"/> <apex:column value="{!Lead.Street}" headerValue="Street" width="100"/> <apex:column value="{!Lead.City}" headerValue="City" width="100"/> <apex:column value="{!Lead.State}" headerValue="State" width="100"/> <!-- <apex:column headerValue="First Name" width="100"> <apex:inputField value="{!Lead.FirstName}"/> </apex:column> <apex:column headerValue="Last Name" width="100"> <apex:inputField value="{!Lead.LastName}"/> </apex:column> --> <apex:column headerValue="Email" width="100" style="font-size:12px"> <apex:inputField value="{!Lead.Email}"/> </apex:column> <apex:column headerValue="Phone" width="100"> <apex:inputField value="{!Lead.Phone}"/> </apex:column> <apex:column headerValue="Evening Phone" width="100"> <apex:inputField value="{!Lead.Evening_Phone__c}"/> </apex:column> <apex:column headerValue="Preferred Call Time" width="100"> <apex:inputField value="{!Lead.Preferred_Call_Time__c}"/> </apex:column> <apex:column headerValue="Notes" width="100"> <apex:inputField value="{!Lead.Notes__c}"/> </apex:column> <apex:column headerValue="Do Not Call" width="100"> <apex:inputField value="{!Lead.DoNotCall}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </div> </apex:form> </apex:page>
controller
public with sharing class LeadUpdate { private ApexPages.StandardController controller {get; set;} public List<Lead> searchResults {get;set;} public string searchText {get;set;} public LeadUpdate(ApexPages.StandardController controller) { } public PageReference search() { String qry = 'select id, name, FirstName, LastName, Status, Ref_ID_File_Number__c, Email, Phone, Street, City, State, Country, PostalCode, TAB_Message__c, Evening_Phone__c, Preferred_Call_Time__c, Notes__c from Lead ' + 'where Ref_ID_File_Number__c =:searchText order by name'; searchResults = Database.query(qry); if(searchResults.size()==0){ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'<b>Ref ID could not be found. The syntax is always as follows: AANNNN-NNNNN (A= Alpha/Letter; N= Number) i.e. FL0301-12345</b>')); return null; }else{ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info,'<b>Please confirm name and address below. Address will be where the letter was received/addressed. If these do not match, you will need to re-verify Ref ID, as it may have been entered incorrectly</b>')); return null; } return null; } public PageReference save() { if(!(String.isEmpty(searchText))){ try { list<lead> lstupdate = new list<lead>(); For(Lead le:searchResults){ //le.Id = lead.Id; le.Ref_ID_File_Number__c = searchResults[0].Ref_ID_File_Number__c ; le.FirstName = searchResults[0].FirstName; le.LastName = searchResults[0].LastName; le.Email = searchResults[0].Email; le.Status = 'Missed Call'; le.Phone = searchResults[0].Phone; le.Evening_Phone__c = searchResults[0].Evening_Phone__c ; le.Preferred_Call_Time__c = searchResults[0].Preferred_Call_Time__c; le.Notes__c = searchResults[0].Notes__c; le.DoNotCall = searchResults[0].DoNotCall; le.TAB_Message__c = True; le.TAB_Timestamp__c = System.now(); lstupdate.add(le); } update lstupdate; ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'Record <b>'+searchResults[0].Name+'</b> has been Updated')); //creating a task Task tsknew = new Task(); tskNew.WhoId =searchResults[0].id; tskNew.Subject = 'Call'; insert tsknew; } Catch (DMLException e) { ApexPages.addMessages(e); return null; } searchText=''; searchResults.clear(); return null; } else { ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info,'Please enter REFID/FileNumber')); } return null; } public PageReference cancel() { pageReference pg1 = new pageReference('/apex/leadform1'); return(pg1.setredirect(true)); } }
Such error also comes when there is some exception, hence keep an eye on debug logs as well.
The profile assigned to the Site won't be shown in the list of profiles.
Follow the steps:
Develop->Sites->Select Site->Click on Public Access Settings button->Make changes here
I recently worked on similar project to create and then query and update lead from force.com site.
after much struggle, I came to know that you cannot query or update standard object records but you can do that on custom object. you can just use create operation.
so inorder to achive my requirement, I used a custom object and then was able to perform all these operations.
the ultimate goal was to convert that to account and contact, that i achived using custom button and apex code behind in similar lines as Convert Lead operation.
Public Access Settings, etc wont help you for leads or any standard object.
hope this helps you.
Hi,
Yeah as i mentioned i given all the permissions ,and as per my knoeledge i'm not getting any error here is my Debug log code
can you tell me where i'm going wrong
if you really want to use leads object then the options are let them create 2 leads with same values for the couple main fields then use internally duplicate merger
options
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003IYLlEAO (free)
or
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016cMzEAI (paid)
I dint go for these options though as I was able to convince my management to go with custom object.