• SFDC Traning 6
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hello - I need some help translating some functionality from an Apex Trigger that has been added to my org previously by a developer. 
I've figured out most of the code, but I'm not sure what the Decimal TempCounter is and why it is used. 
Can anyone give me a line by line translation to layman's terms of the below code:

map<id,decimal> leadcounterMap = new  map<id,decimal>();
   
    Set<id> duplicateids = new Set<id>();
    
    for(Task t: (trigger.isinsert) ? trigger.New : trigger.old)
    {
        if(t.Whoid != null)
        {
            //Rollingup for Leads
            if(String.ValueOf(t.Whoid).startsWith('00Q'))
            {
                if(leadcounterMap.keyset().contains(t.Whoid))
                {
                    Decimal TempCounter = 0;
                    TempCounter = leadcounterMap.get(t.Whoid);
                    TempCounter++;
                    leadcounterMap.put(t.Whoid,TempCounter);
                }
                else
                {
                    Decimal TempCounter = 1;
                    leadcounterMap.put(t.Whoid,TempCounter);
                }
            }
 //rolling up leads activity count 
    for(Lead l : leads)
    {
        Lead TempLead = leadTaskMap.get(l.id);
                
        if(TempLead.No_Of_Activities__c == null)
            TempLead.No_Of_Activities__c = 0;
        
        if(Trigger.isInsert)
            TempLead.No_Of_Activities__c  += leadcounterMap.get(l.id);
        else if(Trigger.isDelete)
            TempLead.No_Of_Activities__c  -= leadcounterMap.get(l.id);
        
        leadstoUpdate.add(TempLead);
    }

Thanks!
James
There's documentation and a number of articles about how you can have an LWC component open a page, including with query parameters (such as this one (https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.use_navigate_add_params_url) from the official documentation). There's also documentation about how you open different types of page, though the NavigationMixin doesn't support direct VF page access.

It appears that, while we can set up a custom tab that wraps the VF page, the VF page is then embedded in an iframe and, due to the lightning and VF pages residing on different domains, there's no communication possible across the iframe boundary (so the query parameters are not visible).

I need to be able to open a VF page from an LWC and pass it several query parameters. My issue is that none of the mechanisms explain how I can get the base URL for a VF page that will work from my LWC (I need to do this for standard and community portal usages).

There's even an article, here (https://developer.salesforce.com/blogs/developer-relations/2017/01/lightning-visualforce-communication.html), that discusses the basic issue (at least in the Aura context). Unfortunately it entirely glosses over how to get the URL for the VF page, simply saying:
 
"vfHost is the host Visualforce pages are loaded from in your environment. In a real-life application, you should obtain this value dynamically instead of hardcoding it"

Do you know how I can obtain the VF page URL in a robust and automatic way from Salesforce (since this component will be part of a package I can't hard-code the access)?
  • August 19, 2019
  • Like
  • 0