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
Ashmi PatelAshmi Patel 

Invalid type: DataloadTest_c

what's wrong n this code???
ERROR ::: Invalid type: DataloadTest_c

public with sharing class DataLoadTestingClass{
    public String phoneVal {get; set;}
    public String countryVal {get; set;}
    public String cityVal {get; set;}
    public String nameVal {get; set;}
    
    public PageReference doInsert(){
        DataloadTest_c objdlt = new DataloadTest_c();
        objdlt.name = nameVal;
        objdlt.city_c = cityVal;
        objdlt.country_c = countryVal;
        objdlt.phone_c = phoneVal;
        
        insert objdlt;
        
        pagereference ref = new pagereference('/apex/insertdlttest');
        ref.setredirect(true);
        return ref;
    }
}
Best Answer chosen by Ashmi Patel
SFDC Coder 1SFDC Coder 1
Hi Ashmi Patel,

After looking your code it seems like you are trying to create the object "objdlt" of type custom object(DataloadTest_c ).
As per the salesforce's standard custom object should have postfix as "__c". But in your code its "_c".
So try your code after replacing "DataloadTest_c" with "DataloadTest__c".

Also Mark it best if it helps you :) 
 

All Answers

sfdcMonkey.comsfdcMonkey.com
hi  try this

public with sharing class DataLoadTestingClass{
    public String phoneVal {get; set;}
    public String countryVal {get; set;}
    public String cityVal {get; set;}
    public String nameVal {get; set;}
    
    public PageReference doInsert(){
        DataloadTest__c objdlt = new DataloadTest__c();
        objdlt.name = nameVal;
        objdlt.city__c = cityVal;
        objdlt.country__c = countryVal;
        objdlt.phone__c = phoneVal;
        
        insert objdlt;
        
        pagereference ref = new pagereference('/apex/insertdlttest');
        ref.setredirect(true);
        return ref;
    }
}
Thanks
Mark it Best answer if it helps you
and let me inform if any issue with it
 
SFDC Coder 1SFDC Coder 1
Hi Ashmi Patel,

After looking your code it seems like you are trying to create the object "objdlt" of type custom object(DataloadTest_c ).
As per the salesforce's standard custom object should have postfix as "__c". But in your code its "_c".
So try your code after replacing "DataloadTest_c" with "DataloadTest__c".

Also Mark it best if it helps you :) 
 
This was selected as the best answer
sfdcMonkey.comsfdcMonkey.com
always use __c (double underscore) aftert custom object and custom field
in your case i find you use single underscore (_c) 
let me inform if it helps you :)
Ashmi PatelAshmi Patel
its not working..
ERROR ::::: Invalid field city__c for SObject DataloadTest__c at line 10 column 9
Ashmi PatelAshmi Patel
User-added image

plz...
Ashmi PatelAshmi Patel
actually done....i forgot add phone as field
my object name is DataloadTesting
DataloadTest__c is not object field