How to get a field value inside subform using JQuery or JavaScript?
Hello,
Does anybody know how to get a field value inside subform using JQuery or JavaScript?
Thanks in advance
Marina
-
Not as straight forward as you would like. I actually get the value from the subform based on a button click where it uses a value in the subform to pop up a window of information. The button does not have a JS call in it but rather a rule where you can access [this]
In the rule this is the method:
btnAPS(this)
JS required (ASAppID is the element name of the value in the subform that I want to use):
function btnAPS(ctrl) {
try {
console.log ('Enter the app sts log function',ctrl);
var val = GetSubFormControlStringValue(ctrl,'ASAppID');
console.log('Application ID: ', val);
window.open(NotifyAppCustom.UrlConstants.FormsAndPortal.APCSubmitForm+'&AppID='+val,'Application Log','height=600,width=800');
} catch (e) {
alert(e);
}
}and this is how to get the value from the subform:
function GetSubFormControlStringValue(ctrl,controlName) {
console.log ('Enter GetSubFormControlStringValue function');
console.log ('ctrl: ',ctrl);
console.log ('controlName: ',controlName);
var val = $(ctrl).parents(".subFormContentRowChildWrapper").find("[id^='" + controlName + "']").val();
console.log ('val: ',val);
return val;
} -
Hi All,
For me the above methods did not work out. I have another solution- To access any element in any section( which is not in subform )
$(AllFieldsReference['INTERNALFIELDNAME'].querySelector('#INTERNALFIELDNAME ')).val();
-
To access any element inside a subform( which can be on any section )
$(AllFieldsReference['INTERNALSUBFORMNAME '].querySelector('[id^="#INTERNALSUBFORMFIELDNAME "]')).val();
Thanks
Sourav - To access any element in any section( which is not in subform )
-
The above works for me too, however the JavaScript methods are very useful as well, a bit confusing at the beginning but once you understand it is easy to implement, refer to getFieldValue method from link below
https://documentation.agilepoint.com/00/appbuilder/cloudjsJavascriptMethods.html
This is how I used it:
var cValue=GetControlValue({"fieldId":"SubFormName/ControlName"});
function GetControlValue(ctrlName) {
var ctrlVal ="";eFormHelper.getFieldValue (ctrlName, function (res) {
if (res.isSuccess) { //check if is success
console.log(res.data); //logs the data holds the found control's value
ctrlVal = res.data;
} else { console.log(res.error); }//logs the error
});return ctrlVal;
}
-
Thanks Nadia Segura
Please sign in to leave a comment.
Comments
5 comments