Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

Questions tagged [insert]

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

Filter by
Sorted by
Tagged with
0 votes
2 answers
30 views

Not able to insert records in custom metadata

I have used this sfdx cmd to execute the mass record insertion in custom metadata. sfdx force:cmdt:record:insert --filepath CountryMapping.csv --typename CountryDialingCodeMapping__mdt I am getting ...
blackFire's user avatar
0 votes
2 answers
98 views

Data insertion failed with salesforce inspector

I don't understand why I get this error INVALID_CROSS_REFERENCE_KEY: Record Type ID: this ID value isn't valid for the user: 0121t0000001qxAAAQ [RecordTypeId] I want to insert field numbers in a '...
Alain's user avatar
  • 9
0 votes
1 answer
71 views

Duplicate Username error on upsert/insert action

Let me explain from the start. I gave users data to insert in UAT org (records contain an external ID). I asked them to insert data and there were 3000+ records. He mistakenly closed the window and ...
Priyansh Kumar's user avatar
-3 votes
1 answer
68 views

Please help me with the validation rule that it is not working during insert [closed]

NOT( AND( REGEX(Email, '^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,})+$'), REGEX(Owner_1_Email_Address__c, '^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,})+$'), REGEX(Owner_2_Email_Address__c, ...
Dagma Rinju's user avatar
-2 votes
2 answers
42 views

Before Update Case

Retrieve existing case, do not create a new case. trigger ValidateCase on Case (before insert) { if(Trigger.isBefore && Trigger.isInsert){ for(Case newCase : Trigger.new) { ...
Desaarollador x's user avatar
0 votes
0 answers
132 views

Trigger Creation for Duplicate Email on Contact

I am trying to create a trigger on contact to prevent duplicate records based on Contact Email. It will not be inserted but a Task instead will be created that there is incoming duplicate. I am new to ...
sFDev_newbie's user avatar
0 votes
1 answer
41 views

Salesforce apex how to save checkbox multiple values in database

I am trying to save the values from checkbox group in apex. I have converted the values from comma delemited to a list of strings. How can I save the values into the picklist type field. I have ...
Hasan Zubairi's user avatar
0 votes
2 answers
44 views

AfterInsert caused by: System.FinalException: Record is read-only

I want to update a record that has recently been created. Trigger: trigger TTCaseTrigger on Custom_Case__c (after insert) { if(Trigger.isInsert && Trigger.isAfter){ if(...
Speenzar XaXai's user avatar
0 votes
0 answers
86 views

Why insert is rolled back when validation triggered in bulk update

I have list of 2 records i try to update in bulk from object foo__c, this should trigger an insert of 2 records from the object zoo__c. One of the updated foo records hits a validation rule (as ...
Michael Imas's user avatar
0 votes
0 answers
172 views

Bulk API 2.0: Can I insert AND upsert in one csv request?

Edited to clarify: Background info on what I'm working on – we're going to be receiving email lists from clients, and we want to create new Leads or update existing Leads in Salesforce with the info ...
Brittany Layne Rapheal's user avatar
2 votes
1 answer
152 views

Insert records of user Selected Object without knowing object first

If I have a list of object strings containing field data for an object and I have a parameter selecting which object this should be inserted into, is it possible to write apex to insert those records? ...
Crash667's user avatar
  • 239
0 votes
2 answers
95 views

update fields in a records which is coming as a string

I am getting fields and its values in form of a string, for example: field1*Value1,Field2*Value2,Field3*Value3 I need to update above 3 fields in a record with their given values. Object ob=new object(...
Learner's user avatar
  • 21
0 votes
0 answers
164 views

CMDT CSV Insert Problems

Am trying to insert new records for a custom metadata file and saw that force:cmdt:record:insert has been deprecated. I tried sf cmdt generate records --csv path/to/my.csv --type-name MyCmdt but VS ...
Dmns's user avatar
  • 21
0 votes
1 answer
181 views

rollback partially in Service

When we are using Database.insert() or Database.update() with a false option(In any service) then it returns a success or failure result. We know in the insert if any lines fail, delete the header and ...
Akshay Jain's user avatar
0 votes
0 answers
416 views

Cannot insert ContentVersion Apex code

Hello I am having problems to create a ContentDocument with Apex code. I am trying to create those records from a partner user community that has some permission set. I get the next error when trying ...
TechGuy's user avatar
  • 97
1 vote
0 answers
354 views

INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] ContentVersion

Hello I am having problems to create a ContentDocument with Apex code. I am trying to create those records from a partner user community that has some permission set. I get the next error when trying ...
TechGuy's user avatar
  • 97
-1 votes
1 answer
785 views

How to pass and insert Records from lightning web component to apex class

With this code I tried to insert into my object but I get this error : System.NullPointerException: Attempt to de-reference a null object => My Apex Class @AuraEnabled(Cacheable=false) ...
dev50's user avatar
  • 15
1 vote
2 answers
380 views

APEX equivalent for SObject Tree -> insert nested objects

I often encounter usecases where i need to insert nested objects. While i know that it is feasible to leverage external Ids to achieve the insert in a single DML operation Account a = new Account(Name=...
Philippe's user avatar
  • 188
0 votes
0 answers
2k views

Bulk insert data in Custom Metadata Type using SFDX cli

I have created a Custom Metadata type in my developer Sandbox. I want to insert data from csv file using cli in vs code. It is giving me error. sfdx force:cmdt:record:insert --filepath .\Aperia.csv --...
Ishaan Jain's user avatar
-1 votes
1 answer
304 views

Add List of Inserted Id's to generic sObject List

I need to replicate the standard "Create Records" Flow Element in an Invocable Apex Class so that I can include some additional code before and after the insert. I am using generic sObject ...
Jeff Callahan's user avatar
0 votes
1 answer
205 views

Before Insert Trigger field not writeable

I created this trigger to verify if the Account__r.Number_of_obj__c is null so the user in this case can't insert , but the problem that I get is that the is field not writeable . The error is : ...
ddev96160's user avatar
0 votes
1 answer
958 views

insert & Database.insertImmediate not immediate?

Baffled by a new record I've added that isn't available to query. Person__c b = New Person__c(Name='Bob'); insert b; //Returns a ...
Kenneth Hippolite's user avatar
-1 votes
1 answer
463 views

Unable to get triggering records in Before Insert(Fast Field Updates) and loop over them [closed]

I was trying by using "Get Records" elements to get all the records of the object triggering the flow. But as the record is not being inserted yet, I can't filter it via Id. Is there any ...
Muskan Agarwal's user avatar
-2 votes
1 answer
452 views

How to insert list of records using LWC? Error : Too many DML Statement 1

Apex : @AuraEnabled(cacheable=true) public static void createFilters(List<Criteria__c> criteres ) { List<Criteria__c> crit = new List<Criteria__c>(); for(Criteria__c cr : ...
user avatar
1 vote
0 answers
165 views

Issue while capturing the approval comments of an approval process using a trigger

I have two approval processes in my org for an object Grant Contract Modification first one being Grant Contract Mod Approval process and the second one being FinanceApprovalProcessGrantContractMod. ...
JK123's user avatar
  • 69
0 votes
0 answers
796 views

System.DmlException: Update failed. First exception on row 0 with id; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST

This error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: pba.ListingTriggerDispatcher: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id ...
user121228's user avatar
0 votes
1 answer
144 views

How to send the ID to new page after insert?

There are 2 pages. I inserted one record into an object with the save button on page 1 and transitioning to page 2, Now I want to get the ID on page 2, what should I do? ID was auto-numbered by object....
Kyo ri's user avatar
  • 9
1 vote
0 answers
289 views

Is't Possible to update the ContentDocumentId field value of ContentVersion in Before Insert trigger? [closed]

I would like to update the ContentDocumentId of ContentVersion record in the before insert trigger. Is this possible? If it's not possible can anyone please explain the reason for it? Update: When a ...
Ajith Kumar's user avatar
0 votes
1 answer
724 views

Apex - Insert json value into custom field

I am inserting records into custom object Rating__c via trigger. This object has a field that stores json value against each record based on Account ID(Related Account). Example: {"attributes&...
Ram's user avatar
  • 1
0 votes
1 answer
351 views

What are the parameters for saving a phone number field in Apex?

When I insert the Order record, the Order saves but the custom phone number field does not. What are the parameters for saving a phone number field in Apex? Order o = new Order(AccountId = a.Id, ...
David Swarbrick's user avatar
0 votes
1 answer
3k views

Write a trigger on Contact and fill its Mailing Address with its Account's Shipping Address

I am trying to write an trigger for when a contact get inserted or updated its mailing address so i want to copy this mailing address to its associated account's shipping address. I am getting this ...
Govind's user avatar
  • 11
1 vote
1 answer
112 views

Internal Error happens when try to insert 5000 or 10000 in one transaction 1294474088-313147 (-1775489667)

To reproduce specific problem which occurs only when there are 50000 users on the org, we need to insert 50000 users into sandbox. When we try to do that, we receive Internal Salesforce Error issue. ...
Patlatus's user avatar
  • 17k
0 votes
0 answers
691 views

ERROR: execution of BeforeInsert caused by: System.NullPointerException

trigger exerciseSIX on Account (before insert){ List<Account> allAcc=[SELECT BillingPostalCode FROM Account]; System.debug(allAcc.size()); List&...
Nareg Artinian's user avatar
0 votes
1 answer
304 views

How to prevent the License Management App (LMA) from creating Lead records when a package is installed via an installation URL?

Is it possible to prevent Lead records from being created by the License Management App (LMA) when a package is installed via an installation URL? If package installation occurs via an installation ...
Renzo J.'s user avatar
0 votes
1 answer
608 views

Queueable insert list records from map and keep order

I have Map with Account and Account Id. I want to insert that accounts in Queueable and return list of all ids in order as acount is inserted(Or map, it doesnt really matther). How can i keep order if ...
Taganrog's user avatar
0 votes
1 answer
1k views

Insert record from static resource csv

I have csv file with account records and want to insert that records via apex. How can i do it and dynamically find necessary fields? I can only manually assign them and its hard to parse cause of ...
Tirkocuyda's user avatar
0 votes
0 answers
658 views

Looping without a collection variable in flow

I am working on a requirement to create child records based on the field value present in the parent record using flow. If Obj__c is the parent object and Ch__c is its child object and if count__c is ...
Suhasini's user avatar
  • 307
0 votes
1 answer
213 views

Insert record based on another record

For example a have account sobject and want to use record to create another record with mainly that record data. So same name and another fields, but some fields with another data. Is it possible to ...
meximah's user avatar
0 votes
0 answers
289 views

AMPScript custom attribute row insert DE

I'm trying to insert data from one data extension, which contains an XML, into a new data extension. This XML contains order information and my script writes this into the target data extension based ...
Demi's user avatar
  • 1
1 vote
1 answer
651 views

Attachment to File Trigger on Attachment. File not having any content after the attachment insert

Here is my attachment loop to convert into Salesforce Files. The document as Files is created along with the title and content type however it has no content or sometimes '1' or 'MQ==' which is not ...
Kevin S's user avatar
  • 13
1 vote
0 answers
103 views

Insert into External Object

We have set up a postgres on Heroku. Using Heroku Connect we have exposed couple of tables as external object following this [link][1] . We are able to read the data in Salesforce. But when we are ...
raj's user avatar
  • 183
0 votes
2 answers
80 views

How to control the number of records per run [closed]

I would like to know the best way for me to insert X amounts of records at a time. For example: Suppose I want to enter a list of 50000 records. In order not to run into problems, I thought of ...
Diego Edargo Pessoa's user avatar
0 votes
0 answers
91 views

Unable to add record into multiple publication lists using SSJS script Activity in marketing cloud

Am trying to insert records into many publication lists from a DE(say XXX - this DE has emailaddress, subscriberkey, listid, list name, status) using SSJS. But no output is coming. Please review my ...
DSK's user avatar
  • 1
0 votes
0 answers
202 views

Apex trigger executing only on last record of the batch during mass update

I'm trying to create a very simple trigger that gets fired when a process builder creates a task with certain conditions like task status = 'In Progress'. What this trigger will do is basically it'll ...
J.doe's user avatar
  • 1
1 vote
0 answers
715 views

REST update fail, REST insert work

I have this strange issue. I have opened up REST requests using a read only user in a sandbox, all work fine. The request can post an insert in cases and send an update to changes status etc. I then ...
Daniel Wretman's user avatar
0 votes
1 answer
1k views

Before insert callout to apex class, apex class not updating fields in trigger

I thought I had already posted this, but I guess not (if so, please feel free to direct me to my original post and delete/merge this one). I have a before insert trigger on leads, it calls an apex ...
david5712's user avatar
2 votes
1 answer
870 views

How does Salesforce ensure new record IDs for the same object are unique during simultaneous inserts?

Just curious. I know record Ids are not guaranteed to be sequential from the docs. I've also already read this post on what are IDs are composed of. But lets say 2 or more transactions started at the ...
Ken K's user avatar
  • 33
0 votes
1 answer
2k views

Ids and List<Account> after insert

In an Apex class method, I want to add several Accounts to a List. After a successful execution of the insert, can I access Ids? Example: List<Account> accounts = new List<Account>(); ...
nstuyvesant's user avatar
0 votes
1 answer
2k views

How to create a Lead with a custom record type?

I'm trying to test a workflow rule made, and I'm trying to insert some Leads, with determined Recordtypes to cover all test scenarios. In Dev Console/IDE, how to create a Lead with a custom Record ...
RedMan's user avatar
  • 107
0 votes
0 answers
185 views

Inserting bulk records from CSV on an object and capturing error rows

I am working on parsing CSV file to insert bulk records on an object (OBJECT 1)and populate two lookup fields(OBJECT 2 & OBJECT 3) on it. If the lookup records are already present in the database ...
Badduboy's user avatar
  • 111