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

create custom objects in a quick way or automatically?



Is there a possibility to create custom objects in a quick way or automatically?

once a month, we have about 20 - 30 accounts for those we have to create a certain custom object. It is tedious to klick at an account, open in a new browser tab, click on new custom object and then on save.

-->>> Is there a way to automatically create a new custom object if one field in the account has a certain value?

Thank you


This would not be achieved inside  but you can create a web service and use meta data API to create object and  schedule this.



 Salesforce Developer Support


Sabine, I presume you don't mean a new "custom object", but rather a new Record of a custom object.  For example, a typical scenario is that an Account has a monthly license and you have to regularly come and create a new Opportunity to capture the revenue (or something like that... that's a poor example).


So you may still need some programming, perhaps a Custom button to create a new record of your object with various parameters pre-filled, etc. but it's certainly doable.


The previous answer was keying in on your use of "custom object", which doesn't seem like what you really wanted?


Best, Steve.


p.s. Or, if I'm wrong, you must have a wacky application!  :-)

Going South.ax738Going South.ax738

Steve is right. Its not objects but records that you are looking for.

You need to write custom code to achieve your need.


We have a similar requirement in our organization that need to insert 30+ records once month as a snapshot of current data into an audit table.
We wrote a "schdulable apex class" that would insert records into our audit table and we schduled that class to run on 1st day of every month at 12:00am at night.
The same solution could apply for you.

Read on:


Hi Steve, Hi Going South,


wow thanks for the really fast response!!


You are right I only want to create new records of custom objects and not new custom object Types.


But I have only Enterprise Edition and not developer Edition ;-(


I have read that I need Eclipse or have to install Java for deploying - this seems to be complex...


Is there no other way to create the new records?




Going South.ax738Going South.ax738

If you want to do it manually, you could use data loader tool to import records via CSV file.

You can download it free from setup/administration setup section/data management/last item - dataloader.


Using data loader export current records as a csv file for the user created columns.


On this file format, remove all records and place all your new records under extract column name structure and by auto-map you can import them into salesforce. [Make sure you dont have any lookup keys that are salesforce ids]


PS: The coding for this is not too complex, just about one page of code. There is always  a starting poiint. ;)



Hi Going south,

Hi Steve,


I decided that I will try in a sandbox and if it works there, I will try to use java for transferring the Apex classes to production.

I told you I am completely new to apex (I am used to code in smalltalk), so my question is a silly newbie question ;-)

I hope you can help me.


The model is: 1 account record can have n "Jubiaktion" records. One "Jubiaktion" record belongs to exactly 1 account record.


Jubiaktion is a custom object.

I want to create Jubiaktion records automatically.


When triggering the code below, the field "Debitor" of the account is set. So I know that the code is performed.

But the new "Jubiaktion" record I want to create, is not generated.


I think that "new Jubiaktion__c" creates a new record.

I think  "" establishes the relationship between Account and the new record.

But the problem is that there is no new record is created.


Do I have to use another statement to establish the relation?

What can be the reason that there is no Jubiaktion record generated?


I appreciate your help





public class JubiCreator {
   public static void createJubi(Account[] accs){
      for (Account a:accs){
           if (a.Status_1_Jubilaeums_Review__c == 'Termin Optimierung zu vereinbaren (Consulting)')
              Jubiaktion__c jubi = new Jubiaktion__c(
                  Status_des_Jubil_ums_Reviews__c='In Bearbeitung (Consulting)');
                  a.Debitor__c = 'World4';


Going South.ax738Going South.ax738

you forgot to add


insert jubi;        ---- this should be the last lane after your new statement.


Hi Going south,


thankyou! I added the insert jubi statement after last line like this:


"                  a.Debitor__c = 'World4';
                  insert jubi; 


I got the following error:


"SELF_REFERENCE_FROM_TRIGGER, Object (id = 001R000000ZUjqz) is currently in trigger createJubi, therefore it cannot recursively update itself: []: Class.JubiCreator.createJubi: line 12, column 19"


I changed the trigger which was a before update trigger to an after update trigger:


trigger createJubi on Account (after update) {Account[] accs =;


Now I get the error mesage:


"Error:Apex trigger createJubi caused an unexpected exception, contact your administrator: createJubi: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Class.JubiCreator.createJubi: line 11, column"


I assume I am one step further but I need your help again...I can not change before and not after....


Thank you!


Going South.ax738Going South.ax738

obv, you cannot include parent objects to be assigned inside a detail object's create statement for assignment.

keep the trigger to be before update only.

within the create record statement, keep only the columns that belong to Jubiaktion__c object on the left side of '=' sign.


is Debitor__c a column of Jubiaktion__c?

If so, pl. hange the lanes


Status_des_Jubil_ums_Reviews__c='In Bearbeitung (Consulting)');
                  a.Debitor__c = 'World4';




Status_des_Jubil_ums_Reviews__c='In Bearbeitung (Consulting)', Debitor__c = 'World4');



Setting the Debitor_c was only for testing purposes. I removed it.


Jubiaktion_c is a custom object with Account as master object.

Account__c is a field within Jubiaktion_c holding the backpointer to the Account.

So Jubiaktion_c needs  an Account for being created.



Account                 <<-----------Master





Jubiaktion__c      <<-----------Child(custom object)

Field: Account__c  is backpointer to the account object



With the statement,


I want to set the backpointer from the new jubiaktion to the accounts id (parent)


But this leads to the error:


Apex trigger createJubis caused an unexpected exception, contact your administrator: createJubis: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001R000000ZUjtk) is currently in trigger createJubis, therefore it cannot recursively update itself: []: Class.JubiCreator.createJubi: line 26, column 19


If I remove,


Apex trigger createJubis caused an unexpected exception, contact your administrator: createJubis: execution of BeforeUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Account]: [Account]: Class.JubiCreator.createJubi: line 26, column 19


how can I create the backpointer to the parent object?


Hi Sabine,


I was searching for a similiar solution and found your posts and was wondering if you finally managed to write a code to create records in a custom object automatically. I am facing a similiar dilema in that I need to create one record in a custom object related to the Opportunity object every time a condition is true in a new opportunity only. I am not a programmer and not very familiar with API  scripting. Could you share your soulution with me please?






Hi Farokh,


my solution was to capitulate :-(


Have a nice day


While creating the Custom Web tab using Metadata Api in JAVA, I am getting Unknown Exception..

------------ Response start ----------
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="" xmlns=""><soapenv:Body><checkStatusResponse><result><done>true</done><id>04s90000003BiCeAAK</id><message>An unexpected error occurred. Please include this ErrorId if you contact support: 1738659891-13066 (234113069)</message><state>Error</state><statusCode>UNKNOWN_EXCEPTION</statusCode></result></checkStatusResponse></soapenv:Body></soapenv:Envelope>
------------ Response end   ----------

Error status code: UNKNOWN_EXCEPTION
Error message: An unexpected error occurred. Please include this ErrorId if you contact support: 1738659891-13066 (234113069)
The object state is Error
The ID for the created object is 04s90000003BiCeAAK

Can you help on this ???