Thanks so much Hammad, this worked perfectly. Much appreciated!!
Original Message:
Sent: 03-07-2024 09:22
From: Hammad Naeem
Subject: Resetting Evolve Form Fields
Hi Alex,
To reset the fields with no default values use code below :
------------------------- // code starts here
var AllFields = renderer.formModel.getForm_DataByProperty(renderer.formModel.Schema, "binding", null, true);
for (i = 0; i < AllFields.length; i++) {
$form.setValue(AllFields[i].binding,'')
}
dvfields = renderer.formModel.getForm_DataByProperty(renderer.formModel.Schema, "defaultValue", null, true);
for (i = 0; i < dvfields.length; i++) {
if (dvfields[i].defaultValue.length == 0) continue;
if (typeof dvfields[i].defaultValue !== 'undefined' && dvfields[i].defaultValue !== null) {
$form.setValue(dvfields[i].binding,dvfields[i].defaultValue)
}
}
-----------------------------------// code ends here
Above code resets the value for all fields to empty and then resets the default value fields to their default values.
Hope this helps.
Regards
------------------------------
Hammad Naeem
Precisely Software Inc.
Original Message:
Sent: 03-06-2024 14:46
From: Alex Kuligowski
Subject: Resetting Evolve Form Fields
Thanks so much Hammad, this is very helpful. I am working with the custom rule that you provided, and had a follow up question.
Based on some functionality I implemented in the parent form this is going into, I need to now also reset fields which might not have default values defined. Examples include drop-down selections by the user where there is no option to use the --Select-- as a default.
Is there a tweak I could make to essentially clear out any form field on the form, whether it has a default value called out or not? Or conversely, can I define a default "blank" value for fields which will not be pre-populated?
Thanks again for your help!
------------------------------
Alex Kuligowski
Data Governance
Leprino Foods
Denver, CO
Original Message:
Sent: 02-28-2024 02:49
From: Hammad Naeem
Subject: Resetting Evolve Form Fields
Hi Alex,
use code mentioned below if your form has only non repeating fields with default Values on the form.
---------------------------- // code starts here
dvfields = renderer.formModel.getForm_DataByProperty(renderer.formModel.Schema, "defaultValue", null, true);
for (i = 0; i < dvfields.length; i++) {
if (dvfields[i].defaultValue.length == 0) continue;
var element = $j("[data-link='" + renderer.formModel.formatInputBinding(dvfields[i].binding) + "']");
if (typeof dvfields[i].defaultValue !== 'undefined' && dvfields[i].defaultValue !== null) {
$form.setValue(dvfields[i].binding,dvfields[i].defaultValue)
}
}
------------------------------- // code ends here
Use code mentioned below if your form has both repeating and non repeating fields with default values :
-------------------------------- // code starts here
dvfields = renderer.formModel.getForm_DataByProperty(renderer.formModel.Schema, "defaultValue", null, true);
for (i = 0; i < dvfields.length; i++) {
if (dvfields[i].defaultValue.length == 0) continue;
var fpath = dvfields[i].binding;
if(fpath.indexOf("Repeating_Content")<0)
{
if (typeof dvfields[i].defaultValue !== 'undefined' && dvfields[i].defaultValue !== null)
{
$form.setValue(fpath,dvfields[i].defaultValue)
}
}
else
{
var tblLength = count(fpath);
for(var j = 0;j<tblLength;j++)
{
var fPathWIndex = fpath.substring(0,fpath.indexOf("Repeating_Content")+17)+'['+j+']'+ fpath.substring(fpath.indexOf("Repeating_Content")+17);
if (typeof dvfields[i].defaultValue !== 'undefined' && dvfields[i].defaultValue !== null)
{
$form.setValue(fPathWIndex,dvfields[i].defaultValue)
}
}
}
}
------------------------------------------ // code ends here
You can apply a custom rule either on view load or on a button click or whatever best suits your requirement.
Hope this helps.
Regards
------------------------------
Hammad Naeem
Precisely Software Inc.
Original Message:
Sent: 02-27-2024 14:52
From: Alex Kuligowski
Subject: Resetting Evolve Form Fields
Hi all,
I am trying to implement a rule to reset all form fields to default values if a form is routed through a particular step in a workflow. I would like to avoid having to create a rule that needs to call out every specific field if possible.
I have tried using a custom rule using document.getElementByID("formname").reset() but haven't been successful. Disclaimer: I am not well-versed in javascript so perhaps there is a different method that is more appropriate?
If anyone has any ideas or similar functionality in your solutions I would love to hear them. Thanks in advance!
------------------------------
Alex Kuligowski
Data Governance
Leprino Foods
Denver, CO
------------------------------