Field validation doesn't work in a pop up window - New U

Posted by IramK on 27-Nov-2015 13:18

Hello,

I am opening the new page of an object record on the click of a button using window.open. The code is given below. However, I have some server-side code running to check information on the form (triggers), but when trying to save the form, the form doesn't save, doesn't create the record and closes without displaying any errors. Is this supposed to work like this or am I doing something wrong? Kindly let me know.

Cheers.

Iram

      var params = [
        'height='+screen.height,
        'width='+screen.width,
        'fullscreen=yes' // only works in IE, but here for completeness
      ].join(',');
      var window = window.open('{!#LINK.object#10863}', '_blank', params);

All Replies

Posted by Sri Harsha on 30-Nov-2015 01:28

Hi Iram,

I have tried the scenario you have posted above and was not able to reproduce the issue. Below are the steps i followed.

1. Create an object "Book".

2. Create a button which opens a window with the new page url of object Book.  Added this button to view page of the record.

3. Created a data validation "before create" trigger, which throws an error if the book record name is "mybook"

3. Created a book record. Navigated to its record view page and clicked on the newly added button which opened the new record page in another window.

4. Set the record name as "mybook" and clicked save.

Observed the validation error of the trigger displayed on page. If the record name is changed to something else, the records got created successfully.

Did i miss something here ?

If possible can you create a simple application to reproduce this usecase and attach it here.

Regards,

Harsha.

Posted by IramK on 03-Dec-2015 11:01

Hello Harsha,

I managed to find an issue. Basically I was closing the window when the below mentioned code runs so it doesn't really allow the server validation (i.e. triggers to be checked before performing the window close). Is it possible for me to perform my window close once all the triggers have ran and the form has submitted successfully? Kindly let me know.

Code that runs on that new page's form submission:

$("#theForm").submit(function() {

        var formDetails = rb.newui.page.PageContext.getFormDetails(rb.newui.util.EDIT_FORM_NAME);
        var validator = formDetails.getKendoValidator();
        if (validator && validator.validate()) { //validation true...
          window.opener.HandlePopupResult($("#name").val()); // need this to happen after all the triggers are checked
          window.close(); // need this to happen after all the triggers are checked
}
Posted by Mohammed Siraj on 03-Dec-2015 11:11

Iram, as explained earlier with New UI we have introduced client-side validation for the most basic cases like Required Fields, Invalid Dates & similar.

However, for any server-side validation (i.e. custom field validation or validation trigger), we still require server round-trip to run these validations. That is, validator.validate() statement from above will run only client-side validations.

Presently, using client-side API it is not possible to determine  if server-side validations will run succesfully or not. Going forward we have plans to submit form using ajax & we will have callback handler options to cater to such requirements.

Posted by IramK on 03-Dec-2015 11:16

That's great! Thanks for that. Waiting for 4.0.4.

Posted by IramK on 15-Jan-2016 11:34

Hello [mention:78c86023544844079dc6455a4a7a4d57:e9ed411860ed4f2ba0265705b8793d05],

Is this functionality available yet in version 4.0.4.? Kindly let me know.

Cheers.

Iram

This thread is closed