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
MaggieSumitMaggieSumit 

Hi I am using URL Rewriting in salesforce, i able to reterive the details using id but i am not able to update the field.

Hi I am using URL Rewriting in salesforce, i able to reterive the details using id but i am not able to update the field.
http://**************************************force.com/standardpage?id=00Q2800000HeVCN
global class URLRewriterClass implements Site.UrlRewriter 
{
 //Variable to represent the friendly URLs for pages
 String DIRECTORY = '/standardpage/';
 //Variable to represent my custom Visualforce pages that display page information
 String VISUALFORCE_PAGE ='/standardpage?id=';
 // The first global method for mapping external URL to an internal one
 global PageReference mapRequestUrl(PageReference myFriendlyUrl)
 {
    String url = myFriendlyUrl.getUrl();
    System.debug('******************************'+url);
    if(url.startsWith(DIRECTORY))
    {
       String name = url.substring(DIRECTORY.length(),url.length());
       //Select the ID of the page that matches the name from the URL
       Lead site_page = [select id from Lead where name=:name LIMIT 1];
       System.debug('******************************'+site_page.id);
       //Construct a new page reference in the form of my Visualforce page
       return new PageReference(VISUALFORCE_PAGE+ site_page.id);
    }
    return null;
  }
  // The second global method for mapping internal Ids to URLs
  global List<PageReference> generateUrlFor(List<PageReference> mySalesforceUrls)
  {
    //A list of pages to return after all the links have been evaluated
    List<PageReference> myFriendlyUrls = new List<PageReference>();
    for(PageReference mySalesforceUrl : mySalesforceUrls)
    {
      //Get the URL of the page
      String url = mySalesforceUrl.getUrl();
      //If this looks like a page that needs to be mapped, transform it
      if(url.startsWith(VISUALFORCE_PAGE))
      {
        //Extract the ID from the query parameter
        String id= url.substring(VISUALFORCE_PAGE.length(), url.length());
        Lead site_page2 = [select name from Lead where id =:id LIMIT 1];
        //Construct the new URL
        myFriendlyUrls.add(new PageReference(DIRECTORY + site_page2.name));
     } 
     else
     {
       myFriendlyUrls.add(mySalesforceUrl);
     }
  }
  //Return the full list of pages
  return myFriendlyUrls;
  }
}
Nachu RY 4Nachu RY 4
In SITE ,If you are using standard object in Standard controller, You can have only read and create permission .You are not having update permission.
so you are unable to update the record. 
MaggieSumitMaggieSumit
IS THERE ANY WAY TO ENABLE UPDATE IN LEAD OBJECT
 
Nachu RY 4Nachu RY 4
you can 't enable update update permission to Lead.
1) create a custom object, write the trigger to copy all all data form Lead to Custom object.
2) showcase the custom object in the site.
3)write the trigger (after update)in the custom obectct that , it will update the lead.

Thanks