Service Portal - Checkbox display values

rody-bjerke
Giga Guru

Hi,

Is there an easy way to change the display value for a Checkbox field in the Service Portal (Ticket Fields widget), so that if display value is "true", change to "yes" and if display value is "false", change display value to "no".

Best regards,

checkbox1.jpg

2 REPLIES 2

Gaurav Bajaj
Kilo Sage

Hi Rody,



Please add below code in your client script for widget.



var fields= $scope.data.fields;



for(var n in fields){



if(fields[n].type=='boolean'){


if(fields[n].display_value=='false'){


fields[n].display_value="No";



}


else{


fields[n].display_value="Yes";



}



}



}





find_real_file.png




find_real_file.png




Please mark the response correct/helpful based on the impact.




Thanks


Gaurav


flemming1
Giga Contributor

Hi Rody


I solved it via the HTML template in my custom Widget that is a copy of Ticket. In the HTML added the following:

<div ng-if="variable_toggle">


      <div class="m-b break-word" ng-repeat="variable in data.variables">


              <div ng-if="variable.name != 'patient' && variable.name != 'rm_return_value'">


                      <label class="m-n"><b>{{variable.label}}</b></label>


                      <div ng-if="variable.value != 'true' && variable.value != 'false'">


                              {{variable.display_value}}


                      </div>


                      <div ng-if="variable.value == 'true'">


                              Valgt


                      </div>


                      <div ng-if="variable.value == 'false'">


                              Fravalgt


                      </div>


              </div>


      </div>


</div>



It's line 8 to 13, where I check if the value is true/false and changes it.



Best regards,


Flemming