Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [insert]

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

1
vote
1answer
14 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
48 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
0answers
24 views

How to write Apex test for record creation? [duplicate]

I'm having a hard time writing up a test class for the following Apex class: public class logger { @AuraEnabled public static void insertLog(string name, string id, string location, string ...
0
votes
2answers
23 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
16 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
26 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 ...
0
votes
1answer
50 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
80 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
402 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
71 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
97 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
213 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
96 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
97 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
61 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 ...
1
vote
1answer
201 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
319 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
72 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
116 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
40 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
63 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
216 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
551 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
151 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
42 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
141 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
1k 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
131 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
273 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
483 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
57 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
295 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 ...
2
votes
2answers
316 views

Lead before update runs on insert

I have a fresh dev org, with nothing at all in it other than this one trigger that is below. When I create a new lead, this trigger is ran. (ie, I put the new leads name as John Smith and Company as ...
0
votes
1answer
750 views

What's the correct way to write PathOnClient for Content Version with Data Loader on Mac?

I'm using Data Loader for Mac to import documents as Content Versions, but I get errors while uploading: "Error converting value to correct data type: /Applications/Data Loader.app/ /Users/..../...
-4
votes
1answer
1k views

Method does not exist or incorrect signature: void isEmpty()

I Get te following error on my testclass: Method does not exist or incorrect signature: void isEmpty(). There are several answers to this but I still dont understand what is wrong with my testclass. ...
1
vote
2answers
318 views

How to Get Newly Created Id After Insert Called from an Event

I can't seem to get the Id of my newly created Contact record. When clicking the "Save Contact" button, the contact is saved, but I can't figure out how to reference the new Id. I would like to use it ...
0
votes
1answer
36 views

Error catching when inserting multiple object types

We have a page inserting three different object types. Historically, it has attempted to insert one and, assuming no errors (try and catch), moved to the next. Until all objects were inserted. If ...
0
votes
1answer
29 views

Trigger not assigning lookup id when inserting multiple records

I have a trigger which seems to be working when I insert transactions one at a time but when trying to insert multiple records I recieve the error: FATAL_ERROR System.DmlException: Insert failed. ...
0
votes
2answers
437 views

Cloning Opportunity with Synced Quote and its Quote Line Items

I'm trying to clone an Opportunity and its Synced Quote along with the Quote Line Items associated with that Synced Quote, but I can't seem to insert the cloned Quote Line Items. It doesn't throw any ...
0
votes
2answers
49 views

Getting 66% code coverage for trigger in sandbox; 0% in production

I have created a trigger on campaign member. Trigger gets 66% code coverage in sandbox and 0% in production. I know there's a million threads on this but none have solved my dilemma. Here is my ...
0
votes
1answer
543 views

Workbench - Inserting Records with Self Lookup via Smart Lookup

I would like to insert a few hundred records into a custom object. The custom object has a self lookup. The custom object use is to replace a series of dependent picklists, 3 levels deep. For ...
0
votes
1answer
124 views

Insert using Bulk API throws error MISSING_ARGUMENT:fiedXXX__c not specified:--

An external system is using bulk api to insert records in Salesforce. Salesforce throws an error saying - MISSING_ARGUMENT:fiedXXX__c not specified:-- where XXX is external Id of Parent of the ...
0
votes
1answer
246 views

isAfter is not working properly in apex trigger

I have built following apex trigger code and isAfter code is not executing because I have used recursive method in this trigger. Is it possible to run isAfter while trigger call first time ? Please ...
1
vote
2answers
58 views

Prevent insertion of records based on a condition

I have a zoo__c object. On Zoo__c , I have a field called firstName__c. I want to prevent insertion/updating of records if firstName__c has any of these characters at the end - "op" , "gp" , "kp". If ...
0
votes
1answer
40 views

Test class no inserting object

I have a test class that seems not to be inserting some setup objects I need for the test. My test class is as follows: @isTest(seealldata=false) private class Alertas_The_Influence_isTest{ public ...
0
votes
1answer
32 views

Trigger -Not throwing correct error message

I Am using this trigger to avoid duplicate records,whenever i run to test the trigger for inserting a record.It is correctly throwing error only for last two if condition.If i validate for first if ...
4
votes
1answer
5k views

Inserting Records using a lightning component

I am looking to make a lightning component to insert my Transaction__c object records against all relevant Contracts pulled back requiring action. As it stands I am returning all of relevant contracts/...
2
votes
1answer
970 views

REQUIRED_FIELD_MISSING & FIELD_INTEGRITY_EXCEPTION on PricebookEntry Insert

I want to use standard price for the Pricebook entry. PricebookEntry pbe = new PricebookEntry(Pricebook2Id='01sN00000002OTsIAM', IsActive=true, Product2Id='01tN0000004JGeuIAG', ...
1
vote
0answers
293 views

Challenge when inserting records that has lookup field(that uses external Id of parent record)

In my scenario , I am loading records of object xyz__c in my system. This xyz__c has a lookup field that refers to abc__c object. I am loading records using an external system. It maps the fields on ...
1
vote
1answer
171 views

Why is the Salesforce security scan saying I don't check isCreateable()?

I am baffled by the Salesforce automated security scan. I just ran it and it says: This query looks for sObject Create operations that are performed without checking for isCreatable(). This may be a ...