1

Java script newbie here.

I have this Sisense function called 'handler' that will make all values in a column a hyper link:

widget.transformPivot({
   type: ['member'],
    rows: [
        {
            title: 'Product User',
        }
    ],
}, handler);

I have another function that builds a new url and replaces the value in the same column mentioned above with a constructed url (the details of which are not important for this question):

function createLinkHTML(cell, tag, inner){
    //setup regex to match relevant parts of url and get match
    let prePatt = new RegExp(".*:\/\/.*?\/");
    let preURL = String(prePatt.exec(window.location.href));

    if (preURL.includes("analytics1")){
        preURL = preURL.replace('https://analytics1.foo.com','https://www.newfoo.com');
        //console.log(preURL);
    }

    if (inner.length > 0){
        console.log(inner[0].innerText);
        var htmlLink = `<a href="${preURL}/users/users/details/${inner[0].innerText}" target="_blank" >` + 'Go to User Profile' + '</a>';//+ linkArr[0] + URLParams

        $(tag, cell).html(htmlLink);
    }
}

To call the Sisense function 'handler' we use this code:

function handler(metadata, cell) {

    cell.content = '<a>' + cell.content + '</a>';
}

To call the function 'createLinkHTML' we use:

widget.on('ready', function(_, __){   
    addUserLink(element, widget);
});

I am trying to understand how to combine these two functions so that I can replace the value in the column with a url using 'createLinkHTML' and then use 'handler' to make the new urls in that column a hyper link.

Forgive the question if a totally newbie one. I can't seem to find info that helps me here. I just signed up for a javascript class to learn the fundamentals. but I need to figure this out soon. Thanks.

Kierk
  • 476
  • 6
  • 23

0 Answers0