This topic contains 10 replies, has 0 voices, and was last updated by k_dunc 7 years, 2 months ago.

  • Author
    Posts
  • #21573

    k_dunc

    Hi all,

    Something that I thought would have been so much simpler, but clearly isn't working for me just yet is I have a Client Script called upon the user pressing a custom button.

    Code:
    function CompleteLaterButton_BeforeLoad(type, form) {

    if (type == 'create' || type == 'edit') {
    form.addButton('custpage_complete_later', 'Complete Later', 'complete_later_cs()');
    form.setScript('customscript_expense_report_cs');
    }
    }
    Very simplistically, this Before Load script creates my button and sets the client script function to call when the button is pressed. No problems here – this is working just fine. What I want to achieve, however, is from this client script, I want to do some field setting – which also works – and then I want to save the record (i.e., this button is effectively another 'Submit' type button). Given that this needs to work on both Create and Edit events, what API do I call to save this Transaction record where I have no Record ID yet (i.e., a new record)?

    Thanks heaps,

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

  • #21574

    david.smith

    It might be best to do what you need on the after submit rather than trying to do it on the client side.

  • #21575

    k_dunc

    That's probably quite true David. So would this still be achievable with a custom button? Am I still able to create the custom button and run after submit code?

  • #21576

    david.smith

    If you need the ID, not on create. Unless you're just wanting to submit it you could just use the normal submit button (no need for a custom button) and run your script on the save event.

  • #21577

    ERPExperts

    You could have a checkbox the user checks when creating it, then the User Event will trigger After Submit, and looks at whether the said Checkbox is checked or not.

    If it is, set the value to 'F' and then execute the required logic.

  • #21578

    k_dunc

    Thanks for those responses. I guess my whole point to the question was that I'm attempting to replicate the "Complete Later" button functionality of the Expense Report. When you activate Expense Report Approval Routing, it turns off the "Complete Later" button, so I was attempting to figure out a way to: Display a button when someone is editing or creating an Expense Report (which I currently do from a User Event Script); and
    Call a script that stops this Expense Report from entering the next State of my Workflow – i.e., keep it as 'unsubmitted', thereby allowing the user to continue editing the Expense Report at a later time.

    So I still need the standard NetSuite Submit button, which should then send the Expense Report to the next State, but I needed my own 'Submit' ("Complete Later") button that sets my checkbox and then also saves the record. The issue I'm finding is that there doesn't appear to be a Client Script 'save record' API that doesn't require the record ID – unless I'm missing something?

  • #21579

    MikeBucklaew

    Maybe this is crazy but could you do something like add the "complete later" button using your workflow and use that button to call a workflow action script that "unsets" the "complete" check box, saves (this actually would probably have to be a "create" on a new) the record and then re-direct back to the expense report when the button is clicked?

  • #21580

    k_dunc

    Thanks for the suggestion Mike, but I don't believe that will work either. There's a current NetSuite Enhancement request to create a new API that allows the creation of a record from a button press – so who knows how far off something like that might be? Using a Workflow Action Script still won't allow me to save a new record I don't believe.


    MikeBucklaew replied on 06/19/2017, 08:10 AM: I think you’d have to actually read all the data, create a new record and then populate the fields and then submit. Sounds like a lot of work to code and I’m not sure it would work…

  • #21581

    pcutler

    I've run into this problem before too, and I don't have any great answers.

    It sounds like you're looking to implement a custom submit button. I tried using nlobjForm.addSubmitButton in the before load user event, and that just introduced JavaScript errors to the web page. So, instead, how about re-purposing one of NetSuite's built-in submit buttons such as "Save & Email." You could re-label "Save & Email" to "Save for Later" and trigger your code off of that button.

    But in my honest opinion, the best answer is to adjust your workflow instead of seeking a technical solution. How about a dialog box upon clicking save that asks the user whether they are done or saving their changes for later. Alternatively, as mentioned above, how about a checkbox for the user to select?

  • #21582

    k_dunc

    Thanks for that pcutler. I do have it working satisfactorily for my client. It does include a checkbox, then clicking the 'Submit' button in order to actually save the record. I don't mind your 're-purposing' suggestion though. Good one!


    dchinery replied on 08/22/2017, 08:23 AM: Hi Kirk, we have just seen a similar thing in that when we have standard NetSuite expense approval in place, everything seems to run fine but once we added the “Complete Later” button to the standard form, the approval workflow disappeared completely, therefore losing all of the approval process that we utilise. Did you ever find an alternate method for this that didn’t involve scripting or changing of standard forms?

  • #21583

    k_dunc

    Hi dchinery, I did get it working via Workflow and Client Script, so regrettably, to answer your question: no, nothing that didn't involve scripting or changing standard forms. Happy to help guide you through any of this if it will help?

    Cheers.

You must be logged in to reply to this topic.