Using Syle to highlight a field

amacqueen
Mega Guru

The picture below shows what I've done to get a field highlighted based on the fields value

Style.PNG

I have a feeling that I may have got the syntax wrong as this field is a string and not an integer/choice field.

I would welcome any feedback.

TIA

1 ACCEPTED SOLUTION

Angus,


Use the below code:



function onChange(control, oldValue, newValue, isLoading) {


  var cTypeLabel = $('label.incident.contact_type');


  var cTypeField = $('incident.contact_type');



if (newValue == 'Self Service') {


  cTypeLabel.setStyle({backgroundColor: "red"});


  cTypeField.setStyle({color: "red"});


  }


  else {


  cTypeLabel.setStyle({backgroundColor: ""});


  cTypeField.setStyle({color: ""});


  }



}


View solution in original post

30 REPLIES 30

bernyalvarado
Mega Sage

Hi Angus, does that color exist? CornflowerBlue. I tried it in my Developer instance and it didn't work. So, OOB is not defined.




Try changing it to Blue and see if it works. If it doesn't work, then probably you may want to try using the following in your style value field...



javascript: current.content_type.getDisplayValue() == "Site Surgery"



Thanks,


Berny


Thanks Berny that didn't work, see below for the modified style.


Style3.PNG


Oh! your field is called contact_type .   On your condition you have written content_type




try this:




javascript: current.contact_type.getDisplayValue() == "Site Surgery"


and since Site Surgery is both, the value and the label, the following should also work:



javascript: current.contact_type == "Site Surgery"


I'm afraid neither of those worked Berny, just in case it matters I've added the Dictionary Info for the field below. Not that it should matter but I'm trying this on our Dev instance and that's on Fuji



Style4.PNG