You need to sign in to do that
Don't have an account?
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;
}
}
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;
}
}
so you are unable to update the record.
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