Big news! The community will be moving to a new platform April 21. Read more.
Big news! The community will be moving to a new platform April 21. Read more.
Commodore
Commodore
3283 views

How to populate several blank/empty text fields with text?

Jump to solution
Before we 'close' an item we would like to have any blank/empty text fields automatically filled in with "N/A" or similar text. I feel like somewhere I saw the code for a script on how to do that, but maybe I'm imagining that. I did find a script for hiding blank fields on a form, but we would rather have those fields filled in.

I could maybe create a special form for this and use form actions to do it, but we have several text fields. Any guidance on how to fill in all blank fields at once would be appreciated.

Thanks!

-Brian
0 Likes
1 Solution

Accepted Solutions
Absent Member.
Absent Member.
If you just want one universal form action, this code executed "When the form is about to be submitted..." using "Execute custom JavaScript" should fit the bill:


for (var i = 0; i < aFieldLookup.Fields.length; i++)
{
if (aFieldLookup.Fields.type == "text" && IsFieldEmpty(aFieldLookup.Fields.dbName)){
SetFieldValue(aFieldLookup.Fields.dbName, "n/a");
}
}

View solution in original post

3 Replies
Micro Focus Expert
Micro Focus Expert
If you are trying to avoid coding for each text field individually and trying to avoid Form actions, an AppScript applied to the post transition context of your Close transition would be at least one way of achieving your goal. The logic could dynamically query for all text fields available on the transition or in the table, inspect to see if it has a value, then set the field to "N/A" if applicable. It shouldn't take much code to achieve this. I personally have not seen an existing script to do this however.
0 Likes
Absent Member.
Absent Member.
If you just want one universal form action, this code executed "When the form is about to be submitted..." using "Execute custom JavaScript" should fit the bill:


for (var i = 0; i < aFieldLookup.Fields.length; i++)
{
if (aFieldLookup.Fields.type == "text" && IsFieldEmpty(aFieldLookup.Fields.dbName)){
SetFieldValue(aFieldLookup.Fields.dbName, "n/a");
}
}

View solution in original post

Commodore
Commodore
Thanks Gary and Jeff. I set up a rule that checks to see if any of those text fields are blank and made that rule the condition used by the form action. The code Jeff supplied works great.

Thanks again!
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.