function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CaptaConsultingCaptaConsulting 

How can i get all the values of a picklist field? In javascript or vbscript

Hi,

I am doing an Sforce Control with javascript and I need to know which are the possible values of a field with type picklist because i need to compare this values with other field.

I hava seen in the forum how to do it in JAVA calling the "describeSObject" instruction, but not in javascript or vbscript

I have tried this, but id doesn´t work.

.................

var sfdc = new ActiveXObject('SForceOfficeToolkit.SForceSession');
sfdc.SetServerUrl('{!API_Enterprise_Server_URL_50}');
sfdc.SessionId = '{!API_Session_ID}';

var newCItems = new Array(1);
newCItems[0] = sfdc.describeSObject('Contract');
var e2 = new Enumerator(newCItems);
var sobj2 = e2.item();

document.writeln("PICKLIST VALUE 0 = " + sobj2.item('Status').picklistValues[0].value);
document.writeln("PICKLIST VALUE 1 = " + sobj2.item('Status').picklistValues[1].value);
document.writeln("PICKLIST VALUE 2 = " + sobj2.item('Status').picklistValues[2].value);

.................


Any clue, code or help?

Thanks.

Victor Alvarez
DevAngelDevAngel

This bit of code should do the trick.

 

 var x = sfdc.CreateObject("Contract");

var flds = new VBArray(x.Fields).toArray();

for(var i in flds) {

if (flds[i].Type == "picklist") {

var plvs = new VBArray(flds[i].PickListValues).toArray();

for (var j in plvs) {

document.writeln("    value: {" + plvs[j].Value + "} label: {" + plvs[j].Label + "}");

}

}

}

CaptaConsultingCaptaConsulting

Hi Dave,

It works great.

Thanks.

Víctor �lvarez