function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
marys pindamarys pinda 

Custom field type number

Hello,
I created a custom field of satisfaction with type number.
I made a reques to see what returned me:
select Name,Satisfaction__c from Contact

And I is not got what I wanted:

The desired:
Name, Satisfaction__c
Marcia Morgado, 10
Rosana Moreira, 8
Vanessa Pedrozo, 7

The obtained:
Name, Satisfaction__c
Marcia Morgado, 0032000001E3fVyAAJ
Rosana Moreira, 0032000001D8WWsAAN
Vanessa Pedrozo, 0032000001D8Y4nAAF

CODE:

String query=inputText;
String first=query.substringAfter('select ');  
first=  first.substringBefore('from');
     
    string title= first+'\n';
    string contenuCSV = title;

    string queryResultString = '';
    list<sObject> queryResult = (List<sObject>)database.query(inputText);
    for(sObject a: queryResult)
    {
        queryResultString = queryResultString + string.valueof(a);
    }
    list<string> queryLines = queryResultString.split('}');
    for(string s:queryLines){
        list<string> queryCol = s.split(',');
        for(string st:queryCol){
            contenuCSV = contenuCSV + st.substringAfter('=') + ',';
        }
        contenuCSV = contenuCSV.substringBeforeLast(',').substringBeforeLast(',') + '\n';
    }

How do I solve this problem with numeric fields?
Thank you,
Vamsi KrishnaVamsi Krishna
Seems your inputText is querying for Name and Id instead of Name and Satisfaction__c

the values you have are all Contact record Ids (starting with 003 .. )
Marcia Morgado, 0032000001E3fVyAAJ
Rosana Moreira, 0032000001D8WWsAAN
Vanessa Pedrozo, 0032000001D8Y4nAAF

where do you get the inputText from ? once you change the actual query in the inputText it should work fine..
marys pindamarys pinda
My inputText receives the request: select Name,Satisfaction__c from Contact only
Emmanuel B.Emmanuel B.
Vamsi Krishna is right, you query contact Ids.
Either your inputText is not correct, or your field Satisfaction__c is not a number but an Id (or a formula leading to an Id).
You should add a system.debug(inputText) or add it to contenuCSV to check what happens.