You need to sign in to do that
Don't have an account?
Jason Wenig
Visual Force Page Object ID in Lightning
Long ago, consultants built a visual force page that upon a newly created custom object, sets the lookup field object based on the current page. The custom object can be linked to a lead or to an opportunity.
Existing code:
String pId = controller.getId();
if (pId == null)
{
oTJC_Product = new TJC_Products__c();
if (ApexPages.currentPage().getParameters().get('retURL') != null)
{
Id pageId = ApexPages.currentPage().getParameters().get('retURL').Replace('/','');
if (pageId.getSObjectType().getDescribe().getName() == 'Lead')
{
oLead = [select id, name from Lead where id =:pageId];
oTJC_Product.Lead__c = pageId;
}
else
{
oOpportunity = [select id, name from Opportunity where id =:pageId];
oTJC_Product.Opportunity__c = pageId;
}
}
The above code works in classic as the URL had the ID on the end of the return URL BUT in lightning, the URL is different now and doesn't appear to contain the ID at all.
I'm not sure what the answer to replace ApexPages.currentPage().getParameters().get('retURL') in Lightning is but this should not be so difficult to do.
Apexpages.currentpage().getParameters().get('vfRetURLInSFX') does return a URL in lightning but the URL can't even be parsed to get an ID from the URL.
Please help.
Existing code:
String pId = controller.getId();
if (pId == null)
{
oTJC_Product = new TJC_Products__c();
if (ApexPages.currentPage().getParameters().get('retURL') != null)
{
Id pageId = ApexPages.currentPage().getParameters().get('retURL').Replace('/','');
if (pageId.getSObjectType().getDescribe().getName() == 'Lead')
{
oLead = [select id, name from Lead where id =:pageId];
oTJC_Product.Lead__c = pageId;
}
else
{
oOpportunity = [select id, name from Opportunity where id =:pageId];
oTJC_Product.Opportunity__c = pageId;
}
}
The above code works in classic as the URL had the ID on the end of the return URL BUT in lightning, the URL is different now and doesn't appear to contain the ID at all.
I'm not sure what the answer to replace ApexPages.currentPage().getParameters().get('retURL') in Lightning is but this should not be so difficult to do.
Apexpages.currentpage().getParameters().get('vfRetURLInSFX') does return a URL in lightning but the URL can't even be parsed to get an ID from the URL.
Please help.