0

I have a suitelet that is adding an inlinehtml field which contains an iframe. The problem is when I try to use the API functions I get an error in the browser.

For example just trying to do var value = nlapiLookupField('customer', custid, custentity_mycustomfield');

Results in nlapiLookupField is not defined. Is there a way I can access the API by writing functions within my HTML page being called as an iframe? I'm open to suggestions, if there is a way I can include the functions as part of the suitelet and call them from the iframe I would do that but so far have not gotten it to work.

user290687
  • 87
  • 2
  • 11
  • If i got it correctly please check this answer [Stack Overflow answer](https://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe) – Beny Jul 23 '17 at 15:12
  • Nope, this is Netsuite both files are on the same domain. – user290687 Jul 23 '17 at 15:34

1 Answers1

2

If your iframe is all custom HTML then you won't have the suitescript client libs loaded.

I take care of this one of two ways:

  1. Call parent.nlapi...
  2. Load your iframe from a suitescript. This can be a really simple form with room to load your custom HTML

Of course if you go the second route why do you need the iframe? You carload quite a bit of custom HTML into a div inside an inline HTML field. In my experience that simplifies things quite a bit.

bknights
  • 14,408
  • 2
  • 18
  • 31
  • I meant to close this because I figured out the parent. last night. I actually just wrote my function in the Suitelet script then am just calling it like parent.myFunction(); from the frame. Thanks for the reply though, hopefully it will help someone else! – user290687 Jul 24 '17 at 14:28