• Jason Wenig
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 0
    Replies
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.
 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
My org uses a Detete trigger to prevent the Salespeople from removing tasks assigned to them.  Somehow the following delete trigger on the Task is being called during the association of an Email via Outlook to an Account or Opportunity.  The trigger is not called when associated to a Contact.  I'm not sure how to update the trigger to get around this issue.

trigger NoDeleteonTask on Task (before delete)
{
   String ProfileId = UserInfo.getProfileId();  
   List<Profile> profiles=[select id from Profile where name='TJC Business Development User' or name='TJC Business Development User No Transfer'];

   if (2!=profiles.size())
   {
      // unable to get the profiles - handle error
   }
   else
   {
       for (Task a : Trigger.old)      
       {            
          if ( (profileId==profiles[0].id) || (profileId==profiles[1].id) )
          {
             a.addError('Business Development profiles cannot delete tasks');
          }
       }            
   }
We currently have Salesforce using ADFS 2.0 for SSO and working properly.   Our security team wants to move everyone from ADFS 2.0 to ADFS 4.0 so I was looking for implemenation information on the differences when you are moving to the newest version of ADFS.  All the existing documentation refers to ADFS 2.0.   

Will Salesforce work with ADFS 4.0 today?  If so, what changes do you need to make when moving to the newest version.   Someone out there must have accomplished this already.   I don't see any articles out there on ADFS 4.0 and SSO.
My org uses a Detete trigger to prevent the Salespeople from removing tasks assigned to them.  Somehow the following delete trigger on the Task is being called during the association of an Email via Outlook to an Account or Opportunity.  The trigger is not called when associated to a Contact.  I'm not sure how to update the trigger to get around this issue.

trigger NoDeleteonTask on Task (before delete)
{
   String ProfileId = UserInfo.getProfileId();  
   List<Profile> profiles=[select id from Profile where name='TJC Business Development User' or name='TJC Business Development User No Transfer'];

   if (2!=profiles.size())
   {
      // unable to get the profiles - handle error
   }
   else
   {
       for (Task a : Trigger.old)      
       {            
          if ( (profileId==profiles[0].id) || (profileId==profiles[1].id) )
          {
             a.addError('Business Development profiles cannot delete tasks');
          }
       }            
   }