Field Select based on previous Field - Forum - Rollbase - Progress Community

Field Select based on previous Field


Field Select based on previous Field

This question is not answered

Hi all 

I have a simple query related to selection and let me put the things in detail so that I can provide the clear picture.

First Field is a Relative Field which has  options like  Books, Pens, Knife, Cutter, Eraser etc...

Second Field is Multiple Picklist field  which has options like  Long, Short, Medium, XL, MIDrange, short Range, others etc

so my query goes this way  - if user selects ONLY PENS from the first field  list 
it must Make Second Field  Option as Not selected as default, but it should not allow the user to save the record unless and untill He selects the value in Second Field

which means
First field  valued = PENS
Second Field Value =  "                            "   - as soon as user selects PENS
But we must make sure that Second Field is Compulsory for the user to save the record.... 

is it easy to do in Javascript or trigger

All Replies
  • The best way to do this is using Client side Javascript code for the first part where you can set a default value on any field based on a value selected in some other field.

    For example, Please check in documentation, Chapter 7 - Client-Side Customization---> Setting Default Values.

    For the second part you can use Validate Record data Triggers to validate your data before update.

    For details- Please check in documentation, Chapter 10- WorkFlows and Triggers----> Triggers -----> Trigger Types ----> Validate Record Data.

    hope this helps.

  • Hi Sunil,

    Does the above suggestion works for you? or do you have any followup questions related to this topic?
    Thank you.

  • Dear Orchid

    I'm pure Novice to RB, and just trying and figuring out ways to work on this, I would surely be needing a expert advises like you guys in near future.

  • Hi, check out this discussion thread: [EDIT]

    If you want to enforce the fact that  the user must choose a value for the second field, depending on the selected first field's value, then you may write a custom field validation code for the second field:

    - checking which value was selected from the first (dependent) field

    - returning an error if no value was selected for the second field.

    Please let me know if you need further clarification for the implementation.

  • Hi Sunil,

    I understand, so here is a detailed things to-do to achieve it.

    Before anything else:

    Make your picklist option values something like the below values (with - "|") so we can utilize the rbf_getPicklistCode(); Those codes |B, |C, |K, etc... must be unique.

    Picklist values:

    IMPORTANT NOTE: If you do not have the codes yet (like |B, |C....), DO NOT directly edit the the picklist to add those or it will empty the values on ALL existing records, so use "Replace" that was in the Action column of your field, see image below.

    1. Go to object definition

    2. Click on "Events" under Action column of the picklist containing PENS, Knife...

    3. Under "onchange" specify a function e.g. changeSizeValue(); 

    4. Go to New or Edit page and drag a scrip component to a section and specify below code *replace the field names

    function changeSizeValue() {
        var typeCode = rbf_getPicklistCode("firstPicklist_here");
        if(typeCode == "P") {      //P stands for PENS
            rbf_setFieldValue("secondPicklist_here", "-1");    //CLEAR PICKLIST OPTION

    5. Go to object definition and add field validation to second object with the code below. 

    if("{!firstPicklist_here#code}" == "P" && "{!secondPicklist_here#code}" == "") { return "Must specify a value!"; }

    Save and Test.



  • Revision:

    5. Go to object definition and add field validation to second picklist with the code below.

  • Hi,

    Is the issue has been fixed? or are there any followup questions regarding this thread?
    Thank you.

  • You can close this issue Orchid... As I have removed the complete option list from the section as it didn't work

  • Thank you for the confirmation.