You need to sign in to do that
Don't have an account?
zach
Getting picklist values from an object...
So, I've found a roundabout way of getting what I'm looking for, but I'm wondering if anyone can help me with a more direct way. Basically, I'm trying to get the picklist values from a specific (custom) field in the Case object & so far I have this:
Code:
Obviously, I don't need to loop through all of the fields since I know which field's picklist values I want to get... I just don't know how to reference an individual field.
Thanks,
-Zach
Code:
function buildDivisionSelector() { HTML = "<select id='divisionSelector' style='width:170px;'>"; HTML += "<option value='all'>All Servicing Divisions</option>"; var sfObject = sforceClient.describeSObject("Case"); var array = new Array(); for (var a = 0; a < sfObject.fields.length; a++) { if (sfObject.fields[a].name == "Servicing_Division__c") { array = sfObject.fields[a].picklistValues; } } for (var a = 0; a < array.length; a++) { HTML += "<option value='"+array[a].value+"'>"+array[a].value+"</option>"; } HTML += "</select>"; document.getElementById("divisionSelectorContainer").innerHTML = HTML; }
Obviously, I don't need to loop through all of the fields since I know which field's picklist values I want to get... I just don't know how to reference an individual field.
Thanks,
-Zach
Message Edited by zach on 07-28-2006 02:48 PM
Dont think there is way to do it without traversing through the loop, but you can def stop the loop once the match is found.
Anyway, here goes. There is a hashmap structure in the describeSObject result called fieldMap. The way you access it using your code would be
myValuesArray = sfObject.fieldMap.getItem("Servicing_Division__c").picklistValues;
-Zach
Error: sfObject.fieldMap has no properties
Source File: file:///C:/Documents%20and%20Settings/zhegwood/My%20Documents/sforce/reports/test.html
Line: 169
Here's my code:
Code:
i have following code:
<"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="/sCSS/8.0/Theme2/default/elements.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />
<link href="/sCSS/8.0/Theme2/default/common.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />
<!--
Console Related - Unknown if needed
<link href="/sCSS/8.0/Theme2/default/DesktopFrameCommon.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />
<link href="/sCSS/8.0/Theme2/default/DesktopMainPage.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />
-->
<link href="/css/assistive.css" media="aural,braille,embossed" rel="stylesheet" type="text/css" />
<link href="/sCSS/Theme2/{!$Organization.Id}/{!$User.Id}/dCustom.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" />
<script type="text/javascript" src="/js/functions.js"></script>
<script type="text/javascript" src="/dJS/en/library.js"></script>
<script type="text/javascript" src="/js/setup.js"></script>
<script type="text/javascript" src="/js/roletreenode.js"></script>
<script type="text/javascript" src="/desktop/desktopAjax.js"></script>
<link rel="shortcut icon" href="/favicon.ico" />
<script type="text/javascript" src="/soap/ajax/8.0/connection.js"></script>
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script>
function initPage() {
var sfObject = sforceClient.describeSObject("Application__c");
var array = new Array();
var divisionArray = new Array();
array = sfObject.fieldMap.getItem("Status__c").picklistValues;
for (var a = 0; a < array.length; a++)
{
divisionArray[a] = array[a].value;
}
alert(divisionArray);
}
</script>
</head>
<body onload="initPage();">
</body>
</html>
But I'm not getting any values :( from the divisionArray.also iam not able find out error .
Can anyone Help Me.
I am looking forward to it :)
regards
nirmal