Skip to main content

Questions tagged [dynamic-dml]

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

Assign dynamically values in fields via field API name

I am trying to populate a field with the value of another field dynamically based on custom metadata types. I use the method variable.put(fieldAPIName, value) in order to populate the fields. Here is ...
Xrhstos Kolonis's user avatar
2 votes
1 answer
462 views

Dynamically Insert parent child records in a single DML

I'm trying to insert contact and account records in a single DML. In my case I don't want to use the . operator Instead, I'm using the put operator to insert records. Account acc=new Account(Name='...
Krishnan Mishra's user avatar
2 votes
2 answers
2k views

DML Operation on List<SObjects> - Where I got the record ID of various objects

Scenario: I got a VF Page where I will get only ID's of various Objects, I wouldn't know which Object RecordID I would be getting in an instance. I need to update that record with that ID. Without ...
C. Praveenkumar's user avatar
8 votes
3 answers
8k views

Insert List of Parent and Child Records in One DML Statement

I saw an example how to insert Parent and Child Record in one DML Statement from Developer Guide and It's Working Fine no issue in that. Here In my case I would like insert List Of Both Parent and ...
Sharat's user avatar
  • 1,059
32 votes
2 answers
69k views

Apex Cast sObject list dynamically to a specific sObject Type

The upsert() DML operation requires a specific List based on a specific sObject type, for instance:List<Account> lstAccount = new List<Account>(); However, we are trying to generate a ...
Robin Wijnen's user avatar
1 vote
2 answers
3k views

Populating lookup fields using an external ID with Object type as String

My question is pretty much the same as here. But the difference is I'll have to do it generically. As in the object type is sent as text and I'll have to typecast in the code. Eg., //create an in-...
Vignesh Damodharan's user avatar
2 votes
3 answers
3k views

How to use Dynamic DML operation?

I’m having a requirement, where I guess I’ve to use Dynamic DML.But I’m new to Dynamic Apex as well as Dynamic DML. When I will create a Folder in Box.com server by using API call, I will get a ...
Noob_NoVoice's user avatar
  • 2,739
7 votes
3 answers
6k views

Get field value dynamically

Let's say I have an sObject queried and want to dynamically get a specific field value. I need it to be dynamic so that it can be a different field through an input. sObject obj = [SELECT Id, Name, ...
Nathan Williams's user avatar
1 vote
1 answer
202 views

'FeedItem' schema type undefined in Trigger

I am trying to dynamically create an sObject in APEX based on the following code. Schema.SObjectType targetType = Schema.getGlobalDescribe().get('FeedItem'); system.debug(targetType); sObject ...
jordan.baucke's user avatar
5 votes
1 answer
961 views

Error when I populate lookup with external id using .put method

You can populate lookup fields using an object with an external id field populated like so: Custom_Object__c o = new Custom_Object__c(Account__r=new Account(External_ID__c='123')); insert o; ...
James Sullivan's user avatar
10 votes
1 answer
3k views

Field Sets & Dynamic DML & Describing Fields Included in Field Set

I am attempting to write generic code which will use a fieldset, allowing for dynamic creation of a query. This bit is documented well enough in dynamic DML examples from SFDC. In addition to the ...
Mark Pond's user avatar
  • 23.1k