Picklist values in JSDO coming as numeric values

Posted by mnashi on 09-Jan-2016 10:12

How to get the actual text value of a picklist field in JSDO? The data is coming as numeric value instead of the actual text. Same thing happens for workflow status fields. 

Posted by Anoop Premachandran on 18-Jan-2016 03:08

The IDs will change for each tenant. Please define integration code for workflow statuses and use that. They will remain same across tenants

All Replies

Posted by Ganesh Cherivirala on 11-Jan-2016 01:14

Hi,

There is no direct way to get the picklist values. However there is an API to return the data.

Below is the sample code to get the picklist, where the state is the picklist.

picklist gives the response as array with code, ID, Name e.g: as below

code: "AL"

id: 98892459

name: "Alabama"

var pickListStateResponse = jsdo.getPicklist_state();

               if(pickListStateResponse.response.picklistData){                  

                   var stateList = pickListStateResponse.response.picklistData;

                   var stateEle = $('#state');

                   for(var k=0;k<stateList.length;k++){

//Here based on the requirement we need to map id with code or name

                       stateEle.append($('<option value="'+stateList[k].id+'">'+stateList[k].name+'</option>'));

                   }

//console.log(selectedRow);                  

                   if(selectedRow && selectedRow.state){

                       for(var l=0;l<stateList.length;l++){

                           if(stateList[l].id===selectedRow.state){

                               stateEle.val(stateList[l].id);

                               break;

                           }

                       }

                   }

               }

Hope if helps!.

Regards, Ganesh

Posted by mnashi on 12-Jan-2016 20:28

Although not a straight forward way to get the values, it answers the first part of the question. I also want to know how to get the workflow status value.

Posted by Ganesh Cherivirala on 13-Jan-2016 05:50

Even there is no straight forward way to get the workflow status values. Generally workflow have very less items. So we can make use the switch case (not a good solution).

Here is the sample code.

// status is a workflow item having submitted, Registered, Approved, Declined

var statusEle = $('[name=status]');            

{

                    var status = selectedRow.status+'';

                    //console.log(status);

                    switch(status){

                        case "39338254":

                           statusEle.val('submitted');

                            break;

                        case "39338253":

                           statusEle.val('Registered');

                            break;

                        case "39338255":

                           statusEle.val('Approved');

                            break;

                        case "39338256":

                           statusEle.val('Declined');

                            break;

default:  

                            statusEle.val('submitted');                                              

}

Hope it helps!!

Regards, Ganesh

Posted by mnashi on 13-Jan-2016 20:02

This raises few more questions:

1. How to get numeric IDs for various workflow status values?

2. Are the IDs going to remain same when the application is deployed to different tenant?

3. Is there any documentation explaining how to get picklist values?

4. Are there any enhancements planned to make this easier for developers?

Posted by Ganesh Cherivirala on 17-Jan-2016 06:36

Hi,

In your context - Different tenants means?

Posted by mnashi on 17-Jan-2016 21:54

By different tenants, what I meant was if the application is deployed to different client then would the numeric values of workflow status or picklist fields remain same?

Posted by Ganesh Cherivirala on 18-Jan-2016 00:03

Hi,

Deploying the application on different client won't change the numeric values.

Posted by Ganesh Cherivirala on 18-Jan-2016 00:39

Can we assume different client is nothing but its a different users on private cloud or something else

Posted by Anoop Premachandran on 18-Jan-2016 03:08

The IDs will change for each tenant. Please define integration code for workflow statuses and use that. They will remain same across tenants

This thread is closed