You need to sign in to do that
Don't have an account?
Jason Wenig
Lightning Issue - Classic works to Get Parent ID upon creation, Lightning error
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 highlighted code works in Classic and does not work in Lightning. I assume it is because the URLs are not the same between Classic and Lightning so getting the record ID from the Return URL no longer works. Is there a simple fix for this to get the record ID a different way than through the return URL?
The page is called via a button on either the Lead or Opportunity object. The at the highlighted text is: System.StringException: Invalid id: lightningcbrecord-actions?objectApiName=TJC_Products__c&actionName=new&inContextOfRef=1
{
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 highlighted code works in Classic and does not work in Lightning. I assume it is because the URLs are not the same between Classic and Lightning so getting the record ID from the Return URL no longer works. Is there a simple fix for this to get the record ID a different way than through the return URL?
The page is called via a button on either the Lead or Opportunity object. The at the highlighted text is: System.StringException: Invalid id: lightningcbrecord-actions?objectApiName=TJC_Products__c&actionName=new&inContextOfRef=1
Greetings!
Can you please double check,if the record has parent record value.Also,try this with the same record in classic as well to make sure it has the parent record as well cause the code looks good for me.
Also,please check the below blog for the things to take care when we use them in lightning:
http://xintongzhang.blogspot.com/2016/02/things-to-watch-out-for-when-using.html
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri