You need to sign in to do that
Don't have an account?
Rajashri
How to create Sobject and assign value to it
Hi ,
I have created the below class and want to create sOject and assign value to it.
Can anyone guide me , why m i getting the compiler error "Invalid Invoice_Starement_c " type?
Below is my code
public
withvsharingvclassvObjectprac {
publicvstaticvvoidvobj()
{
sObject s =
newInvoice_Statement__c();
Invoice_Statement__c inv =
new Invoice_Statement__c(Description__c='Test Invoice',Status__c='Pending');
System.debug(
'Invoice'+ inv.Description_c);
}
}
change the code as follows
public withvsharingvclassvObjectprac {
publicvstaticvvoidvobj()
{
//sObject s =newI nvoice_Statement__c();
Invoice_Statement__c inv = new Invoice_Statement__c();
inv.Description__c = 'Test Invoice';
inv.Status__c = 'Pending';
//If you are inserting or updatingor some thing else
Insert inv;
System.debug('Invoice'+ inv.Description_c); //here not _c it is__c , your are passing a hardcode values why you are writuing the debug.
}
}
All Answers
hi i didnt get one thing do you have object with fields and you are creating record on it or you would like to create a object by using the custom coding.
if you are creating a object with in the class which was not existing, then check how to create and process and procedures.
Hi,
Thanks for the reply.
Actually Custom object is already there but it is giving me error msg Invalid type.
change the code as follows
public withvsharingvclassvObjectprac {
publicvstaticvvoidvobj()
{
//sObject s =newI nvoice_Statement__c();
Invoice_Statement__c inv = new Invoice_Statement__c();
inv.Description__c = 'Test Invoice';
inv.Status__c = 'Pending';
//If you are inserting or updatingor some thing else
Insert inv;
System.debug('Invoice'+ inv.Description_c); //here not _c it is__c , your are passing a hardcode values why you are writuing the debug.
}
}
Thanks a lot!!
How can i see my record got inserted successfully in the database?
add the invoice object to to the tab then you will have the access to edit and view the records
setup -> create -> tabs