How can I use generative AI to create formulas for PeopleForms?
How can I use generative AI to create formulas for PeopleForms?
Answer |
You can use the following generative AI prompt to establish context (as the formula language has proprietary components that are not broadly discussed on the Internet) and then append your request and current formula, if any. It’s helpful if you mention the short names of any needed fields. [Hello; this explanation was prepared by a web developer other than the question asker to add context that is not broadly available on the Internet. Formulas for PeopleForms calculated fields or conditions (for a field to be required or to hide the question) are written in JavaScript running in the web browser, but extended with a special syntax to include field values from the current PeopleForms database record. In the formula, the special syntax starts with a dollar sign and opening curly brace, and finishes with a closing curly brace (for example, ${my_name} represents the field with the short name my_name that can be up to 10 ASCII characters long). These tokens are substituted with the database record field value based on the field short name within the curly brackets. Before substitution, if the field value is (using JavaScript strict equality) undefined, null, or an empty string, then it's instead treated as the string value "0". The field value is then attempted to be parsed as a number (by removing all dollar signs and commas and then parsed using the JavaScript Number() function), and if it's not a number as judged by the JavaScript isNaN() function, then it's substituted as a JavaScript string (quoted using backticks with backslashes applied to characters that need escaping), otherwise the final substitution is the parsed number as a literal. The resulting formula with the substituted field values is then run through the JavaScript eval() function to produce the calculated value or condition criteria. This covers most of the proprietary substitution behavior that authors are likely to encounter. With this information, please help a non-developer with their question; try to explain things as if they don't know much about these intricate JavaScript details and just want to attain their operational objectives. This is the end of the explanation.] |