Often times when working in NetSuite, we want to draw some HTML from one site into another. For example, we often display google doc spreadsheets within NetSuite when we want to present table information.
Here is a generic script that can be used either in a Portlet or Suitelet context. See how you can create script parameters that drive the way it works. This script can easily be enhanced to dynamically size correctly according to where the content is displayed.
function drawHTMLPage(request, response) { var context = nlapiGetContext(); if (context.getExecutionContext() == 'portlet') { var url = context.getSetting('SCRIPT', 'custscript_portlet_url'); var title = context.getSetting('SCRIPT', 'custscript_portlet_title'); var content = '<iframe width=100% height=100% style=height:500px; src=' + url + '></iframe>' request.setTitle(title) //really a portlet context request.setHtml(content) } if (context.getExecutionContext() == 'suitelet') { var url = context.getSetting('SCRIPT', 'custscript_suitelet_url'); var title = context.getSetting('SCRIPT', 'custscript_suitelet_title'); var content = '<iframe width=960px height=100% style="height:640px;" src=' + url + '></iframe>' var newForm = nlapiCreateForm('drawHTML'); var newField = newForm.addField ('content', 'inlinehtml', title); newForm.addField('extra', 'inlinehtml', '') newForm.setTitle (title); newField.setLayoutType('outsidebelow'); newField.setDefaultValue (content); response.writePage( newForm ) } }
During your deployment, specify the values for the script parameters. Or, dynamically in code from your custom NetSuite application, drive the script with parameters as needed.
If you are not a NetSuite developer and would like some help, be sure to contact us so we can set this up in your account.
Is there a way to pass custom values into the parameters that are set in the Portlet deployment? For example I want the url that is passed to this to be “https://www.linkedin.com/search/fpsearch?type=people&keywords=” so I can embed search results based on the contact that is being views. Is that possible?
Is there a way to pass custom values into the parameters that are set in the Portlet deployment?
For example I want the url that is passed to this to be “https://www.linkedin.com/search/fpsearch?type=people&keywords=NETSUITE+CONTACT+FULLNAME” so I can embed search results based on the contact that is being views.
Is that possible?
Thanks!
Hi Jeff,
In this case, the script doesn’t need to leverage the NetSuite parameter function. Instead, you will dynamically drive it from within the script based on information in the environment. However, I should ask, where will the NetSuite Contact Full Name come from? Meaning, if you are on portlet, how do you envision getting the NetSuite Contact Full name as data to that form?
Note, Portlets draw in the context of a dashboard, not in a contact record. Hence, if you are trying to get information to come up about a contact, I suggest a different approach. Instead, why don’t you add a new tab to the contact form and then under that tab, draw your own web page using a similar URL IFrame approach.
Jeff,
Just like that last response, the key question is, “Where is the data coming from to drive inputs?”. From there, we can figure out how to get it up on the URL.
Marty
Hey Marty,
My assumption is that a Portlet could be added on drilldown of a specific support case. Once its there wouldn’t I be able to access specific values of that Support Case (like the Contacts name?)
-Jeff
Jeff,
Indeed, if you start from the Portlet, and you select the case, you have all you need to know the contact. Now all you need to do is a redirect function to the contact record. It’s not SuiteScript definition parameters that drives this. It is just simply an nlapi redirect call.
Do you have screen shots of what you are trying to do?
Marty
Hey Marty,
Thanks for the help. I will try that.
I work at Buzzient and we are building out a Netsuite Social CRM integration similar to what we did for Salesforce, Siebel CRM, CRM On Demand, Zendesk and others. See our click through demo to get an idea of the Social CRM piece we are bringing to Netsuite https://www.buzzient.com/siebel-click-through-demo/ or for a 2 minute overview see how we integrated Facebook engagement into Oracle CRM On Demand https://www.youtube.com/watch?v=d9BLn49D20M
Would love to discuss with you more in depth what we are doing with Netsuite.
thanks,
Jeff
Hi Jeff,
Keep me informed on how your NetSuite Social CRM offering unfolds. I would be interested in giving you feedback when you are ready to make it work in NetSuite.
Marty
Thanks for your post on drawing external HTML pages in Netsuite.
I had a question about how to use it. You mention it’s a generic script, do we copy and paste it into a portlet script, or is it a Suitelet script that gets called by a portlet script?
I was looking up the Portlet scripts in help and I only saw two parameters (portlet, column), so I’m guessing this is a suitelet?
If you could add a bit more clarification on how to use it, that would be great.
Thanks,
Robert.
Hello Robert,
Yes, the NetSuite help document is suggesting a Portlet. Our script can be used either way during the definition of your Portlet or your Suitelet. Have a look at our logic. We can handle it either way because we are using Script parameters.
I plan on showing how to make the form automatically resize the existing window soon.
Marty
Hi Marty,
Hope you are doing well…!
Scenario is : User should be able to make changes to Sales Team without editing it.
For this case i have added custom tab and on this tab using inlinehtml field i am loading Suitelet. In this suitelet i am sourcing Sales team values and trying to edit it but i am not able to do so.
Same suitelet is working fine when loaded directly through url.
Requesting you to guide me on this.
Thanks,
Avinash.
Did you try setting the permission to Public and run as Anonymous?
Marty
Hi Marty,
I have implemented your code in form level(client) script but I am getting null request, response so can you please guide me
Thanks for all of your extremely helpful posts!
Do you know of a way to make the inlinehtml content to fill the page? Filling the width is pretty easy with width:100% on inline styles, but filling the height is another story and just wanted to see if you had a solution you could share?
Suitelet Code:
var form = nlapiCreateForm("My Form");
var fhtml = form.addField("content", "inlinehtml", "Content");
fhtml.setDefaultValue("");
response.writePage(form);
For example I’ve tried multiple variations of the following inlinehtml:
<iframe src="" style="border:0; width: 100%; min-height: 500px;">
But can’t seem to get the frame to fill the entire page vertically.
Thank you!
Good question. I haven’t tried this but did you see this article?
Can you access an external website that requires login? For example, could the portlet direct to facebook.com and then each user have the ability to log onto the website? Basically, a browser portlet.
Hi Josh,
So long as you can craft the request externally in JavaScript in the browser, then it would be possible. You may have to get access to the DOM so that you get more capacities to perform an HTTP Request.
Marty
Hi Marty!
Your posts on NetSuite are the best as usual.
I wanted to know your thoughts on this. I need to render a page on a Portlet/Suitelet (doesn’t matter). Is there any way in which I can include a in this iframe so that it runs an http request and redirects the result somehow to NetSuite?
The thing is that I have an API call that I need to make, but if I do it from the context of a SuiteScript with https.get(), I don’t get the response I need because is not my browser that is making the http call but NetSuite…and I need the call to be made with my browser because the call is expecting some cookies that will be only available there.
If I make the call from an iframe, I know it works, but I’m not sure how to route that value back to NetSuite so that I can use it from there.
Thanks in advance for your time!
Hello Ignacio,
I think I understand what you are getting at. My instinct is the only way to do what you are saying is to get at the Browser’s Document Object Model (DOM) to walk the tree to produce what is needed. Sometimes we inspect NetSuite’s supplied JavaScript functions to better understand what it is doing in the UI. As always, you are “on your own” when you take scripting matters into your hands. I don’t have any specific recommendation except to continue to be tenacious.
Marty