This topic contains 5 replies, has 0 voices, and was last updated by michoel 8 years, 3 months ago.
-
AuthorPosts
-
August 8, 2016 at 3:23 am #6254
SooSHi Everyone,
I am seeking some help here and i am stuck for few days
I am working on a Suitelet which creates a Form displaying different fields in GET method.
I have added 3 buttons:
* APPROVE calling a function checkApprove() as newForm.addButton(‘custpage_approveit’,’Approve’, ‘checkApprove(‘+salesorderID +’)’);
* REJECT calling a function checkReject() as newForm.addButton(‘custpage_rejectit’, ‘Reject’, ‘checkReject(‘+salesorderID +’)’);
* SUBMIT using newForm.addSubmitButton(‘Submit’);
I want to verify the inputs of the user in all fields have added in the form (myform.addfield…) and alert the user of any information wrongly input, and if ok (and only if all OK) submit the form to POST
WAY 1:
The 2 functions checkApprove() and checkReject are on a Clientscript and are working fine.
Since the submit button doesn’t let me verify the input of the User (except for Mandatory field) I am trying to use these 2 functions (APPROVE & REJECT) to do some verification (example date later than today…)
Everything works fine, my function are called properly and do some alert or even some nlapiSubmitField nevertheless I am not able to force the function ‘check’ on the clientscript to submit the Form on the Suitelet. As i want to display the POST of that same Suitelet.
WAY2:
If i press the SUBMIT button the POST method is correctly called but since the test are not done. my code is throwing every time it receive an none authorised value (expected behaviour).
is it possible to go back to Get after pressing SUBMIT if requirements are not encountered .?
Thanks guys in advance for your help.
This is a cached copy. Click here to see the original post. -
August 8, 2016 at 5:09 pm #6255
david.smithnlapiSetRedirectURL(type, identifier, id, editmode, parameters)
-
August 8, 2016 at 6:03 pm #6256
michoelAnother approach instead of creating additional buttons – you could have your client script handle the saveRecord event and return false if the verification fails to prevent submitting.
https://system.netsuite.com/app/help…_N2959270.html
SooS replied on 08/09/2016, 01:49 AM: thanks mate but you cannot use saveRecord event in a suitelet generating a custom form. [or i don’t know how to]
Infinet CS helped me resolving my issue.
thank you for the support
-
August 8, 2016 at 6:19 pm #6257
Infinet Cloud SolutionsIn the first instance I would see if you can restructure your validation logic to trigger in an another way (other than from the buttons), and if possible add the Approve and Reject validation to the Save Record client script handler.
If I have understood correctly I think you are asking is whether you can use client script to invoke the submission of the form; simulating the same behaviour as clicking on the Submit button. So your button Approve or Reject Button click would perform your validation logic and if successful submit the form. There isn’t a supported NetSuite API for this although there are enhancement requests out there for the feature. You can use the following code although normal disclaimer as its not supported by NetSuite and its using the Document Object Model its likely to break in future updates.
Code:
// Supress NetSuite displaying an alert box warning of leaving the page.
setWindowChanged(window, false);// Using the DOM find the Submit button by its id and simulate a Click on it.
document.getElementById(“submitter”).click();
Its a fairly common requirement for complex suitelets to want to submit the form by script (if you want to refresh lists of data using fields as filters) so I would like to see this part of the supported API and also to provide the ability to suppress the exit page popup box.
SooS replied on 08/09/2016, 01:50 AM: thanks. solved it with this.
-
August 9, 2016 at 1:46 am #6258
SooSHi Infinet, thanks for the tips, I figured that i have to used the DOM nevertheless, this force me to have a clickable button submit (which i am trying to avoid)
Following your advice, I kept 2 buttons [Submit] and [Validate and Submit].
I have disable the Submit button on my suitelet
Code:
var submitButton = newForm.addSubmitButton(‘click here =>’);
submitButton.setDisabled(true);
newForm.addButton(‘validateit’, ‘Submit’, ‘buttonValidate(‘+salesorderID+’)’);
Anyway i pushed the DOM a bit further and make the button submit disabled in the suitelet. then my clientscript is enabling it before calling (all using DOM).Code:
if (conditions) {
// my actions here// I had to enable the button Submit that i have disabled on load of the suitelet.
// I has to do it for both (submitter and secondarysubmitter) don’t really know why anyway
document.getElementById(‘submitter’).disabled = false;
document.getElementById(‘secondarysubmitter’).disabled = false;// call the submit button (for me it was secondarysubmitter and not submitter
document.getElementById(‘secondarysubmitter’).click(); // this is not working if button is not re-enabled
}
โAnyway thanks for your help, got it working fine !! -
August 9, 2016 at 5:25 pm #6259
michoelthanks mate but you cannot use saveRecord event in a suitelet generating a custom form. [or i don’t know how to]
You certainly can – I have done this for several scripts. In SS1.0 you would still have a Script record for a client side script, so you just need to edit it and map the Save Record event to your function name.
Infinet CS helped me resolving my issue.
Great to hear you managed to get this working. However, keep in mind that DOM manipulation in Netsuite should be a last resort, as Netsuite is free to change the DOM as they please..
Infinet Cloud Solutions replied on 08/09/2016, 05:44 PM: I have bolded the disclaimer to make that statement stronger and my first statement was to find a way to do this without using the DOM. But there are quite a few of these reasonably common requirements that NetSuite has yet to provide support for. For each one there are enhancements logged, its unlikely these will now be considered for Suitescript 1.0 but at least highlighting the use case hopefully encourages NetSuite to consider them for 2.0.
-
AuthorPosts
You must be logged in to reply to this topic.