(Solved) Disable a Date field in Opportunity Workflow

Hi All,

Within the Opportunity Workflow I would like to disable the closed date once its been entered

Example:
If a user enters a closed date at Stage 2
Closed Date should be displayed (ReadOnly) for Stage 3

If no date is entered at Stage 2 the Closed Date should be displayed and editable for Stage 3

I've tried various scripts but the fields is either enabled or disabled in both cases the scripts dos not appear to check that the date field contains data

Sample script:

if (Values('oppo_closed')+""=="undefined")
{
oppo_closed.disabled = false;
}
Else
{
oppo_closed.disabled = true;
}

OR

if (oppo_closed.value == "")
{
oppo_closed.disabled = false;
}
Else
{
oppo_closed.disabled = true;
}

  • 0

    If you are using a CreateScript then the property used in ReadOnly.

    oppo_closed.ReadOnly = true;

  • 0

    Hi Jeff,

    Thank you for the reply.

    I should have put all the scripts I tested, the problem I am having is checking the value of the date field.

    The last script I tested sets readonly when the date is entered and when the date is blank

    var dOppoClosed="";

    dOppoClosed = new String(Values("oppo_closed"));

    if(dOppoClosed=="null" || dOppoClosed=="Undefined")

    {

    ReadOnly=false;

    }

    else

    {

    ReadOnly=true;

    }

    The IF statement that checks the date does not appear to work with a date field for any of my scripts,

    The readonly statement is working and I have manage to get DISABLE To work as well

    Problem still remains the check on date value, it is always seen as CONTAINS A VALUE

  • 0

    It’s a bit of an *** about face way of doing it but you could just look straight at the underlying data and do so something like:

    var oppId = CRM.GetContextInfo(“Opportunity”, “oppo_opportunityid”);

    var oppRec = CRM.FindRecord(“Opportunity”, “oppo_opportunityid = “ + oppId + “ and oppo_closed is null");

    //if recordcount is 0, there must be an oppo_closed value so make it readonly

    if (oppRec.RecordCount == 0)

    ReadOnly =false;

    else

    ReadOnly=true;

  • 0

    Just noticed my true and false is the wrong way around in the IF statement .... it's still early!

  • 0

    Thank you Peter!

    This solved worked perfectly (readOnly adjustment included)

    Greatly appreciated