Skip to main content
Known Participant
May 3, 2023 3:34 PM UTC
Solved

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

Hi all,

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

Thanks in advance

    sanchitg0002
    Inspiring
    May 4, 2023 6:38 AM UTC

    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 }
      )
    )

    17 replies

    sanchitg0002
    Inspiring
    May 3, 2023 3:36 PM UTC

    Simply use if()

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

    Known Participant
    May 3, 2023 4:05 PM UTC

    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

    mikes0011
    Brainy
    May 3, 2023 4:12 PM UTC

    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?

    The Expression Guru