How can I cast True or false into yes or no?

Certified Associate Developer

Hi all,

How can I cast True or false into yes or no?is there any function to convert like this?

Thanks in advance

  Discussion posts and replies are publicly visible

Parents
  • Simply use if()

    if(ri!booleanValue, "Yes", "No")

  • 0
    Certified Associate Developer
    in reply to Sanchit Gupta (Xebia)

    Thank you Sanchit,

    But my requirement is little different .I am retrieving some boolean value from expression rule so it gives result as"false" and I want to use this false to some boolean fie

    a!localvariables{
    local!recomend: a!defaultValue(
        value: ri!studyMedicalReview.recomend,
        //retrieved values should go into the field goes as default //
        default: rule!recomend(ISR_Studyrequest: ri!studyRequest.studyRequestId)
      ),
     local!yesNo: { "Yes", "No" },
      local!booleanArray: { true(), false() },
    a!sideBySideItem(
                    item: a!radioButtonField(
                      label: "Recomended",
                      labelPosition: "ABOVE",
                      choiceLabels: local!yesNo,
                      choiceValues: local!booleanArray,
                      value: local!recomend
                      saveInto: {
                        local!recomend
                        }}
    ld in the interface .I have tried the above code but it giving error as choice values are yes or no but you are using false value.so How can I overcome this issue

  • 0
    Certified Lead Developer
    in reply to sireesha

    I'm having a hard time understanding your use case.  Can you post a screenshot of the error you're getting?  What does the value of "local!recomend" evaluate to?

  • 0
    Certified Lead Developer
    in reply to sireesha

    The value of that component must have the exact same data type as the items in choiceValues. Could it be that your local contains a string with the value "false"?

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    a!localvariables{
    local!recomend: a!defaultValue(
        value: ri!studyMedicalReview.recomend,
        //retrieved values should go into the field goes as default //
        default: rule!recomend(ISR_Studyrequest: ri!studyRequest.studyRequestId)
      ),
     local!yesNo: { "Yes", "No" },
      local!booleanArray: { true(), false() },
    a!sideBySideItem(
                    item: a!radioButtonField(
                      label: "Recomended",
                      labelPosition: "ABOVE",
                      choiceLabels: local!yesNo,
                      choiceValues: local!booleanArray,
                      value: local!recomend
                      saveInto: {
                        local!recomend
                        }
                        primaryButtons: {
        a!buttonWidget(
          label: "Submit",
          submit: true(),
          
          saveInto: {
            ri!buttonPressed,
            
            a!save(
              ri!studyMedicalReview.recomend,
              local!recomend
            )
          }
        )
      }}

    Hi Mike ,

    Sorry to confuse you. I tried the above code it was giving some error initially but later that it didnt show any error and not providing the right output also.

    I am retrieving some boolean value from rule!recomend that is "false"(which I got from the rule!recomend).I am trying to place the same boolean value into the field "Recomend" in the interface when ri!studyMedicalReview.recomend has no value.But I am not getting the right output and not getting any error also.

    Could you check and confirm where I am doing mistake?

    Many thanks

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    Hi Stefan,

    Choice values contains local!booleanArray: { true(), false() } these values but from the rule I am trying to place  "false"(which is also boolean value) in the local!recomend when the ri!studyMedical.recomend is blank.

    Many thanks

  • 0
    Certified Senior Developer
    in reply to sireesha

    hi Sirio, in value parameter of radio button field , just have null check in you radio button field like below,

    a!radioButtonField(
    value:if(
    a!isNullOrEmpty(ri!studyMedical.recomend),
    false,
    ri!studyMedical.recomend
    )

  • 0
    Certified Associate Developer
    in reply to GopalK

    Hi Gopal Thank you for the reply.

    But how can  use the retrieved value from  rule!recomend  in the radio field when the ri!studyMedical.recomend is empty with the above code

  • +1
    Certified Senior Developer
    in reply to sireesha

    Did you copy this code from Interface designer? This code is full of errors.

    I tried what you said and it works perfectly

    a!localvariables(
      local!recomend: a!defaultValue(value: null, default: false()),
      local!yesNo: { "Yes", "No" },
      local!booleanArray: { true(), false() },
      a!radioButtonField(
        label: "Recomended",
        labelPosition: "ABOVE",
        choiceLabels: local!yesNo,
        choiceValues: local!booleanArray,
        value: local!recomend,
        saveInto: { local!recomend }
      )
    )

Reply
  • +1
    Certified Senior Developer
    in reply to sireesha

    Did you copy this code from Interface designer? This code is full of errors.

    I tried what you said and it works perfectly

    a!localvariables(
      local!recomend: a!defaultValue(value: null, default: false()),
      local!yesNo: { "Yes", "No" },
      local!booleanArray: { true(), false() },
      a!radioButtonField(
        label: "Recomended",
        labelPosition: "ABOVE",
        choiceLabels: local!yesNo,
        choiceValues: local!booleanArray,
        value: local!recomend,
        saveInto: { local!recomend }
      )
    )

Children