locked
How to create a self dependency in status reason RRS feed

  • Question

  • Status reason is a system picklist that we can customize by adding or deleting values from the list.

    I would like to know if it is possible to create a self depencency within this field.

    For example, The list of values in status reason are: New, In progress, Waiting for client, On hold.

    What I need is: If the satus is New -> The only value shown is In progress.

    If the status is In Progress -> show Waiting for client  and On Hold.

    If the satus in Waiting for client or on hold -> show only In progress.

    Any ideas how to achieve this?

    Thanks in advance,

    Miguel

    Monday, June 7, 2010 7:02 PM

Answers

  • Hi,

    you cannot hide/show, you  have to  remove them from  picklist field when require and  add them  back  again  when  require.

    e.g.

    var  oOption ;

    if(crmForm.all.status.DataValue.SelectedText  == "New)

    {

    //  Add  or  remove from  other  picklist depending  on  criteria.

    oOption = oField.Options[4];

    crmForm.all.statusReason.DataValue.DeleteOption(4);

    }

    else  if(crmForm.all.status.DataValue.SelectedText  == "In Progress")

    {

    //  Add  or  remove from  other  picklist depending  on  criteria.

    crmForm.all.statusReason.DataValue.AddOption(oOption.Text, oOption.DataValue);

    }


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    • Marked as answer by MIDRIANO Monday, June 7, 2010 8:24 PM
    Monday, June 7, 2010 8:08 PM

All replies

  • you  can  add/remove picklist values  from  drop down using  javascript, Note these values  to be  added must be valid and must already exits as valid picklist values. So  you  can  write a OnChange() event on your "Status" field.

    Example

    The following code example shows how to use a field of type Picklist. Note that when you add an option to a Picklist, the option must already exist in the set of possible options.

    var oField = crmForm.all.SOME_PICKLIST_FIELD_ID;
    
    // Capture the fourth option
    var oOption = oField.Options[4];
    
    // Show how many options are available
    alert("Original length :"+ oField.Options.length);
    
    // Set the field to the first option by value
    oField.DataValue = 1;
    
    // Show the text for the first option
    alert(oField.SelectedText);
    
    // Remove the fourth option
    oField.DeleteOption(4);
    
    // show the new length
    alert("New length :"+ oField.Options.length);
    
    // Restore the fourth option
    oField.AddOption(oOption.Text, oOption.DataValue);
    
    // Show the restored length
    alert("Restored length :"+ oField.Options.length);

    Muhammad Ali Khan
    http://malikhan.wordpress.com
    Monday, June 7, 2010 7:14 PM
  • Thanks but maybe I am not using this script correctly or is not quite what I want to achieve.

    This one adds and removes values from a picklist. (I ended up with five values with the same name.)

    I want to hide/show values depending on the selected value within the same picklist field.

    Monday, June 7, 2010 7:33 PM
  • Hi,

    you cannot hide/show, you  have to  remove them from  picklist field when require and  add them  back  again  when  require.

    e.g.

    var  oOption ;

    if(crmForm.all.status.DataValue.SelectedText  == "New)

    {

    //  Add  or  remove from  other  picklist depending  on  criteria.

    oOption = oField.Options[4];

    crmForm.all.statusReason.DataValue.DeleteOption(4);

    }

    else  if(crmForm.all.status.DataValue.SelectedText  == "In Progress")

    {

    //  Add  or  remove from  other  picklist depending  on  criteria.

    crmForm.all.statusReason.DataValue.AddOption(oOption.Text, oOption.DataValue);

    }


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    • Marked as answer by MIDRIANO Monday, June 7, 2010 8:24 PM
    Monday, June 7, 2010 8:08 PM
  • Another option would be to have an on demand workflow change the status for you. That is, create an on demand workflow called 'advance status' and have it set such that if status reason equals x, when the workflow is run, change it to y and if the status reason is y, change it to z. That kind of thing.

    Leon Tribe

    Want to hear me talk about all things CRM? Check out my blog

    http://leontribe.blogspot.com/

    or hear me tweet @leontribe

     


    Want to hear me talk about all things CRM? Check out my blog http://leontribe.blogspot.com/ or hear me tweet @leontribe
    • Proposed as answer by Leon TribeMVP Saturday, June 19, 2010 4:22 PM
    Saturday, June 19, 2010 4:22 PM