Questions tagged [insert]
Using insert DML, you can insert new records and commit them to the database.
192
questions
0
votes
0
answers
50
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 ...
2
votes
1
answer
66
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? ...
0
votes
2
answers
56
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(...
0
votes
0
answers
76
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 ...
0
votes
1
answer
94
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 ...
0
votes
0
answers
22
views
Managed Package - Allow only application code, and few authorized users, to insert records of a custom object
We have a custom object in our core managed package (visibility is public). There are a bunch of other managed packages that work alongside the core managed package and have code to insert records of ...
0
votes
0
answers
255
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 ...
1
vote
0
answers
281
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 ...
-1
votes
1
answer
569
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)
...
1
vote
2
answers
189
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=...
0
votes
0
answers
1k
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 --...
-1
votes
1
answer
167
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 ...
0
votes
1
answer
161
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 : ...
0
votes
1
answer
590
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 ...
-1
votes
1
answer
293
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 ...
-2
votes
1
answer
299
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 : ...
1
vote
0
answers
137
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.
...
0
votes
0
answers
748
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 ...
0
votes
1
answer
124
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....
1
vote
0
answers
169
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 ...
0
votes
1
answer
565
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&...
0
votes
1
answer
257
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, ...
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 ...
1
vote
1
answer
66
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. ...
0
votes
0
answers
476
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&...
0
votes
1
answer
241
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 ...
0
votes
1
answer
423
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 ...
0
votes
1
answer
682
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 ...
0
votes
0
answers
471
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 ...
0
votes
1
answer
134
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 ...
0
votes
0
answers
267
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 ...
1
vote
1
answer
544
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 ...
1
vote
0
answers
88
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 ...
0
votes
2
answers
60
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 ...
0
votes
0
answers
83
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 ...
0
votes
0
answers
157
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 ...
1
vote
0
answers
450
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 ...
0
votes
1
answer
861
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 ...
2
votes
1
answer
698
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 ...
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>();
...
0
votes
1
answer
1k
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
0
answers
154
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
1
answer
186
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 ...
1
vote
0
answers
217
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
1
answer
47
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
1
answer
391
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, ...
0
votes
0
answers
514
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
1
answer
77
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
1
answer
562
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
1
answer
267
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 = ...