Questions tagged [insert]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
849 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 ...
3
votes
4answers
1k 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 ...
1
vote
1answer
624 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....
0
votes
1answer
534 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....
11
votes
3answers
18k views

How to insert reports/dashboards inside a lightning component?

I'm facing issues in inserting reports inside the lightning component. As in VF pages we have analytics report tag or iframe..but in lightning i'm not able to find a solution. If any body has done it.....
0
votes
3answers
619 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
105 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
582 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 ...
0
votes
1answer
335 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
237 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 ...
4
votes
2answers
816 views

Adding new values to Custom Picklist (PHP Toolkit)

I'm using the PHP Toolkit for integrating a web application with my Salesforce account. I have this custom object: Individual__Choice__c that contains this custom Picklist: Primary_Option__c This ...
-2
votes
1answer
209 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
49 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
126 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 ...
6
votes
0answers
180 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
1answer
627 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
1k 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
179 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
77 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
346 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
4k 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 ...
0
votes
1answer
2k 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
80 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
437 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 ...
-4
votes
1answer
2k 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
798 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
60 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
49 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
829 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
54 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 ...
4
votes
1answer
10k 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/...
0
votes
1answer
464 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
175 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
55 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
33 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 ...
1
vote
1answer
418 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 ...
1
vote
0answers
594 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 ...
0
votes
1answer
755 views

Insert Attachment Saving 5 files in Notes and Attachment

I got into a problem when I save the pdf to lead attachment. Here is the scenario I have a Button on detail page of a Custom Object which is Child of Lead. This button opens a VF page and renders as ...
2
votes
1answer
154 views

Uncommitted work in tests / Preparing for callouts

I have the following scenario in some unit tests: I need to create some data with inserts I need to invoke a method which performs a callout The test fails with the System.CalloutException: You have ...
0
votes
0answers
1k views

Salesforce Insert - Avoiding DUPLICATE_DEVELOPER_NAME errors

I am trying to insert Salesforce object records using APIs. Some objects throw errors with DUPLICATE_DEVELOPER_NAME errors. Some objects have Developer Name fields: 2017-05-01 16:33:35,379 ERROR - ...
3
votes
2answers
2k views

DML not allowed on User

I created some test users using the following apex code which worked perfectly fine: list<User> abc = new list<user>(); for(integer i=1; i<3;i++) { abc.add( new User( ...
0
votes
1answer
69 views

Master and child DML insert not working

I try to insert master and child simultaneously, however, it is not working: public PageReference Submit() { try { insert objectSelected; Id objectSelectedId = objectSelected....
0
votes
0answers
48 views

inserting a new object after updating an account

I am trying to insert a new custom object called Aid if 2 CheckBoxes in an account are checked. here is my trigger: trigger Aid on Account (before update) { for(Account acc: Trigger.new) { if(...
3
votes
0answers
659 views

Why doesn't Dataloader use specified 10k batch size when Bulk API is selected?

I have this sample CSV file containing 10,000 records (with 33 columns) I'd like to import it via Dataloader into Case object at my sandbox environment. I tried using these settings below with Bulk-...
0
votes
1answer
1k views

VF page for inserting and viewing object values

I need to make VF page for inserting new Contacts that shows pageBlockTable of all existing Contacts below. After i add recordSetVar="contacts" save button stops working. <apex:page ...
0
votes
1answer
1k views

Avoid Duplicate Id in a List

i have developed one visualforce page and it has multiple Group with Product and Bundle so, once user insert multiple Group with the Same product and same bundle then it's giving me an error as ...
0
votes
0answers
345 views

Error sending an email with function InsertDE (Ampscript)

This is my first contribution to this community. I'm having problems with sending an email when i'm using the function InsertDE whereas using other functions such as UpsertDE works fine, and the ...
8
votes
1answer
14k views

Inserting test record with record type

I'm trying to create a unit test where a I insert a record with a specific record type Student_Records__c endterm = new Student_Records__c(); endterm.School__c = schl.id; endterm....
1
vote
1answer
2k views

Stop Apex logic from running before update if it was already run before insert in the same transaction

Background: We have a custom object called Training History that stores customer training "minutes". Customers purchase minutes from us in blocks of 60, and we book Events for them in Salesforce for ...
4
votes
1answer
4k views

INVALID_FIELD, Foreign key external ID not found - Inserting Related Records via External Id

I am trying to insert related records via an External Id. i am using an approach described here where we create an empty parent object with the same external Id like the "real" parent. It is a self-...