Questions tagged [insert]

Using insert DML, you can insert new records and commit them to the database.

Filter by
Sorted by
Tagged with
1
vote
2answers
169 views

Is my after insert trigger efficient and safe to port to production?

Recently I created an after insert trigger to update a field in my sponsorship object. it works so far in sandbox and has passed the unit test that I have created and has 100% code coverage. here is ...
0
votes
0answers
30 views

Merge Duplicate Contacts

So I have Salesforce system that was implemented 6 years ago and sits ontop of a extremely old sales system. When implemented it was built in a way that it creates duplicate contacts on different ...
2
votes
1answer
31 views

Can't create relationship with Account and Custom object when using FF Unit Of work

I working on a class that needs to insert several records and create relationships between them, mostly to the Account object. I'm passing a deserialized JSON (WrapperRestZopaProviderRequest) to the ...
0
votes
1answer
24 views

Bulk API fails to insert w/ null RecordTypeId, but Rest API succeeds

I've come across an error where the Bulk API and the Rest API differ in their behavior when inserting records with record types. To sum up the problem: Suppose one or more custom record types are ...
2
votes
1answer
23 views

What effect does FOR UPDATE have on pending inserts?

FOR UPDATE will lock a row to prevent other clients from accessing it, as is well documented. Does FOR UPDATE have an effect on pending inserts from concurrent clients as well? For example, assume ...
1
vote
1answer
33 views

At which level do duplicate rules work?

I'm trying to prevent the insertion of duplicate records from concurrent transactions. FOR UPDATE does not seem like a good candidate because the records are not updated, so there is nothing to lock. ...
2
votes
2answers
46 views

How to update existing records and upsert new records

I want to update existing task records but a new record gets created instead . What am I doing wrong. Apex: public static void Activities(List<Account> accounts) { Set<Id> persAccIds = ...
0
votes
0answers
75 views

FIELD_INTEGRITY_EXCEPTION, Every asset needs an account, a contact, or both and field comparison

I have been trying to insert new assets to the asset table and use the serial_number to check if the asset already exist before inserting it to avoid duplicates. I'm at the point where I am trying to ...
3
votes
1answer
55 views

Does locking of account lock related contact during insert?

I have a WSDL Apex service that consumes XML and creates a series of objects. XML received and parsed, queries for and finds a single account "Potential Customer" to relate potential customer ...
1
vote
1answer
24 views

Inserting dependent objects without using a loop

I have this issue. I have a list of Contracts and I need to create Cases and custom objects called 'Budget' that the Case needs to lookup. The code can be summarized to something like this for(...
1
vote
1answer
225 views

Upserting records using SFDX CLI for a object with no External Id

Below are the available data related commands in CLI. If I want to insert records using SFDX CLI, how to do that? force:data:bulk:delete -- bulk delete records from a csv file force:data:bulk:...
0
votes
0answers
44 views

simple_salesforce bulk insert - Duplicate Id error

I am using the Python package simple_salesforce to bulk insert instances of a custom object. The custom object has Account Id as a foreign key, which I am inserting during the bulk insert. I'm seeing ...
0
votes
1answer
143 views

simple_salesforce - Cannot bulk insert more than 10 records at a time [closed]

I am using the simple_salesforce Python package. I tried bulk inserting 100 records using bulk.insert(), and did so without any errors. However, when I checked how many records were present after, ...
0
votes
0answers
246 views

System.TypeException: DML operation INSERT not allowed on __Share

I have created share object in my salesforce environment. From Setup-> security Controls -> Sharing Settings -> I made my custom object access to "Private". So suppose my object name is EVT_Client__c ...
1
vote
2answers
82 views

Apex Test class for web-to-lead creation without OwnerId

I need to create an Apex test class for a Lead Apex Trigger that handles "before insert" of the web-to-lead inserts of Lead records that DON'T have OwnerId at the "before insert" time. Assigning of ...
-4
votes
1answer
78 views

Trigger not creating a new record [closed]

If case status got change for certain record type, new support record should get created. I configured status and record type combination in custom setting I am trying to avoid nested loop in my ...
0
votes
1answer
46 views

Trigger.new information; Insertion of new Contact

I have a trigger that on contact creation/insertion, I need to get its ID and make a new task associated with that ID. However, I have System.debugged Trigger.new, and I see that the newly created ...
0
votes
2answers
45 views

How to insert more than one record from visualforce page to custom object?

I want to insert the records in a custom object. The code is working fine when I insert one record at a time but when I am trying to insert more than one record on a same run one at a time than it is ...
-2
votes
1answer
76 views

Getting Unexpected Token error when inserting records from execute anonymous [closed]

Custom_Object__c co = new Custom_Object__c(Name='TEST', Date_of_Visit__c=2019-06-06); insert co;
1
vote
1answer
145 views

Insert Case Apex - Disable Active Assignment Rules

I am trying to insert a case in apex and set the owner to a specific user id. However active assignment rules are rerouting the case. In apex, how would I disable the use of active assignment ...
0
votes
1answer
63 views

List.clear() not emptying my List

The project that I am working on has an API endpoint that is meant to upload a large number of records into three different tables: Careers, Degrees, and CareerDegreeRelationships. The endpoint is ...
0
votes
2answers
34 views

Testing a trigger that is suppose to cover an failed check

I have a trigger on a custom Student object that is suppose to assign the lookup field Advisor based off of another look up field Gender. Basically my trigger goes: ... if (newStudent.Gender__c == ...
0
votes
1answer
27 views

Assign a record as a look up object before insertion

I am attempting to write an api endpoint meant to upload many objects of one type. This object, MyObject, contains a lookup field that looks up another MyObject record for translation reasons. ...
0
votes
1answer
77 views

Link files lead to new custom object

On Lead conversion I also create a new object to which I map several fields of the lead trough processbuilder. I also want to pass the files from the lead to the new custom object. I am trying to do a ...
1
vote
1answer
210 views

Is there a way to insert data with specific IDs?

I'm not sure if I'm explaining this correctly but I'll give it a shot. I'm trying to use Data Loader to insert CSVs of data into a Partial Pro sandbox, but I want these inserted records to use the ...
1
vote
1answer
384 views

Error: Too many DML rows: 10001

I have a question here, every time I run my code I first delete everything that is in the object, and then inserted a new list, when I try to do this simultaneously with the error ERROR System....
3
votes
4answers
860 views

|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object on my Apex Trigger

I'm kind of new in Apex development and I'm writing a before insert, before update trigger to a custom object that is going to be upserted through an API integration. Is very basic code but I don't ...
-2
votes
2answers
246 views

How to insert Lookup field value in a Trigger?

I am trying to build a after insert trigger on Contract object. Whenever user will create a Contract record trigger will generate/insert record of other object called Dim2. Dim2 have a lookup with ...
0
votes
1answer
288 views

Get record ID in Trigger.isBefore && Trigger.isInsert

I want to get the ID of the record in Trigger.isBefore && Trigger.isInsert. I need to start a batch process based on this ID. It works for Trigger.isUpdate but does not work for Trigger....
0
votes
3answers
739 views

How to find required fields for an sObject?

I know the question has already been posted, and answers where given ; I read this topic ; Of course I can try to insert the sObject and get the error listing the missing fields, But isn't it a '...
0
votes
3answers
365 views

Insert 2 objects (parent and child) at a time (over 200 records)

I have over 200 records, and I need to insert 2 lists. Work's records are created too fast and can't take a customField from still not inserted Case. If insert 1 per time - Error: Too many DML ...
1
vote
2answers
104 views

Why is my flag not working on maximum trigger depth exceeded

I have written a trigger for purchases if the purchase contains several of the same purchase detail items they should be summed up and merged as 1 purchase detail. When I use a before insert I get in ...
1
vote
1answer
271 views

DUPLICATE_VALUE Error Upon FieldPermissions Insert

We created a tool that scans Permission Sets of a installed managed package, "clones" these Permission Sets and removes any Permissions defined as too powerful. However upon FieldPermissions Insert i ...
2
votes
1answer
480 views

Unable to insert records using Iterable Batch class

I'm trying to create an Iterable Batch class for inserting records. I'm able to insert my records in my normal class. I have created the Batch class and am trying to call it my current class in the ...
2
votes
0answers
582 views

How to insert records in Big Object through developer console?

I am creating Big Object through workbench like Survey__b. I inserting record through developer console, in this time showing error: Variable does not exist. But i have all variables in the big ...
0
votes
1answer
135 views

Create one grandchild record per child record

I need to create automation that creates one grandchild record per child record, when criteria are met on the parent record. The initial criteria are straightforward: two field values on the parent ...
-2
votes
1answer
164 views

after insert,after update trigger doesn't work

Below is my trigger to create a new record(with next quarter) when Hold and freeze are set to true. But this works for new but not update. below is my trigger and . trigger AddingNewQuarter on ...
1
vote
1answer
47 views

Create Child record when Parent's Parent Updates

I have to be able to create a child record called "seats" when the parent of the parent object of "Seats" changes. Teams -->Tables---> Seats So when Team changes, I need to be able to create Seats ...
0
votes
1answer
86 views

Create Users Records with SFDX, Bad Timezone

I'm Trying to create one user record with by creating them with SFDX and the minimum required data about the user, into a scratch org (later trying it in an actual sandbox or production), but I have ...
0
votes
1answer
374 views

Create Child Record if a lookup on a Parent Object Changes

I'm pretty close to being maxed out on workflows for my custom objects. So I decided to see if apex classes could help, I'm still currently trying to learn how to write triggers and classes so Im ...
1
vote
1answer
851 views

Inserting Child Records with Master-Detail Relationships

I'm allowing a user to upload multiple files for accounts, contacts, and trades. Contact looks up to Accounts via a lookup field while trades look up to accounts via a master-detail relationship. I'...
-1
votes
1answer
170 views

Trigger:Too many soql query error

when I create or update record, am getting too many soql query error. following are my code: trigger UpdateAssetImageurl on SymphonyIPM__Patent__c (after insert,after update) { List<...
0
votes
0answers
63 views

Inserting Accounts and Contacts (that look up to the Account) in the same class

I'm trying to insert Accounts and Contacts in the same class. I'm inserting the account first, then inserting contacts, based on the account name. The account field in contacts is not getting ...
0
votes
1answer
264 views

Cannot Reference Contact fields in Validation Rule Formula

I'm trying to create a validation rule that disallows a User from creating a record if their contact has a certain checkbox checked. Unfortunately, when I reference the $User object, there is no ">" ...
1
vote
1answer
3k views

System.assertEquals for records in a list? Test class

I have a batch class that inserts Journal records after updating Account records... I am new to apex and cannot think how to test the inserted records in the test class. I have a list to get the ...
6
votes
0answers
158 views

Why inserting a user object and making callout in a test throws CalloutException in Production?

I stumbled upon strange behavior when executing tests on deployment to production organization. In the test, I first insert a User object, some other objects and then as the last one, a CampaignMember ...
0
votes
2answers
602 views

Trigger to update fields on record create or edit

I have a trigger on the OpportunityLineItem object that we use to update 4 revenue fields with specific calculations when the record is either created or updated. For some reason it seems the trigger ...
0
votes
1answer
1k views

Pass value from one method to another

How do I pass a value from one method to another. I am using a public list with a {get; set;} but this seems not to be working. What I want to achieve is to loop trough the insert from the first ...
3
votes
0answers
74 views

First event/event relation insert taking a while

I have an application that inserts events and event relations in an org's database and has a loading icon to prevent the user from doing anything until the event and relations are properly created and ...
0
votes
1answer
418 views

System.ListException: Before Insert or Upsert list must not have two identically equal elements for my DML operation [duplicate]

I have below code where I try to insert an SObject and getting an error as mentioned in subject. I have tried to fetch newly inserted records of say Object1, and putting them in Object2 lookup field ...