Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.
    list<invoice_setting__c> invoiceset = [select SiteUrl__c, Prefix__c, 
                                           Seperator__c,Seperator1__c,DateValue__c,
                                           DateValue1__c from Invoice_setting__c limit 1];
    system.debug('query'+invoiceset);

In this SiteUrl_c, Prefix_c are text fields and remaining fields are picklist values.

Although I have values in picklist they are not appearing in query in debug, I can however see the textfield values.

How can I overcome this problem?

share|improve this question
    
Are you sure you have value in that field for the particular record the Query fetches ? –  Mohith Shrivastava Nov 21 '12 at 10:26
    
yeah I'm having values in it(but I'm not inserting this values into any object) –  Eagerin Sf Nov 21 '12 at 10:27
    
Huh. The values you declare in a picklist configuration are part of the metadata, that won't show up in soql. When creating objects (database records), you should select one of the picklist values , if you do that, the selected value (or values in case of multi select picklists) should be present in your soql query. –  Samuel De Rycke Nov 21 '12 at 10:54
    
I've found the query tool to be a bit hit and miss, what result do you get if you run this query in a Data Loader extract? –  DavinC Nov 21 '12 at 13:47

1 Answer 1

It would appear that your picklist values are null. I set up the following test in a developer org. I set up a test object like:

Test Object Settings

As you can see, this is a very simple object with just a text value and a picklist value. I then proceeded to correct a record for that object:

Sample Text Object With All Values

Notice how both the text field and the picklist field have values. I then went into the Developer Console and ran the following statement:

List<Test_Object__c> objects = [
    SELECT 
        Test_Text__c, Test_Value__c 
    FROM 
        Test_Object__c 
    limit 1
];

System.debug(objects);

This statement ran and the following can be seen in the debug logs:

Sample Debug Log With Values

Notice the second line. This is the line that is outputting the System.debug message. Notice how Test_Text__c and Test_Value__c are both displayed. Now, I am going to go back into the object and remove the picklist value. The following is the saved result:

Sample Test Object Without Picklist Value

Notice how the picklist field is now null. When I go back into the Developer Console and rerun the same exact query, this is the result:

Sample Debug Log Without Picklist Value

Once again, notice the second line which is the output of our System.debug statement. Notice how it is now missing the Test_Value__c field. This is due to the fact that the field is null.

So, long story short, in order to get your picklist values to display in your debug statement, the selected record must have values for those picklist values in the database. If they are null, they do not show up in the debug logs. For your instance, I would wager that your selected record does not have values entered. Enter some values there and the debug logs will reflect those values.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.