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
crocodilecrocodile 

!!!!Record is not inserted!!!!

Hi all,
         I have two objects prac__c, Dept__c.
I wrote a trigger for prac__c which calls a method m1() in pracs_prac1.class when a record is created/updated in prac__c object
Apex class shown below:

public class pracs_prac1 {
    public static void m1(prac__c[] a1)
    {
        Dept__c dpt=new Dept__c(Name='testing');
        try
        {
              insert dpt;
          }
          catch(DMLException e)
          {
               system.assert(false,'Error creating Calc:'+e.getDMLMessage(0));
          }
       
    }

}


This class is compiled successfully without any error.

But when i created a record in prac__c no record is inserted in Dept__c

Is there any createable property set to be true?

when i used the statement: Dept__c.createable=true; in the above class getting an error saying Save error: Variable does not exist: Dept__c.createable

then how can i set the createable property to true?
Is there any code i have to use apart from this? Please help me in this regard.

Thanks in advance,
-Vissu


kathyanikathyani
It says variable does not exist. May be there is no field by that name defined in your object.
I might be wrong but may be field is spelled differently in your object.
SuperfellSuperfell
Where's your trigger code, what do your unit tests look like, do any of them pass?
crocodilecrocodile
Hi Simon-
Thanks for ur reply.
My trigger code:

trigger pracs_trig1 on prac__c (before insert, before update)
{
    prac__c[] a1=trigger.new;
    pracs_prac1.m1(a1);
 }


First of all i want to insert a record named testing. After successful insertion i wan to pass the values for the fields.

-Vissu
crocodilecrocodile
Hi kathyani,
Thanks for ur reply.

createable is not a field.
In  http://www.salesforce.com/us/developer/docs/apexcode/index.htm    there is a statement like
"To create an sObject record, the createable property of the sObject must be set to true"
So, i tried to set createable property to true using the code:
Dept__c.createable=true;

Then getting an error saying: Save error: Variable does not exist: Dept__c.createable

Any idea to rectify this error...?

-Vissu