Hello everyone,
Here is the code for a field. When the user gives an input, there are some controls that should be verified. I want to add some code so that if the user gives an input that doesn't satisfy the condition, the field should be initialized as empty. How can I do this, please?
a!integerField( label: "Montant Apport", labelPosition: "ABOVE", placeholder: "Donner le montant exact de l'apport", value: ri!record['recordType!{3e104763-60d6-49a4-8cdb-405e073de678}PBY prêt.fields.{0f648b9f-079f-483f-87ad-d8a64c53802e}montantApport'], saveInto: ri!record['recordType!{3e104763-60d6-49a4-8cdb-405e073de678}PBY prêt.fields.{0f648b9f-079f-483f-87ad-d8a64c53802e}montantApport'], required: true(), validations: { if( and( not(isnull(ri!record['recordType!{3e104763-60d6-49a4-8cdb-405e073de678}PBY prêt.fields.{0f648b9f-079f-483f-87ad-d8a64c53802e}montantApport'])), not(isnull(ri!record['recordType!{3e104763-60d6-49a4-8cdb-405e073de678}PBY prêt.fields.{5c6f5fa8-85d3-4b23-af45-80a1b6b0c364}montantPret'])) ), if( ri!record['recordType!{3e104763-60d6-49a4-8cdb-405e073de678}PBY prêt.fields.{0f648b9f-079f-483f-87ad-d8a64c53802e}montantApport'] < (0.2 * ri!record['recordType!{3e104763-60d6-49a4-8cdb-405e073de678}PBY prêt.fields.{5c6f5fa8-85d3-4b23-af45-80a1b6b0c364}montantPret']), "Le montant de l'apport doit être au moins égal à 20% du montant demandé pour le prêt.", null ), null ) } ),
Discussion posts and replies are publicly visible
To initialize the field as empty if the user input doesn't satisfy the condition, you can add additional logic to the validation block. if condition inside the existing validation block. If the user input doesn't satisfy the condition (i.e., if the amount entered is less than 20% of montantPret), the a!save function is used to reset the value of the montantApport field to null, effectively initializing it as empty.
manishs0028 said:I've added an if condition inside the existing validation block. If the user input doesn't satisfy the condition (i.e., if the amount entered is less than 20% of montantPret), the a!save function is used to reset the value of the montantApport field to null
This would be an interesting approach, except it's nonsense. You can't call a!save() inside the validations parameter. At all.
manishs0028 said:a!setValue(
Additionally there is no such function as a!setValue(). Is your answer written by ChatGPT or something?