Wednesday, 15 April 2020

Get Parent Record Id From Lightning URL



In component Create an attribute.

<aura:attribute name="recordId" type="String"/>


In Init method use the below code to get parent record Id from Related list.

        var pageRef = component.get("v.pageReference");      
        console.log(JSON.stringify(pageRef));      
        var state = pageRef.state; // state holds any query params      
        console.log('state = '+JSON.stringify(state));      
        var base64Context = state.inContextOfRef;      
        console.log('base64Context = '+base64Context);      
        if (base64Context.startsWith("1\.")) {          
            base64Context = base64Context.substring(2);          
            console.log('base64Context = '+base64Context);      
        }      
        var addressableContext = JSON.parse(window.atob(base64Context));      
        console.log('addressableContext = '+JSON.stringify(addressableContext));
        component.set("v.recordId", addressableContext.attributes.recordId);
        console.log('rec Id---'+component.get("v.recordId"));

reference : https://sfdclesson.com/2019/11/23/get-parent-record-id-from-lightning-url/


Thursday, 9 April 2020

Disable right-click in Salesforce Lightning Page



component add this:

<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

In JS file add this in doInit:

doInit : function(component, event, helper) {
       document.addEventListener('contextmenu', event => event.preventDefault());

},

Tuesday, 7 April 2020

Download any video from Google Chrome


Follow the below steps on your computer/laptop in chrome (recommended).
  1. Login to udemy go to the course and play the lecture, for eg. first lecture is running
  2. Open ‘Developer tools’ by pressing ‘F12’ go to the ‘sources’ tab
  3. Switch to ‘Snippets’ tab
  4. Add new snippet with any name for eg. ‘udemy-downloader
  5. and paste the code below

    1. var videoLink = document.querySelector(".vjs-tech").getAttribute('src');
    2. window.open(videoLink,'_blank');
  6. Save the snippet file using ‘ctrl+s
  7. And now Right click on the snippet file (udemy-downloader) which have the scripts and click on Run
    It will download the video for you in selected Quality - (on which it is playing)
  8. Now you only need to follow step number to download your favorite lecture.

    Hope this is helpful :)