Add values dynamically to a picklist - Forum - Rollbase - Progress Community

Add values dynamically to a picklist

 Forum

Add values dynamically to a picklist

This question is answered

Hello,

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

Cheers.

Verified Answer
  • 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
  • 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

  • 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?

  • Hi IramK,

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

    Thanks,

    Orchid

  • Picklist field.

  • 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

  • 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?

  • 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

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

  • 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

  • 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.

  • 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