In the image bellow the 3fields in the square come from a dropdown ("SI" or "NO") in a user interface.
I can see the user responses in a read-only grid (see the image bellow).
I want IF 3 condition ("Financial", "Documents", "Certificate") in the red square are "SI" then the column "Estado" return a new value "Finalizado"
IF just one condition ("Financial", "Documents", "Certificate") in the red square are "NO" then the column "Estado" return a new value "Pendiente"
Next i want to store the value of the column "Estado" in my cloud database
Discussion posts and replies are publicly visible
Hi,
You have to build the logic according by using AND/OR functions. If you are looking for the condition that either the 3rd or 1st value is blank then the value return will be EN Proceso. for that you can use OR function and into that use isnullorempty function.
a!textField( label: "Estado de proceso VENDEDOR", labelPosition: "ABOVE", value: if(and( ri!CWA_OECVendor.oecvendorverffinancial ="SI", ri!CWA_OECVendor.oecvendorverfdocs ="SI", ri!CWA_OECVendor.oecvendorregistroac ="SI" ), "Finalizado","Pendiente" ), saveInto: a!save(ri!CWA_OECVendor.oecvendorstatus, if(and( ri!CWA_OECVendor.oecvendorverffinancial ="SI", ri!CWA_OECVendor.oecvendorverfdocs ="SI", ri!CWA_OECVendor.oecvendorregistroac ="SI" ), "Finalizado","Pendiente" ) ), refreshAfter: "KEYPRESS", characterLimit: 55, required: false, readOnly: true, align: "LEFT"
Here's a standalone example mirroring your values which demonstrates how to do this calculation in a single-nested if() statement as well as how to properly contain the calculation within its own local variable. Note how the text field does not and should not have a "saveInto" parameter set, as it would never do anything at all since it's read-only.
a!localVariables( local!entry: a!map( financial: "", documents: "", certificate: "" ), /* this value will auto-update as the dropdown values are changed */ local!calculatedStatus: if( or( a!isNullOrEmpty(local!entry.financial), a!isNullOrEmpty(local!entry.documents), a!isNullOrEmpty(local!entry.certificate) ), "In Processing", if( and( local!entry.financial = "YES", local!entry.documents = "YES", local!entry.certificate = "YES" ), "Finalized", "Pending" ) ), { a!dropdownField( label: "Financial", labelPosition: "ADJACENT", placeholder: "(none)", choiceLabels: {"Yes", "No"}, choiceValues: {"YES", "NO"}, value: local!entry.financial, saveInto: local!entry.financial ), a!dropdownField( label: "Documents", labelPosition: "ADJACENT", placeholder: "(none)", choiceLabels: {"Yes", "No"}, choiceValues: {"YES", "NO"}, value: local!entry.documents, saveInto: local!entry.documents ), a!dropdownField( label: "Certificate", labelPosition: "ADJACENT", placeholder: "(none)", choiceLabels: {"Yes", "No"}, choiceValues: {"YES", "NO"}, value: local!entry.certificate, saveInto: local!entry.certificate ), a!textField( label: "Status", readOnly: true(), /* this field is READ ONLY, so there is **no save-into**, as it wouldn't do anything anyway */ /* saveInto: "", */ value: local!calculatedStatus ) } )
Thanks Mike for elaborated code, it really helped a lot...
It works
Great, thanks for confirming