Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)
edited by

I am using Django & Salesforce.

I establish a connection between them through simple-salesforce

I have created a custom picklist on Contact Object of Salesforce.

I wont to fetch all the 20 values of my picklist & display in Django.

I am looking for SOQL to fetch values from Salesforce.

sf = Salesforce(instance_url='https://test.salesforce.com', session_id='')

sf1 = Salesforce(connection parameters)

sf3 = sf1.query("SELECT Color__c FROM Contact")

sf3 will give me values set for respective Contact records.

I want to fetch all the 20 values I have entered while creating Color__c on Contact object. In Apex we can do that, something like below

public class PicklistUtil { 

    public static List<Schema.PicklistEntry> getContactColor() { 

        return Contact.Color__c.getDescribe().getPicklistValues(); 

   } 

}

I am looking to do the same in Django. Can someone please help?

1 Answer

0 votes
by (32.1k points)
edited by

There might be a stable way, but the following should work:

d = sf1.Contact.describe()

for f in d['fields']:

    if f['name'] == 'Color__c':

        break

picklist = f['picklistValues']

picklist should then be a list of OrderedDicts.

To learn in-depth about Workflow in Salesforce, sign up for an industry based Salesforce administrator certification.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.6k users

Browse Categories

...