Questions tagged [insert]

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

Filter by
Sorted by
Tagged with
10
votes
3answers
12k 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.....
7
votes
1answer
1k views

Inserting Accounts and Contacts Simultaneously

Trying to insert a new Account and it's Contact (maybe multiple Contacts?) at the same time. While researching this, I've come across various posts that are close to the solution, such as: ...
6
votes
0answers
138 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 ...
5
votes
1answer
9k 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....
4
votes
1answer
6k 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/...
4
votes
1answer
2k 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-...
3
votes
4answers
555 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 ...
3
votes
2answers
642 views

Remote Objects: Insert an array of objects

Is it possible to insert an array of objects using Remote Object Model? Here's my code: <apex:remoteObjects jsNamespace="romodel"> <apex:remoteObjectModel name="Stock__c" jsShorthand="...
3
votes
2answers
3k 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'; ...
3
votes
2answers
1k 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( ...
3
votes
2answers
706 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 ...
3
votes
0answers
66 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 ...
2
votes
1answer
4k views

Apex Trigger giving “cannot specify Id in an insert call: [Id]” error

I'm pretty new to Apex and writing a simple trigger for when an account submits a form on our website (tracked on the formSubmit__c object) to create an Opportunity and am getting the following error ...
2
votes
3answers
359 views

Trying to get Code Coverage on my apex Class

I'm trying to get code coverage on my class to no avail. Any assistance would be greatly appreciated. I'm sure there is a better way to write my class but just trying to get the end user his request ...
2
votes
2answers
498 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 ...
2
votes
1answer
149 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 ...
2
votes
2answers
2k views

Insert data to custom object with relationship using external Id

Good day everyone, I have installed an npsp package and then I created a visual force that will save a new affiliation . I've tried to used an external Id to save the data. I've already tried saving ...
2
votes
1answer
581 views

Trigger to insert new record not firing

I'm trying to create an Apex trigger that automatically creates a new record when some requirements are met. We have a custom object, Vendor Issues, which we would like to have new records created ...
2
votes
2answers
403 views

Error: Before Insert or Upsert list must not have two identically equal elements

Im getting above error when I try to add some custom records to a list and insert it later. Here's what Im doing. From the following code, I call a method from a different class (SetupBase) and add ...
2
votes
2answers
340 views

Why is this Trigger not working

I've a question with this trigger. I checked the register and it launch the trigger but is not doing anything. It doesnt show me the debug messages, even the first one. The idea is that when we are ...
2
votes
2answers
340 views

Error when I try to clone an object

I'm trying to clone an object, here is the code: @RemoteAction global static void cloneRow(String idProj){ System.debug('@@ clone: '+idProj); ConfigeroPSA__Expense__c oldExp = [SELECT Id,Name,...
2
votes
1answer
605 views

Upserting objects in Apex: can I assert which have been inserted / updated?

I'm upserting a list of custom objects in an Apex controller that are retrieved on demand from an external source. My object has an external identifier field used to help the database call determine ...
2
votes
1answer
1k 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', ...
2
votes
2answers
1k views

How do I scalably run Apex after a small delay so that all related objects exist?

I'm trying to run Apex code that runs a little while after custom objects are created. The problem is that I have a few systems inserting and updating data when a customer places an order in an ...
2
votes
1answer
921 views

Storing json as a String field is giving wrong value

I have been developing an Apex Trigger where I build a json string from an incomming Event. What I do is serialize the event into the json at first, then deserialize it as a Map and add to it some ...
2
votes
0answers
406 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 ...
2
votes
0answers
467 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-...
2
votes
1answer
43 views

Record won't insert - Apex Trigger

I have created an apex trigger so that it will create a record for everyday of an opportunities contract, I have run the code without the insert statement and my debug shows it works fine. What am I ...
2
votes
2answers
661 views

Insert or update records dynamically through SOAP API's Partner jar

I am working on inserting CSV records to Salesforce. I usually do using Bulk API where the types are auto detected and mapped. However, I got into a scenario where I have to upload Documents or ...
2
votes
1answer
39 views

Problem with trigger execution on Opportunity batch insert

I've been dealing with this for a while now, and still haven't found a solution on the problem I am currently facing. So.. here is the situation. I have programmed a Trigger for the Opportunity ...
1
vote
2answers
101 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
148 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....
1
vote
2answers
211 views

APEX fields on inserted sObject

I have custom fields on my Account object. Some of them have default value, let say "Days__c" as number with default value 0. When I insert the object like this: Account account = new Account(Name = ...
1
vote
1answer
46 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 ...
1
vote
1answer
2k 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 ...
1
vote
2answers
84 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 ...
1
vote
2answers
782 views

How to get field values from VF page

I'm stuck with a really easy task. My VF page have StandardController and Extension. I'm using the standard fields for Task object : <apex:InputField value="{!Task.Client_Name__c}"/> So I ...
1
vote
1answer
73 views

How does a trigger behave

Assume I have written a after insert trigger on an object A. I do some manipulation inside my trigger and at the end I create 3 to 4 new objects , that is a related list in Object A(Master-detail ...
1
vote
2answers
2k views

Updating WhatId on Activity when Opportunity is Created

Here's something that I'm trying to do which I feel as though I've made it 75% of the way through. Right now let's assume I have the ability to generate an opportunity when a certain action is ...
1
vote
2answers
34 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 ...
1
vote
1answer
45 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 ...
1
vote
1answer
690 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
vote
1answer
239 views

Apex method not creating record

My apex class is as follows: global class CreateDailyRSLI implements Schedulable{ List<Wildlife__c> LiveRhinosList = [SELECT id, Number_of_Sightings_Today__c FROM Wildlife__c]; ...
1
vote
1answer
37 views

Updating opportunity with APEX code

I want to add products to a specific opportunity via APEX code. Not sure how I would be able to do that. I know how to create an opportunity and insert it into the environment but wanted to make it ...
1
vote
1answer
122 views

Bulk Data Insertion that includes relationships

Good day everyone, I just want to ask your idea in regards with my problem. I am trying to read a data from csv and upload the data to salesforce. Below is an image of sample data in my csv. This is ...
1
vote
1answer
185 views

Trigger that inserts record from newly inserted record

I've Updated my code, and I'm still not getting the additional records inserted. My goal is; once an opportunity is closed a project is created. Once the project is created Credit Details (...
1
vote
1answer
664 views

How to upsert multiple records with Apex controller

This code is able to upsert a single record in salesforce. I want it to save multiple records by breaking the long string of dates contained in the datesFromCalendar. datesFromCalendar contains data ...
1
vote
1answer
134 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 ...
1
vote
2answers
452 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 ...
1
vote
1answer
884 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 ...