Add values dynamically to a picklist

Posted by IramK on 13-Nov-2014 05:14

Hello,

Is it possible to add values to a picklist dynamically rather than predefined values? Kindly let me know.

Cheers.

Posted by Orchid Corpin on 13-Nov-2014 09:57

There is no functionality to have this. Options are predefined during the field creation.

When we add some JQuery codes like $("#picklistName").append("<option value='new'>NEW</option>"); this will have the NEW option BUT values will not be saved.

Workaround is:

 - Create a new object (e.g. Product) and create a relationship to your main object (Warehouse).

- In the New and Edit page of Warehouse, go to design page change the lookup style to "Picklist"

- Every time you add new record to Product that will be automatically available as option in the picklist.

 

Regards,

Orchid

All Replies

Posted by Ranjana sinha on 13-Nov-2014 05:32

Hi IramK,

Can you tell us the exact scenario where in you want to add values to picklist dynamically.

In general while importing data from spreadsheet we have an option to create picklist values on the fly. During submit a checkbox is provided "Create new picklist items during import".

Thanks,

Ranjana Sinha

Posted by IramK on 13-Nov-2014 05:47

Basically I am trying to access the metadata 'objects' definitions available to me and I would like to get them as a picklist dynamically as it would change. Any suggestions?

Posted by Orchid Corpin on 13-Nov-2014 08:43

Hi IramK,

Is this a picklist field you are referring to or a lookup that was rendered as picklist?

Thanks,

Orchid

Posted by IramK on 13-Nov-2014 08:45

Picklist field.

Posted by Orchid Corpin on 13-Nov-2014 09:57

There is no functionality to have this. Options are predefined during the field creation.

When we add some JQuery codes like $("#picklistName").append("<option value='new'>NEW</option>"); this will have the NEW option BUT values will not be saved.

Workaround is:

 - Create a new object (e.g. Product) and create a relationship to your main object (Warehouse).

- In the New and Edit page of Warehouse, go to design page change the lookup style to "Picklist"

- Every time you add new record to Product that will be automatically available as option in the picklist.

 

Regards,

Orchid

Posted by IramK on 13-Nov-2014 10:22

But I have a list of objects available to me via a REST API call. All I want is to populate this list as a picklist. Is it not possible in any other way?

Posted by Orchid Corpin on 13-Nov-2014 10:44

I see, via REST API call, there is a method "updateFieldDef()", I haven't tried calling it but seems like this will do the updating of the picklist via REST.

See Chapter 14 > REST Metadata Methods > updateFieldDef (as of now at Page 697)

documentation.progress.com/.../RB_User_Guide.pdf

Regards,

Orchid

Posted by pvorobie on 13-Nov-2014 11:00

I'd recommend to use Lookup field instead (relationship).

Posted by ymaisonn on 14-Nov-2014 06:34

Indeed, creating a related object that would contain all the picklist values is a more flexible approach.

Create an object with

- Picklist label

- Integration code

Do not use the record ID  as an integration code since its value may change if you migrate the data to another Rollbase instance for example.

Then create a 1:M relationship between the picklist object and your existing object

Posted by IramK on 17-Nov-2014 04:30

This object that would contain the picklist label and integration code needs to contain all the objects available in rollbase (to choose from). Any suggestions on how I could get that done? I currently have done that via a REST API call: GetObjDefNames() and have populated the list of available objects to me. Is there any other way?

Goal: To achieve my object list as given below and then use that as a picklist in my related object picklist field.

Posted by Orchid Corpin on 17-Nov-2014 07:59
I would suggest to create a relationship to all of those objects available it is just a one time setup.
After that you can already use its related Object as a picklist, just drag-n-drop the lookup field and make it picklist style as above image.
Less coding or totally no code needed to have the picklist to those object in that list.

Regards,
Orchid
This thread is closed