This topic contains 5 replies, has 0 voices, and was last updated by Godrules500 6 years, 7 months ago.

  • Author
    Posts
  • #18395

    borncorp

    Hey guys, just letting you know that I encountered an issue recently. I was trying to create a Suitelet “Available without Login” that uses a form and I was attaching a button and a clientscript to it, but guess what? The button doesn’t work. I checked the console and every time I call the button I get “require is not defined” error:

    So I stripped the suitelet to the most barebones version and I still got the error. I verified with others and it seems to be a defect from SS2.0 External Suitelets.

    At the end of the day I was able to run the code by hacking the dom like so:

    Code:
    form.addButton({
    id : ‘custpage_mybutton’,
    label : ‘MyButton’,
    functionName : ‘runButtonClickAction’
    });

    var fileContents = file.load(5835).getContents();
    var field = form.addField({
    id: ‘custpageinjectcode’,
    type: ‘INLINEHTML’,
    label: ‘Inject Code’
    });
    field.defaultValue = ““;
    and as the clientscript file I have this:

    Code:
    $(‘custpage_mybutton’).onclick = function(){ runButtonClickAction(); }

    function runButtonClickAction(){
    alert(‘Button clicked’);
    }

    Totally not recommended, but just throwing it out there.
    This is a cached copy. Click here to see the original post.

  • #18396

    david.smith

    Is your CS code available w/o login?

  • #18397

    borncorp

    Originally posted by david.smith

    View Post

    Is your CS code available w/o login?

    Yes, the file with the clientscript is available without login.

  • #18398

    Godrules500

    I tried modifying the above to add an onload function (which isn’t working). Do you know if there is a way to add an onload and use the N/ui/message module?

    Also, the script I have that does follow your code, there is a button a text box. The button click works. However, when I hit enter in the textbox it takes me to a blank page. Know of a way to prevent this?

  • #18399

    Vesku1980

    Is it true that this feature is still like this, that you can’t run client script with External Suitelet?

  • #18400

    Godrules500

    This is changing in 2018.1 I believe. So you should be able to run client script on an external suitelet.

You must be logged in to reply to this topic.