Create a dependant field in QC Test Plan

I wud like to create 2 look up list fields for a test case.Field1(with some values) and Field2(with some values).And the field 2 values shud be dependant on the field 1 values.Based on the selection of values in Field 1 ,the Field 2 should have the values related to the field 1 values.


  • Mahendra,

    This can be done at workflow level,since the dependancy option via interface is only available for defects module.

    Here is what you can do,
    Create 2 new fields and have their lists populated and tied to fields.

    You can have an external MS access file created with two columns and make the field 1 as primary.Map the field 2 values accordingly to field 1 in access file.Call that DB file in workflow script editor.

    This way when you pick field 1 it will query access file and what ever the related value from field 2 will be populated.

    If not you can put simple if else statements by inputting each value in the code in the Testplan Move to action.

  • Hi venkat,
    thanks for the detailed solution.Also if you can please tell me where exactly i have to write a code on Workflow under which action and some code would be helpful to use and change as per my requirement.

  • There is no reason to code anything...there is a build in workflow generation feature called Script Generator - List Customization for Defect Module which does exeactly what you want to do.
    Go to project customization and press the Workflow will be the first in the list
  • Howard,

    Please watch out the request carefully,this is not for defects module.

    I have already mentioned this clearly in my response

    This can be done at workflow level,since the dependancy option via interface is only available for defects module.


    I will provide you with more references shortly.


  • Venkat's answer is correct. We need to go into the Workflow for any module otehr than the defects module.
    You may or may not want an external file based on your conditions. if you just have a few conditions to take care of, you can hardcode the same within the workflow module itself.
    You can do it onpost or onchange or new.. whichever is your preference
  • Hi all,
    thanks for all the responses.

    I am able to write the code for this and succeeded. But i have one small hiccup here in this work. I have 2 fields as mentioned.2nd field shud be disabled or readonly initially (by default)and only when we select a value from the 1st field ,then only the 2nd field shud be enabled and the dependant values shud be shown in the 2nd field.

    I have used CASE statement and based on the 1st field value, second field values will be displayed.
  • Hi Pradeep,


    Can you please share the workflow script for this dependent fields. As I too have a similar requirement and I am not to find the solution


    Thanks in advance!!!

  • Hi Pradeep,

    Can you please share under which module in the testplan of workflow did you code the dependency. Also what opion did you select while creating the 1st and 2nd field under project entities-> Test-> User fields. I created both the fields and hard coded the values using IF-ELSE but the 2nd field does not change even after value in 1st field is changed.Apart from the coding in the Workflow, do i need to assign that to the 2nd field for it to be active. Below is the code, i tried in the workflow script generator


    Sub DesignStep_MoveTo
    On Error Resume Next
    If TS_USER_06 = "Critical" then
    TS_USER_09 = "30"
    else if TS_USER_06 = "Important" then
    TS_USER_09 = "20"
    else if TS_USER_06 = "Nice to Have" then
    TS_USER_09 = "10"
    End If
    End If
    End If



    Rohit Pillai


    Let me see if I can make it simple ...

    Login to project, go to Tools > Customzie menu. Click "project Lists" from left and create Parent and Child Lists - One list for every "combination" ... Sounds tedious but if you want to keep code clean you need to do this. Or you can skip this step .. .your choice!


    Now go to Project Entities area and note down Field Names of the "parent" and "child" lists

    Then click Workflow from the left to go to workflow coding area and click Script Editor from right to get into the fun part ...

    Determine what will "trigger" child list be populated with parent selection. Most probably it will be a "change in value" in parent list (field) that needs to populate child list.

    So go to Defect Module Script (assuming lists are in defects module), and click on BG_FieldChange or BG_FieldCanChange ... These are the scripts that run in the backgroudn when a value changes under ANY field in selected module (defects module in this case)

    BG_FieldChange scripts executes AFTER a change has been made to a field and BG_FieldCanChange executes right BEFORE the change actually occured (in case you would like to interrupt user from making the change or other needs)

    Inside these scripts/subroutines, you need to write the code to dynamically populate child list IF parent equals certain value. That means (simplest way - not my preferred way) would be to have a CASE statement to check what is the value that has been given to the parent list (field) ... Remember this subroutine will run AFTER a change has been made so it is okay to do something like below:

    Select Case FieldName  'FieldName is handled by QC - It is name of field where value changed


         Case "YourFirstValue"   'if parent has a value = "YourFirstValue" then do the following
         'you need to populate the child list here
         'how you do it?
         'easiest way is to create individual lists
         'under "project list" area go out of wrkflow scripting and

         'look for it above "Workflow" option
         'use something like below to populate the list
         'Bug_Fields("BG_USER_04").List = Lists("PutChildListNAMEHereContainingValuesYouWantToSee")

    Good luck!

  • Hey Venkat,

    Thanks for the help you have provided.

    However i'm trying this for test cases under Test Plan in HP ALM. So i hope the solution should not change much except for field names. I created the lists and coded the case select statements under Test_FieldChange in Test Plan Module script. Still when I change the value in field A, the field B is blank and does not reflect new value. Is there anything that I need to change while defining Field A and Field B in Project Entities under User fields in Test folder.