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
1 answer
61 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&...
user avatar
  • 1
0 votes
1 answer
35 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, ...
user avatar
0 votes
1 answer
323 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 ...
user avatar
  • 11
1 vote
1 answer
27 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. ...
user avatar
  • 13.3k
0 votes
0 answers
84 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&...
user avatar
0 votes
1 answer
55 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 ...
user avatar
0 votes
1 answer
112 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 ...
user avatar
0 votes
1 answer
33 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 ...
user avatar
0 votes
0 answers
96 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 ...
user avatar
  • 169
0 votes
1 answer
55 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 ...
user avatar
0 votes
0 answers
140 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 ...
user avatar
  • 1
1 vote
1 answer
145 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 ...
user avatar
  • 13
1 vote
0 answers
41 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 ...
user avatar
  • 83
0 votes
2 answers
33 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 ...
user avatar
0 votes
0 answers
38 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 ...
user avatar
  • 1
0 votes
0 answers
57 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 ...
user avatar
  • 1
1 vote
0 answers
88 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 ...
user avatar
0 votes
1 answer
449 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 ...
user avatar
0 votes
1 answer
214 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 ...
user avatar
  • 13
0 votes
1 answer
497 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>(); ...
user avatar
0 votes
1 answer
346 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 ...
user avatar
  • 107
0 votes
0 answers
50 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 ...
user avatar
2 votes
1 answer
97 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 ...
user avatar
1 vote
0 answers
120 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/...
user avatar
1 vote
1 answer
32 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....
user avatar
0 votes
1 answer
256 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, ...
user avatar
0 votes
0 answers
256 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 ...
user avatar
0 votes
1 answer
45 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 ...
user avatar
0 votes
1 answer
213 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 ...
user avatar
  • 35
0 votes
1 answer
95 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 = ...
user avatar
1 vote
2 answers
180 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 ...
user avatar
0 votes
0 answers
81 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 ...
user avatar
2 votes
1 answer
145 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 ...
user avatar
0 votes
1 answer
706 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 ...
user avatar
  • 121
2 votes
1 answer
58 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 ...
user avatar
  • 3,615
1 vote
1 answer
66 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. ...
user avatar
  • 3,615
2 votes
2 answers
188 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 = ...
user avatar
  • 2,090
1 vote
1 answer
1k 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 ...
user avatar
  • 165
3 votes
1 answer
368 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 ...
user avatar
  • 1,838
1 vote
1 answer
30 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(...
user avatar
1 vote
1 answer
2k 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:...
user avatar
  • 8,342
0 votes
0 answers
165 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 ...
user avatar
0 votes
1 answer
804 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, ...
user avatar
0 votes
0 answers
795 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 ...
user avatar
1 vote
2 answers
313 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 ...
user avatar
-4 votes
1 answer
139 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 ...
user avatar
0 votes
1 answer
186 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 ...
user avatar
  • 215
0 votes
2 answers
105 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 ...
user avatar
-2 votes
1 answer
939 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;
user avatar
1 vote
1 answer
1k 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 ...
user avatar
  • 1,838