This topic contains 1 reply, has 0 voices, and was last updated by starlingMark 5 years, 11 months ago.

  • Author
    Posts
  • #21245 Score: 0

    Ferdinand
    • Contributions: 0
    • Level 1

    Hello,

    I'm just getting start on Suitelets and need some help:

    In one of our Client Scripts when the user clicks on a button they are prompted to enter a date which is then processed by the script to update the record.

    Currently I'm using a Javascript prompt() together with nlapiStringToDate, but for better usability I'd like to replace this with a datepicker using NetSuite's UI elements.

    I got as far as creating and deploying the following Suitelet script:

    Code:
    function selectDateForm(request, response)
    {
    if(request.getMethod() == 'GET')
    {
    var dateForm = nlapiCreateForm('Select Date', true);
    dateForm.addField('custpage_newdate', 'date');
    dateForm.addSubmitButton();
    response.writePage(dateForm);
    }
    else
    dumpResponse(request, response);
    }
    But now I'm at a loss how to open the Suitelet in a popup and return the entered date to a variable in the Client Script.

    I can get a button to open the Suitelet in a popup, but when clicking the Save button the popup window redirects and displays an error:

    Code:
    ReferenceError: "dumpResponse" is not defined.
    Instead I want the popup to return the entered date and close itself.
    This is a cached copy. Click here to see the original post.

  • #21246 Score: 0

    starlingMark
    • Contributions: 0
    • Level 1

    Hi Ferdinand,

    Perhaps a better method would be to have your Suitelet collect/validate the date and update the record. You could do that like this:

    1.) Have your button hit a client script (or do a window.open) on the URL for your Suitelet (this can be retrieved from the deployment record or nlapiResolveURL).

    2.) As you have above, on GET, have your suitelet collect/validate your date

    3.) On POST, use nlapiSubmitField to update the record you care about

    4.) Have the POST response from the suitelet close the popup and reload the opening window, thus displaying the new date


    Ferdinand replied on 05/16/2018, 03:57 AM: I see, thanks for the idea. But then all the logic for actually using the date would have to be part of the Suitelet, right?

    I was thinking to keep it more universal and just return the date because I have date selections in 3 different places.

    The way it works is that the user can click buttons on the items sublist when the transactions are in edit mode, the entered date is then used to update a custom column field (of type date) for all lines on the transaction.

    Reloading the opening window while in edit mode would be a problem because then it will lose all entered/unsaved changes.

You must be logged in to reply to this topic.