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
1answer
17 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>(); ...
0
votes
1answer
19 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 ...
0
votes
0answers
32 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 ...
2
votes
1answer
643 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
2answers
1k views

update and insert not working

Upsert not working..update and insert not working..need help I have tried using the example given in salesforce visual force developer guide for upsert. It just inserts a new row. I tried in a ...
0
votes
2answers
840 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
58 views

One-to-many insert/upsert from landing to separate DE's

I'm bulding a preference center and having trouble with writing into two separate DE's. We have two DE's: Newsletter_Subscribers (EmailAddress, FirstName, LastName, OptIn, Country, IPAddress, ...
2
votes
1answer
46 views

Unexpected behaivor: Database.insert(userList, false) is rolling back User insertion

I am attempting to insert two users with the database.insert method. One user that should work, and another that is missing required fields. // Create two users, one of which is missing a required ...
0
votes
1answer
1k views

Confused about OrderProducts, OrderItems, and Products when making orders in test class

I'm making a test class that creates 5 orders and upon insert, I get the error that you need to add products to orders. I've got... List<Product2> clothProds = [SELECT Id FROM Product2 WHERE ...
1
vote
1answer
727 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
1k 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 ...
1
vote
0answers
30 views

Insert Work Orders with randomized Latitude and Longitude Values for testing bulk scheduling in Field Service Lightning (FSL)

This code is supposed to insert 50 work orders with randomized geolocations. It's meant to create enough records of sample data to set the stage for demonstrating the power of bulk-scheduling/...
1
vote
1answer
25 views

I'm trying to insert new record but it gives error as Line: 7, Column: 1 System.StringException: Invalid id: objcus.id

Apex_Customer__c objcus=new Apex_Customer__c(); objcus.Name='Test ABC'; insert objcus;//it will creat new customer records Apex_Invoice__c objnewinvoice=new Apex_Invoice__c(); objnewinvoice....
0
votes
0answers
39 views

Inserted row in a Data Extension with a null Primary Key

We have a Data Extension with a Primary Key and we are able to insert via REST API a row setting its Primary Key as null. Until we know, it isn't possible because as Primary Key that field is no ...
0
votes
1answer
22 views

SForce Partner Client Create Object with RecordType

I have a PHP web application using the SForce Partner Client to connect with Salesforce. I am creating a new Record Type for a custom object. How can I insert a record with that new Record Type in ...
0
votes
1answer
33 views

Trigger isUpdate being fired during insert

I have a trigger on an Account object that fires on update. In my unit test for the trigger, I create a test Account and insert it, which somehow causes the update trigger to fire. This causes an ...
0
votes
1answer
20 views

How to add value to a Picklist field in a custom object?

I want to insert a custom object and one of the field in the custom object is a Picklist (Multi-Select). I used the following code: PResources__c pResource = new PResources__c(); pResource.Name = ...
-2
votes
2answers
442 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 ...
1
vote
2answers
170 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 ...
2
votes
1answer
41 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
0answers
42 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 ...
0
votes
1answer
102 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
27 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
36 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
56 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
252 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
100 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
25 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(...
2
votes
1answer
2k 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
1answer
607 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
67 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
354 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
414 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 ...
4
votes
2answers
4k views

Create static resource with apex code

Is there a way to create a StaticResource within a Apex code. this the code i am doing: StaticResource sr = new StaticResource(); sr.Body = file; sr.Name = 'testLicence'; ...
1
vote
2answers
120 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
81 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
62 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
49 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
137 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
329 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
71 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
41 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
147 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
58 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. ...
1
vote
1answer
567 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 ...
2
votes
2answers
817 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
558 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
3answers
1k 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
1answer
469 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....