HTML Portlet: Entity Internal ID I'm using a very...
# suitescript
r
HTML Portlet: Entity Internal ID I'm using a very simple Portlet script (included below) to embed a Power BI report into Customer Dashboards. Works great. Q: How can I determine the InternalID of the customer record where the portlet is viewed so I can pass this as a variable on the PowerBI URL (ie to filter the PowerBI report)? I've figured out the PowerBI syntax with their Table/Field name and have tested this successfully if I manually hardcode a value in the URL. I've seen references to params.entity (N/record ?) and tried options from examples online to no avail. Any suggestions would be appreciated. Thanks!
Copy code
*@NApiVersion 2.x
 *@NScriptType Portlet
 */
define([],
    function() {
        function render(params) {
            params.portlet.title = 'PowerBI Test';
            var content = '<iframe width="100%" height="640" frameborder="0" src="<https://app.powerbi.com/reportEmbed?reportId=123Test>"></iframe>';
            params.portlet.html = content;
        }
        return {
            render: render
        };
    });
n
@RL I don't have an answer to this but in the absence of a response from someone that does know, I wonder have you tried logging "params.portlet" or even "params" to see what they contain? Failing that maybe you can use client script to see the url and ascertain the id that way? Must admit I've not written many portlet scripts over the years.
d
@RL This has been working for one of my portlets. Not sure if it's the correct/most efficient way to do it, but it works. I know I've gotten URL parameters differently in other scripts, not sure why I did it this way (possibly a limitation of a portlet) var pageHeaders = request.getAllHeaders()['referer']; var custID = pageHeaders.split('entityid=')[1].split(',')[0];
Note: This is from a 1.0 script. I just notice you're using 2.0. It will probably need some slight modification.
r
@PNJ
params.entity Verified it with params.portlet.html = params.entity & it shows the correct ID on the customer dashboard (same ID as in the URL entityid=5 )
Thank you! Wow ... I have been overthinking this when it was right in front of me. Was able to source the internalid using your example. So the last piece ... is it simply a matter of including +params.entity+ in the URL to pick up the value?
p
Yes