Field Select based on previous Field

Posted by mysteryminds on 10-Nov-2014 18:53

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

Posted by Varun Tayal on 10-Nov-2014 22:44

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.

Posted by Orchid Corpin on 13-Nov-2014 16:45

Hi Sunil,

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


Posted by mysteryminds on 14-Nov-2014 13:55

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.

Posted by ymaisonn on 14-Nov-2014 14:24

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.

Posted by Orchid Corpin on 14-Nov-2014 15:52

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.



Posted by Orchid Corpin on 14-Nov-2014 15:56


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

Posted by Orchid Corpin on 05-Jan-2015 06:33


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


Posted by mysteryminds on 05-Jan-2015 06:54

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

Posted by Orchid Corpin on 05-Jan-2015 07:03

Thank you for the confirmation.


This thread is closed