0

I'm getting the below error when I'm trying to run the flow. Could someone please help me?

This page has an error. You might just need to refresh it.

Error in $A.getCallback() [Action failed: c:BELL_COMP_CarePassFlow$controller$doInit [Cannot read property '1' of null]] Failing descriptor: {markup://flowruntime:flowRuntimeV2}

Below is my controller.js


({
    handleGoBack : function(component){
        var workspaceAPI = component.find("workspace");
        workspaceAPI.getFocusedTabInfo().then(function(response) {
            var focusedTabId = response.tabId;
            workspaceAPI.closeTab({tabId: focusedTabId});
        })
    },
    /*onTabClosed : function(component, event, helper) {
        var tabId = event.getParam('tabId');
        console.log("Tab closed: " +tabId);
    },*/
    
    closeFocusedTab : function(component, event, helper) {
        var workspaceAPI = component.find("workspace");
        workspaceAPI.getFocusedTabInfo().then(function(response) {
            var focusedTabId = response.tabId;
            console.log("Tab Focused: " +focusedTabId);
            //workspaceAPI.closeTab({tabId: focusedTabId});
       })
        .catch(function(error) {
            console.log(error);
        });
    },
    doInit : function(component, event, helper) {
        
        //Get Extra Care Card Number and Pass to Continuation, then Launch Flow
        console.log('hey1:::');
        console.log('component.get("v.recordId")::'+component.get("v.recordId"));
        // console.log(component.get("v.pageReference").state.testAttribute);
        // component.find("articleURL").set("v.value", window.location.pathname);
        console.log('window.location.pathname::'+window.location.pathname);
        console.log('window.location.href::'+window.location.href);
        var recId = component.get("v.recordId");
        var url, captured, result;
        if(recId == undefined || recId == null){
            url = window.location.href; // or window.location.href for current url
            captured = url ? /CaseRecordId=([^&]+)/.exec(url)[1] : ''; // Value is in [1] ('384' in our case)
            result = captured ? captured : 'myDefaultValue';
            component.set("v.recordId", result);
            /*component.set("v.recordId", "5004C000006DU5FQAW");*/
        }
        
        
        console.log('url:::'+url);
        console.log('result:::'+result);
        
        console.log('component.get("v.recordId")::'+component.get("v.recordId"));
        
        //helper.myTestFunction2();
        helper.getExtraCareCardNum(component);
        console.log('hey2:::');
        let inputParam = {caseId: component.get("v.recordId")};
    },
    // onPageReferenceChange: function(cmp, evt, helper) {
    //     var myPageRef = cmp.get("v.pageReference");
    //     var recordId = myPageRef.state.c__CaseId;
    //     console.log('c__NewChild: '+id);
    //     cmp.set("v.recordId", recordId);
    // },
    // refreshIt: function(component, event, helper){
    //     component.find('accForm').submit();
    //     var recordId = component.get("v.recordId");
    //      var navService = component.find("navigationService");
    //     var pageReference = {
    
    //         "type": "standard__component",
    //         "attributes": {
    //             "componentName": "c__acapChecklist"    
    //         },    
    //         "state": {
    //              recordId: recordId
    //         }
    //     };
    //     navService.navigate(pageReference);    
    // }
})

1 Answer 1

2

The JavaScript RegExp.exec() method returns null if it does not match:

The exec() method executes a search for a match in a specified string. Returns a result array, or null.

It appears that your regex is not matching the current URL when you load this component in your Flow.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .