Values() collection and highlighting a null value for the dateonly field

Help!

I am using values() to highlight required fields on the screen as long as they are null (ie have no data in them) and it appears to be working for all field types except "dateonly" and I cannot figure out why...

I have a requirement for a screen that I need to highlight a field on the screen until it is populated. The purpose is to let users know this field is required to be populated before the workflow button to move to the next stage in the workflow will appear. This is a "transition" stage in the workflow. At this stage, users will be returning to this screen to complete somewhat of a "checklist". Once the checklist is complete, the workflow button for the next stage will appear. There are A LOT of fields on this screen, which is why there is a requirement to highlight the fields necessary to trip the appearance of the workflow button. In order to help the user visually, once the required field is populated, the field should no longer be highlighted.

I have this working for most of the fields, but I am getting tripped up by the different field types. One other thing that I didn't mention is that the highlighting on the field is only to appear during the "transition" stage.

In order to meet this requirement, I have used crm.ready() in the custom content of the screen. I created a function called RequiredYellow(). The function seems to work for all field types except a dateonly field and I have not been able to figure out why. Here is a snippet of what I have tried...the selection type and the checkbox type work fine (so showing what is working for me). The last if statement is the one I am have issues with. I have shown what I have tried on the dateonly type and none of those seem to work. How do I determine that the dateonly field has not been populated?

function RequiredYellow(){
if (crm("oppo_stage").value()== "transition") {
if (crm("oppo_selectiontype").value() == null) {
crm.fields("oppo_selectiontype").highlight();
} }
{
if (crm("oppo_checkboxtype").value() == "") {
crm.fields("oppo_checkboxtype").highlight();
} }
{
if (crm("oppo_dateonlytype").value() == "") || (crm("oppo_dateonlytype").value() == null) || (crm("oppo_dateonlytype").value() == 'undefined') {
crm.fields("oppo_localprojectapprovaldate").highlight();
} }
}

Any assistance would be greatly appreciated!

  • 0

    Think it is because the syntax is incorrect in the line:

    if (crm("oppo_dateonlytype").value() == "") || (crm("oppo_dateonlytype").value() == null) || (crm("oppo_dateonlytype").value() == 'undefined')


    It could be:

    if (crm("oppo_dateonlytype").value() == "" || crm("oppo_dateonlytype").value() == null || crm("oppo_dateonlytype").value() == 'undefined')


    Got a bit over enthusiastic with your brackets. I run stuff in the console to see whagwan, when I run yours (amended for the fields I have available) I get:



  • 0

    As an aside, I prefer to use jquery than the client side API:

    $('#oppo_dateonlytype').css("background-color", "yellow");

    Looks a bit neater:

    Than:

    But that's only because I have too much time on my hands I guess.

  • 0

    Thanks Toby!

    I am going to go back and look at what I have. I tried each of those ORs individually and I was not getting any of them to work. Based on what you are indicating...as long as I get the syntax correct, I was on the right track. Yeah!

    Also on your aside note, are you saying switch out my crm.fields highlighting with the line you are recommending for a cleaner look?

    Thanks! I will let you know if I get this to work.

  • 0

    Thanks Toby...I did get over enthusiastic with my brackets. It works for me now!

    Thank you!!