mercredi 3 juin 2015

Boo Language Calculation on Web Drop Down List

The software we use LanDesk Service Desk uses Boo Language calculations to allow for dynamic windows.

I have a drop down list on a form that has one of two options. "Acute" and "Ambulatory". Based on which is chosen, one of two possible fields will no longer be hidden and will be set to mandatory. I have managed to get this to work, but I'm afraid if the number of options grows on future forms that the code will get a little wordy. Do any of you have any suggestions for alternatives. Thank you,

import System

static def GetAttributeValue(Request):
    isAcuteHidden = true
    isAcuteMandatory = false
    isAmbulatoryHidden = true
    isAmbulatoryMandatory = false


    if Request._PharmacyType != null and Request._PharmacyType._Name == "Acute":
        isAcuteHidden = false
        isAcuteMandatory = true

    elif Request._PharmacyType != null and Request._PharmacyType._Name == "Ambulatory":
        isAmbulatoryHidden = false
        isAmbulatoryMandatory = true

    return String.Format(":SetHidden(_AcutePharmacy, {0});:SetMandatory(_AcutePharmacy, {1});:SetHidden(_AmbulatoryPharmacy, {2});:SetMandatory(_AmbulatoryPharmacy, {3});", isAcuteHidden, isAcuteMandatory,  isAmbulatoryHidden, isAmbulatoryMandatory)   

Aucun commentaire:

Enregistrer un commentaire