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.
The IDs will change for each tenant. Please define integration code for workflow statuses and use that. They will remain same across tenants
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
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.
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
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?
Hi,
In your context - Different tenants means?
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?
Hi,
Deploying the application on different client won't change the numeric values.
Can we assume different client is nothing but its a different users on private cloud or something else
The IDs will change for each tenant. Please define integration code for workflow statuses and use that. They will remain same across tenants