Find your content:

Search form

You are here

Getting only text values in Query

 
Share
    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?


Attribution to: Eagerin Sf

Possible Suggestion/Solution #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.


Attribution to: Jesse Altman
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4640

My Block Status

My Block Content