Home Advanced Request Offering

Target Enum List Values in Portal .js

Chris_JordanChris_Jordan Customer Adept IT Monkey ✭✭
Hey all,

I am trying to hide certain elements of a custom form when an Enum List equals a certain value.

<div>I have been using the below for Strings, but it does not work for Enum Lists.</div>if(pageForm.viewModel.UserInput2 == 'Full Time') {<br>//Choose the fields to hide<br>var endDateLabel = $(".form-group label[for='SRDate2']");<br>var endDateInput = endDateLabel.next();<br>endDateLabel.hide();<br>endDateInput.hide();&nbsp;

}

So far I have tried just using the property name, and below:


Anyone know how to reference Enum lists and their values? Cheersvar TrainingTarget = "3f711d2c-513a-a7bf-7c54-55f0829b3a8d" if(pageForm.viewModel.TrainingTarget == 'Individual Training') { //Choose the fields to hide var GrpLabel = $(".form-group label[for='SRString6']"); var GrpInput = GrpLabel.next(); GrpLabel.hide(); GrpInput.hide(); }

Best Answer

Answers

  • Chris_JordanChris_Jordan Customer Adept IT Monkey ✭✭
    Chris,

    An Enum is a JavaScript Object in the ViewModel so you need to reference a particular property of it.
    if(pageForm.viewModel.TrainingTarget.Name == 'Individual Training')
    Or for multi language environments
    if(pageForm.viewModel.TrainingTarget.Id == '5cf234fc-b718-85dd-a8b3-bdaa92d8e89c')
    <br>Geoff
    <br>Thanks Geoff - Worked perfectly.
  • Geoff_RossGeoff_Ross Cireson Consultant O.G.
    Glad to hear it, happy to help.
Sign In or Register to comment.