+ Start a Discussion
hamid.komairi1.3940317522316162E12hamid.komairi1.3940317522316162E12 

SOQL : Issue querying label and picklist value for the same field ...

Hello everyone,

I have an Account table with a custom field with data type 'Picklist'.
What I want to do is, for each record in the account table I want the picklist value and also the label for that value.

Due to some limitations I can't execute the simple query ...
SELECT Custom_Field_1__c, toLabel(Custom_Field_1__c) FROM Account"

When I execute that query I get the error ...
INVALID_FIELD:
SELECT UCB_Specialty_1__c, toLabel(UCB_Specialty_1__c) FROM Account
^
ERROR at Row:1:Column:36
duplicate field selected: UCB_Specialty_1__c ].
caused by: AxisFault

If anyone knows a work around or a solution, I'd appreciate to hear about it.
Thank you.

Greetings,

Hamid
Sri549Sri549
Hello hamid,

 As per my understanding about your requirment  you can write query like this
 SELECT  UCB_Specialty_1__c FROM Account,
 SELECT Custom_Field_1__c FROM Account
now you may get error free ,
if it is not solving  your problem . could you please explain me ellaboratedly.
if it solves your problem,
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Srinivas
SFDC Certified Developer



hamid.komairi1.3940317522316162E12hamid.komairi1.3940317522316162E12

Hello Srinivas,

Thank you for your time and answer, very much appreciated.
I think I wasn't clear enough on the issue. Will try to rephrase my problem.

I am trying to run a soql query using a plugin in our integration platform Tibco BW. I want to select both the label which sits somewhere in a translation table and it's picklist value from a field, let's call it Custom_Field_1__s. I know in my earlier post you will find a UCB_Specialty_1__c field, let's ignore this field.

So, my query was very simple :
select Custom_Field_1__c, toLabel(Custom_Field_1__c) from Account

You can see that Custom_Field_1__c appears twice in my query and this is what the exception message is telling me ...
Duplicate field selected, so apparently it's not possible to do this kind of lookup.

I was wondering if there was someone out there who knew a workaround for this issue.

Kind regards,

Hamid

Philippe DebatyPhilippe Debaty
You can apply an alias to the SOQL label column as such:
select Custom_Field_1__c, toLabel(Custom_Field_1__c) customField1Label from Account

 
Jai Prakash GuptaJai Prakash Gupta
Basically we use toLabel() with picklist fields to display picklist values based on User's language if translation is setup in translation workbench for these picklist values.
For Reference - https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_tolabel.htm
eticam joeeticam joe
I have an Account table with a custom field with data type 'Picklist'.
What I want to do is, for each record in the account table I want the picklist value and also the label for that value. https://tractorsinfo.com/nyc-doe-payroll-portal/