Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
hi,
I do the following, i render the status list values as buttons ( shown on Joget KB), at the same time, i have assigned different (slightly) js handler methods on the buttons. in those handlers, i know the value of the buttons/statuses so i can set the validation_type (made up name) field on the main form like below
i use jquery like $("input[id*='validation_type']").val(some_in_value)
where some_in_value is a range of flags i made up 0 : no validation at all, 1 : remarks only, 2 : all fields
this way the value is set in the form, then when the complete assignment call is made, the custom beanshell validators are able to see the value of the validation_type field. if the validation type field is say 0 for example, i just return true; immediately in the validator to short-circuit any further (actual) validation logic of the field
Anders,
let me more clear, the form is not yet submitted, so the saved values in the tables do not matter, the "selected" value in the web page is what i am after. - plus the button clicked i am referring to is basically the status value selected - eg, approved, rejected, hold, action-x, action-y – the purpose is that i don't want to validate fields if its not approved, but i need remarks if its rejected or hold.
i tried different approaches, can a subform see the formdata for a sibling subform or can a subform get the entire formdata for the parent form including subforms - remember this is the approval form containing 2 subforms named abc-form, abc-form-approval-action) - i got hopeful when trying to use FormUtil.loadFormData() which is supposed to return subformdata
finally, i put a hidden field on the main-form, and user jQuery to put a value in that field when the approval-status is selected from the dropdown or the approval-button is clicked ( if the statuses are presented as buttons)
the validation code in the abc-form can now find the hidden field value and determine what button was clicked.
Thanks for sharing the approach. Yes if the form is not yet submitted then client-side JavaScript will be needed to dynamically retrieve form values. Did you use the JavaScript API Javascript API#getValue(fieldId)?
Hi, to get the value of any form field you can use Hash Variable#FormDataHashVariable as long as you know its table name.
I have an approval form AA_Approval generated by Joget App Gen on my form AA, i also have AA_Approval_Action form created by Joget App Gen.
AA_Approval is the main form
AA is a sub form
AA_Approval_Action is a subform
I want to be able to get the value of the status field in AA_Approval_Action FROM a field in AA (via a bean shell validator), this validators are called when the status is selected and complete button is pressed (or in my case, the status values have been rendered as buttons with hookup to Complete action click)
from field X in AA , i can figure out that AA is the form and the formData for AA. I also want the formData of AA_Approval_Action or in short i want to know the value of the status field of AA_Approval_Action.
Why? I want to force validation of fields in form AA only if Approved is selected,
Additionally I want to only force validation for the remarks field in AA_Approval_Action ( if rejected is selected) this is easier cuz remarks field and status field are in the same form.