This topic contains 3 replies, has 0 voices, and was last updated by pcutler 6 years, 6 months ago.

  • Author
    Posts
  • #21232

    GusGus

    I'm using nlapiResolveURL() to open a record in edit mode. I was previously using this function to make a copy of a record and open it in edit mode. When it was set up that way I was able to pass parameters in the url. Now that I'm just opening the record itself in edit mode and not creating a new record and opening it in edit mode, I cannot pass parameters in the URL. A custom button is triggering a client script that has nlapiResolveURL() opening the purchase order record in edit mode. Is there a way to pass something along with this url to communicate to a user event script that this has been opened in edit mode through a custom button and not the normal edit button? In the before load I can check to see that the request is null and that works. However, I need to know in the before submit. I can set a field in the before load that flags it as a custom edit and not a regular edit, but then if the user were to cancel or close the browser window that flag would still be set and I need it not to be. Any ideas?
    This is a cached copy. Click here to see the original post.

  • #21233

    GusGus

    I just wanted to add that basically what I'm trying to do is allow users to make changes to a purchase order, save a copy of the way the purchase order was before being edited, send that edited purchase order through an approval process, and if it is rejected, be able to turn the data on the purchase order back to the way it was before the edit. Right now the only way I can figure out to make the copy of the pre edit record is to copy it in the before load and submit it. However, when I do that I won't know if the user canceled the edits so I can delete the copy that will now not ever be needed. I'm also flagging the purchase order as being a custom type of edit in the before load which is problematic for the same reason. If the user closes the browser window or cancels, I have no way of knowing so that I can remove the flag from the record. Ideally I'd like to not make any submits until I know the user is going to submit their edits but I can't find a way to do that yet.

  • #21234

    pcutler

    The nlapiResolveURL method returns the URL as a string, so to append parameters you can use string concatenation. Make sure to use encodeURIComponent to escape necessary characters.


    GusGus replied on 05/08/2018, 02:07 PM: I’m unable to load the request in the before load. I get an error saying that request is undefined. The request object is null.

    My client script where I create the url:

    var url = nlapiResolveURL(‘RECORD’, ‘purchaseorder’, recordId, ‘edit’) + ‘&isCustomCopy=1’;

    My user event before load function where I am trying to get the parameter:

    var isCustom = request.getParameter(‘isCustomCopy’);

    nlapiLogExecution(‘DEBUG’,’custom?: ‘, isCustom);

    Error:

    nlobjError

    code

    :

    “UNEXPECTED_ERROR”

    description

    :

    “TypeError: Cannot call method “getParameter” of undefined (bsi_po_change_request_record_prep_ue.js$238675#74 )”

    details

    :

    “TypeError: Cannot call method “getParameter” of undefined (bsi_po_change_request_record_prep_ue.js$238675#74 )”

  • #21235

    pcutler

    You're right that the request parameter is not available in the before load user event script in all contexts. You need to check that it is defined before attempting to use it.

    From Help:

    request : an nlobjRequest object representing the GET request (Only available for browser requests.)

You must be logged in to reply to this topic.