cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JinJia Frequent Visitor
Frequent Visitor

Integrate PowerBI with Netsuite

Hi, devs

 

I'm currently integrating PowerBI with Netsuite.

 

I'm facing an issue. I want to know the way to get access token with Javascript API.

 

Looking forward to hearing from you asap.

 

Thanks,

Jin

12 REPLIES 12
Moderator Eric_Zhang
Moderator

Re: Integrate PowerBI with Netsuite

@JinJia

 

You can embeded report with Javascript API, check Embedding Basics. However AFAIK, there's no way to get accesstoken in Javascript, you would have to get the token in backend(eg in C#) and pass it to the page.

I have no idea on Netsuite and not sure what you can do in it. Maybe ask the question how to integrate an C# app with Netsuite in the dedicated forum.
 

JinJia Frequent Visitor
Frequent Visitor

Re: Integrate PowerBI with Netsuite

Hi, Eric

 

I'd like to ask you a few more questions.

 

As I metioned before, I'm integrating PowerBI with Netsuite.

 

I'd like to import Sales Order reports from NetSuite to PowerBI.

 

I think, the only way I can do this is to import sales order record one by one.

 

I tried to use PowerBI REST API before but I can't find solution.

 

PS: NetSuite only provide Javascript API so integration should be done only by Javascript. So I think C# is not solution.

 

Can you please give me some reference for it?

 

Please ask me any questions you might have.

 

Looking forward to hearing from you asap.

 

Sincerely,

Jin

Moderator Eric_Zhang
Moderator

Re: Integrate PowerBI with Netsuite

@JinJia

Then my approach would be using Power BI Embedded, check Power BI emebedded VS Rest API.

 

  1. Import the records to powerbi desktop,design the report and upload it to a workspace. Regarding data refreshing, check this link.
  2. Generate an accesstoken that never expires(not recommended).
    var embedToken = PowerBIToken.CreateReportEmbedToken(this.workspaceCollection, this.workspaceId, report.Id,Convert.ToDateTime("2099-12-31"));
  3. Embed the report with PowerBI-Javascript. You can save the below sample in a html file and run in brower, my token in this test wouldn't expire before 2018 year.
     
    <html>

    <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/jquery/dist/jquery.js"></script>
    <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/powerbi-client/dist/powerbi.js"></script>

    <script type="text/javascript">
    window.onload = function () {

    var embedConfiguration = {
    type: 'report',
    accessToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXIiOiIwLjIuMCIsIndjbiI6IndvcmtzcGFjZUNvbGxlY3Rpb240UEJJIiwid2lkIjoiYjVkMDJiYmItODcxNy00MmJlLWEzMTMtZDEyYTdmYzk0OTcyIiwicmlkIjoiMjlhNDcxNGYtYzQzMi00ZjEwLTk5ZTMtNzA1MzhmNGJlYmUwIiwiaXNzIjoiUG93ZXJCSVNESyIsImF1ZCI6Imh0dHBzOi8vYW5hbHlzaXMud2luZG93cy5uZXQvcG93ZXJiaS9hcGkiLCJleHAiOjE1MTQ2NDk2MDAsIm5iZiI6MTQ4MDAyOTQ4Nn0.GC1iQa1Xghkp9o4R87DcRjaLe9a0PBN7wxYOJKFDd5Y',
    id: '29a4714f-c432-4f10-99e3-70538f4bebe0',
    embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed?reportId=29a4714f-c432-4f10-99e3-70538f4bebe0'
    };

    var $reportContainer = $('#reportContainer');

    var report = powerbi.embed($reportContainer.get(0), embedConfiguration);


    }
    </script>

    <div id="reportContainer"></div>

    </html>
Anonymous
Not applicable

Re: Integrate PowerBI with Netsuite

Check out our solution for this... 

https://www.youtube.com/watch?v=dbOQDLZi1Xc&t=5s 

e-mail me for more details

 

-Josh

sandralynn Frequent Visitor
Frequent Visitor

Re: Integrate PowerBI with Netsuite

Hi @JinJia

 

The ability to connect NetSuite to Power BI is a common, highly requested idea on the Power BI ideas website. As such, there is very little information available regarding how to connect NetSuite to Power BI. Elegant alternative solutions that integrate NetSuite to Power BI by automating data refresh.

 

  1. Purchase the SuiteAnalytics Connect (ODBC) functionality from NetSuite
  2. Leverage NetSuite’s Web Query report functionality

Thanks.

EP_Jack Frequent Visitor
Frequent Visitor

Re: Integrate PowerBI with Netsuite

If you enable webquery on a saved report, you can then download a .igy file,

 

open this in a text editor  strip out  everything before htts:\\

 

and strip out the following from the end

 

Formatting=All
PreFormattedTextToColumns=True
ConsecutiveDelimitersAsOne=True
SingleBlockTextImport=False

 

replace 

 

["emailaddress","Please enter your email address:"]

 

with 

 

your.name@domain.com

 

then copy the string and go into PBI and got o data sources and use a web data source, paste this in and use an anonmous authentication, and away you go

 

i've also created a powershell scrip with a smilar function to sync to local MSSQL DB and then you can point PBI to a SQL DB, personal prefernce which way round you want to access your data

Anonymous
Not applicable

Re: Integrate PowerBI with Netsuite

Check out www.tacticalconnect.com for a solution.

SQLMonger Frequent Visitor
Frequent Visitor

Re: Integrate PowerBI with Netsuite

Would you be willing to share the PowerShell script you create for pulling data from NetSuite? 

 

 

EP_Jack Frequent Visitor
Frequent Visitor

Re: Integrate PowerBI with Netsuite

sure this is the PSS i used to go into a local SQl server

 

Invoke-Sqlcmd -Query "DELETE FROM [Netsuite].[dbo].[Customer_Product_Sales];" -ServerInstance "#########\SQLEXPRESS"
$url ="web address from Netuite as described in my original post"

$WebResponse = Invoke-WebRequest -uri $url
$content = $WebResponse.Content
$content = $content.replace('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body><table>', "" )
$content = $content.replace('</table></body></html>', "")
$content = $content.replace('</td>', "")
$content = $content.replace('</tr>', "")
$content = $content.replace('<tr>', "#" )
$content = $content.replace('<td>', "^^")
$content = $content.replace("`t|`n|`r", "")


$array = $content.Split('#')
ForEach ($tr in $array)
{
$TD = $tr.Split('^^')
if ($TD.count -gt 1)
{
$CustomerID = $TD[4] -replace "`n","" -replace "`r","" -replace "=-","" -replace "=","" -replace "'",""
$Customer = $TD[6] -replace "`n","" -replace "`r","" -replace "=-","" -replace "=","" -replace "'",""
$Customer_Ref = $TD[8] -replace "`n","" -replace "`r","" -replace "=-","" -replace "=","" -replace "'",""
$QTY = $TD[10] -replace "`n","" -replace "`r","" -replace "=-","" -replace "=",""
$Year = $TD[12] -replace "`n","" -replace "`r","" -replace "=-","" -replace "=","" -replace "'",""
$yyy_MM = $TD[14] -replace "`n","" -replace "`r","" -replace "'",""
$Total_Revenue = $TD[16] -replace "`n","" -replace "`r","" -replace "=",""
$Brand = $TD[20] -replace "`n","" -replace "`r","" -replace "=-","" -replace "=","" -replace "'",""
$Category = $TD[22] -replace "`n","" -replace "`r","" -replace "=-","" -replace "=","" -replace "'",""
$Item = $TD[24] -replace "`n","" -replace "`r","" -replace "=-","" -replace "=","" -replace "'",""
$Description = $TD[26] -replace "`n","" -replace "`r","" -replace "=-","" -replace "=","" -replace "'",""

 

 

Invoke-Sqlcmd -Query "INSERT INTO [Netsuite].[dbo].[Customer_Product_Sales] (Customer_ID , Customer , Brand , Category , Item , Customer_Ref , Description , Qty , Total_Revenue, Year , YYYY_MM) VALUES ('$CustomerID', '$Customer', '$Brand', '$Category', '$Item', '$Customer_Ref', '$Description', '$Qty', '$Total_Revenue', '$Year', '$yyy_MM');" -ServerInstance "#######\SQLEXPRESS"

}}