0

I have created a VF page which display tooltip information and I want to display those tooltip in separate window or separate popup window during record creation. I have referred below link to open VF page from Toast message messageTemplateData link.

https://developer.salesforce.com/docs/component-library/bundle/force:showToast/documentation

Below is the code that I have tried:

showMyToast : function(component, event, helper) {
    var toastEvent = $A.get("e.force:showToast");
    toastEvent.setParams({
        mode: 'sticky',
        message: 'This is a required message',
        messageTemplate: 'Please Check Tooltip{0} First! & {1}',
        messageTemplateData: ['Salesforce', {
            url: 'https://myorg.salesforce.com/apex/myVFPageName',
            label: 'Click here',
            }
        ]
    });
    toastEvent.fire();
}

Now when I tested above code, it opens the link within same tab, But I want to open this link in other tab or in separate popup window.If Right Click then it opens in other tab but I want it in single click .If I use window.open(link,'_blank') then as soon as Aura component gets launched, it display toast message and at the same time it launches the link in other tab without manually clicking on the link.

showMyToast : function(component, event, helper) {
    var toastEvent = $A.get("e.force:showToast");
    toastEvent.setParams({
        mode: 'sticky',
        message: 'This is a required message',
        messageTemplate: 'Please Check Tooltip{0} First! & {1}',
        messageTemplateData: ['Salesforce', {
            url: window.open('https://myorg.salesforce.com/apex/myVFPageName/','_blank'),
            label: 'Click here',
            }
        ]
    });
    toastEvent.fire();
}

If I open any general link then its launching in other tab which is as expected but I am not sure why it's opening the same within same tab when launching VF page.

Below is the code which open link in other tab.

showMyToast : function(component, event, helper) {
    var toastEvent = $A.get("e.force:showToast");
    toastEvent.setParams({
        mode: 'sticky',
        message: 'This is a required message',
        messageTemplate: 'Record {0} created! See it {1}!',
        messageTemplateData: ['Salesforce', {
            url: 'http://www.salesforce.com/',
            label: 'Click here',
            }
        ]
    });
    toastEvent.fire();
}

Can someone please suggest how to open VF page in separate tab or in popup window from Toast Message messageTemplateData link?

1

I don't know a way of doing that with force:showToast, you can obtain a similar result using the lightning:overlayLibrary or creating a custom toast copying the SLDS toast blueprint.

4
  • Thanks for suggestion. Problem here is I have lightning Component where I display Next and Cancel button only & Record Type Select. Once I click on Next Button, with e.force:createRecord event ,it navigates to the standard page layout and i want to display those toast message there. Custom Toast message appear only on Aura, not on Standard Pagelyout. – Dhananjay Patil Jan 15 at 11:27
  • lightning:overlayLibrary also may not useful as When CreateRecord Page display then only I want to show Toast Message and from the docs, looks like I have to define in aura first and with onclick event, it gets triggered. again with e.force:createRecord, it may not be achievable. Could you please suggest other approach? – Dhananjay Patil Jan 15 at 11:30
  • That's a different issue then. Take a look at salesforce.stackexchange.com/questions/273670/…, and remember there's also a Notifications API that may help – Alba Rivas Jan 15 at 13:57
  • If I create such component and embedded it on my lightning page, will it appear it on Record Create layout? I believe it wont appear and notification API does not work in my case because I don't want to send notification to users. When User try to create record, only then I have to show that toast message which includes specific link of Tooltip. – Dhananjay Patil Jan 15 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.