Return one value for multiple conditions

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

Parents
  • 0
    Certified Senior Developer

    To store the data into DB, you have to create a link or button for the action to writeDataintoDatastore but to show the value into Estado column. you can use the below code under value configuration of the grid column of Estado.

    if(
    and(
    fv!row.financial="SI",
    fv!row.documents="SI",
    fv!row.certificate="SI",
    ),
    "Finalizado",
    "Pendite"
    
    
    )

  • Hi Deepak

    Thanks so much,

    Im trying but now i want to do this:

    IF 3 condition ("Financial", "Documents", "Certificate") in the red square are "SI" then the Text Filed  "Estado de proceso vendedor" return a new value "Finalizado"

     IF just one condition ("Financial", "Documents", "Certificate") in the red square are "NO" then the Text Filed  "Estado de proceso vendedor" return a new value "Pendiente"

    This part is new

     IF 3 or 1 condition ("Financial", "Documents", "Certificate") in the red square are "EMPTY" then Text Filed  "Estado de proceso vendedor" return a new value "En Proceso"

    In the blue square (image bellow) is the value generate by the conditions above, i want that value store in my CloudDatabase after clicking SUBMIT button.

    This is the expresión of the Text Filed  "Estado de proceso vendedor" 

    a!textField(
    label: "Estado de proceso VENDEDOR",
    labelPosition: "ADJACENT",
    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: false,
    align: "LEFT"
    )

  • THIS PART PLEASE

    IF 3 condition ("Financial", "Documents", "Certificate") in the red square are "SI" then the Text Filed  "Estado de proceso vendedor" return a new value "Finalizado"

     IF just one condition ("Financial", "Documents", "Certificate") in the red square are "NO" then the Text Filed  "Estado de proceso vendedor" return a new value "Pendiente"

    This part is new

     IF 3 or 1 condition ("Financial", "Documents", "Certificate") in the red square are "EMPTY" then Text Filed  "Estado de proceso vendedor" return a new value "En Proceso"

  • 0
    Certified Lead Developer
    in reply to danna3499
    THIS PART PLEASE
    THANKS IT WORKS

    I'm a bit confused - do you still have a question with creating this logic, or do you have it working now?

  • Is working the saveInto part (thanks so much)

    But the logic part (bellow) i can't make it work

    IF 3 condition ("Financial", "Documents", "Certificate") in the red square are "SI" then the Text Filed  "Estado de proceso vendedor" return a new value "Finalizado"

     IF just one condition ("Financial", "Documents", "Certificate") in the red square are "NO" then the Text Filed  "Estado de proceso vendedor" return a new value "Pendiente"

    This part is new

     IF 3 or 1 condition ("Financial", "Documents", "Certificate") in the red square are "EMPTY" then Text Filed  "Estado de proceso vendedor" return a new value "En Proceso"

  • 0
    Certified Lead Developer
    in reply to danna3499
    But the logic part (bellow) i can't make it work

    Please post the current version of the code where you're trying to evaluate this.  Remember that code is > 10x more readable when you put it in a Code Box.

  • 0
    Certified Senior Developer
    in reply to danna3499

    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"

  • +1
    Certified Lead Developer
    in reply to danna3499

    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

  • 0
    Certified Lead Developer
    in reply to danna3499

    Great, thanks for confirming Slight smile

Reply Children
No Data