This topic contains 3 replies, has 0 voices, and was last updated by gourisankar 5 years, 9 months ago.

  • Author
    Posts
  • #21946 Score: 0

    vandite
    • Contributions: 0
    • Level 1

    Hi Everyone

    I'm seeking a solution for an issue I have tried to source online but haven't had much luck.

    Here's what I'm trying to achieve:

    1. Add a button to customer record (via user event script or via inline HTML value which calls a function within the form's client script)

    2. When the button is clicked, a popup window containing a suitelet assistant form will load

    3. The user goes through the assistant steps and once submitted, they will be returned a value

    4. The value is passed from the Suitelet back into the customer record and populated within a custom field

    The part that I'm unfamiliar with is how to get the value back from the suitelet to be populated into the customer record's custom field. I know how to use nlapiRequestURL via a client script to obtain information on a POST request Suitelet but have never tried to use a popup form where the user needs to go through steps to get the value.

    Has anyone managed to achieve a similar type of requirement? The solution needs to not involve any refreshes of the customer record and must be available on create/edit.

    Thanks
    This is a cached copy. Click here to see the original post.

  • #21947 Score: 0

    Olivier Gagnon NC
    • Contributions: 0
    • Level 1

    Sounds like you want to use the window.opener reference in the Suitelet to write back to the customer. That isn't quite the whole picture though… you'll need to figure out how the customer can figure out it has just been modified to act on it. If your customer is in View mode, that's a bit of a problem. The architecture I typically due in a write-back situation like this would be for the Suitelet to edit the customer directly (using NS APIs – record.setValue kind of deal) and then refresh the window holding the customer record, so the write-back is visible to the user. If you have a requirement not to do that, for some reason, that makes things a little hard.


    vandite replied on 06/24/2018, 08:35 AM: Hi Olivier

    Thanks for your response. The customer will be in create/edit mode. Unfortunately refreshing the customer record isn’t an option as they might be creating a new customer, have half of the fields populated and then choose to run this process. The record will not have any internal ID at this point for the suitelet to reference back to.

    Previously to bypass any role restrictions on client scripts, I have utilised nlapiRequestURL to do a POST request to a suitelet in order to return the restricted data required. What I was hoping for was something similar.

    I have an inline HTML field which contains the default value:

    The performSearch function is contained in a client script applied to the specific customer form.

    The performSearch function would load the suitelet form in a popup and the user would go through the assistant and the end value will be returned back to the client script variable “endValue”.

    The value would then be populated into a custom field: nlapiSetFieldValue(‘custentity_search_result’, endValue);

    This could actually not be possible but was hoping someone out there might have an idea on how to achieve this.

  • #21948 Score: 0

    Olivier Gagnon NC
    • Contributions: 0
    • Level 1

    I think you should be able to use window.opener to write back to the customer record. That being said, if you're just using the Suitelet as a data middleman and there is no UI component needed, then you can switch to a non-UI Suitelet and just request it, and the response will be the value you need. Then everything is settled within a single http request. No need for cross-window concerns.

  • #21949 Score: 0

    gourisankar
    • Contributions: 0
    • Level 1

    Hi Vandite,

    you can try below code on post section of the suitelet

    var html = '<html>';

    html += ' <body>';

    html += ' <script language="JavaScript">';

    html += ' if (window.opener) {';

    html += ' window.opener.nlapiSetFieldValue('' + fieldname+ '', '' + fieldvalue+ '');';

    html += ' }';

    html += ' window.close();';

    html += ' </script>';

    html += ' </body>';

    html += '</html>';

    response.write(html)

You must be logged in to reply to this topic.