Can rbv_api.selectQuery() return picklist values instead of

Posted by Rollbase User on 30-Aug-2012 10:52

Is it possible to use rbv_api.selectQuery() to return the values of a picklist field instead of the id? I have a picklist field with the integration name state_of_residence this line rbv_api.selectQuery("SELECT name, state_of_residence FROM student",100) returns the ID's of the state_of_residence picklist, not the values. I need the value because I am comparing this picklist with an identical picklist in another object. The ID's change from object to object so the value is what I need to compare. I tried using state_of_residence#value with no luck. Is there any way to do this?

All Replies

Posted by Admin on 30-Aug-2012 11:33

Query API does not perform data formatting or transformation. We have another API to determine Integration codes by ID.

Posted by Admin on 30-Aug-2012 11:35

What do you recommend for this type of situation?

Posted by Admin on 30-Aug-2012 12:37

Just to clarify.

I have two picklists with the same list of values. One is located on the object x and one is located on object y. both picklists are titled state_of_residence.

In my formula, I want to query both objects and build arrays from the values stored in this picklist for all of the records in both object x and object y.

I am using rbv_api.selectQuery() to build two arrays of values (one array for each object). I would like to use these arrays in a comparison. However, rbv_api.selectQuery returns numeric ID's of the picklist values, not the values themselves.

On object x, the picklist value of the "North Carolina" option has an ID of 600217

On object y, the picklist value of the "North Carolina" option as an ID of 600176

I am unable to compare the ID's from 2 different objects because the ID's are different depending on the object.

What other API were you speaking of that could accomplish this?

Posted by Admin on 30-Aug-2012 13:15

You should use "shared" picklists, so "North Carolina" will have the same value regardless of object.

Posted by Admin on 30-Aug-2012 23:28

Hi Ben,

Pavel's recommendation of using Shared picklists would work because then you would be dealing with the same field (Shared Picklists can be shared among more than one object definition).

If you don't want to change to Shared Picklists I would recommend using the following Object Script API method:

rbv_api.getCodeById (objName, fieldName, id)

To use this you'll need to make sure all of your picklist values on both objects have integration codes if you haven't defined them, and they should be identical for both fields. IMPORTANT: Use the "Replace" option on each Picklist field to add the integration codes to each value. For example:

1. Go to Object X, go to Fields section, find your State of Residence field and click the "Replace" action

2. Keep the value the same but define an integration code such as NC for north Carolina

Once you have identical picklist codes defined you can use the rbv_api.getCodeById() method to match the picklist values by Code.

See the section called "Miscellaneous

This thread is closed