Set Oppo_Targetclose readonly if another checkbox fiels is not checked in a Workflow rule ?

SUGGESTED

Hi all,

I have setup a New Opportunity workflow rule with a custom field which is a checkbox, and I want the following :

  1. If the user has checked the checkbox field, he can modify the oppo_targetclose date
  2. If the user has not checked the checkbox field, the oppo_targetclose date is readonly, or he can't modify it (there's a default value which is now)

Any suggestion on where and how I could do that ?

Thanks a lot.

Parents Reply Children
  • 0 in reply to PPI-VDM

    Oh, so you want it to become readonly or not readonly as the user ticks or unticks the box?

  • 0 in reply to Vega
    SUGGESTED

    It's probably easier to make the target close date disappear than make it readonly. Also, what if they have prefilled it in, and then you uncheck the box? Do you want the value cleared? You can either make the field fade in and out which looks nice on the screen but it removes the elements from the DOM so things can move around if the field is in the middle of others. If you use the hide function it just makes the field hidden but keeps the screen layout correct. In your workflow screen put the script below in the custom content, and then on the onChange event of the tick box, just have setTargetClose(); so it calls the function when you tick/untick the box.

    function setTargetClose()
    {
        if(!crm.fields("comp_optout").val())
        {
            crm.fields("comp_name").val("");
            crm.fields("comp_name").hide();
        }
        else
        {
            crm.fields("comp_name").show();
        }
    }
    
    crm.ready(function()
    {
        setTargetClose();
    });

    Ensure that you have the script tags surrounding the javascript in the custom content. I would have put it in but it means I can't post the code. Obviously you'll need to change the field names as I was testing this on the company summary screen.