Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- Re: Dynamic Insert Query
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Dynamic Insert Query
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-02-2013 12:54 PM
Let me first describe the requirement -
I have a managed package that contains an Object called Student. I have to create a many-to-many relationship with another object. I have a junction object for this.
Just imagine, that this package can get installed into different orgs, and the many-to-many relationship can happen with some object called Class or Teacher or Exam (depending on the requirement of the org.)
I am creating the second master-detail relationship of the junction object when I have installed the package in the org, and I am storing the API name of the second master-detail relationship in a Custom Settings. (Custom settings also belong to my package)
The Student-Teacher or Student-Exam, assignment is happening from a VF page(also belonging to the package). So I need to dynamically select the field API name of the second master-detail, assign value to it and save it.
Is there any way to create a Dynamic Insert DML?
Solved! Go to Solution.
Re: Dynamic Insert Query
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-02-2013 01:28 PM
What do you mean by "dynamically select the field API name of the second master-detail"? Don't you have this stored in your custom setting?
Maybe you are looking for the describe methods.
Salesforce.com Certified Advanced Administrator
http://www.forcedisturbances.com/
Re: Dynamic Insert Query
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-03-2013 02:07 AM
Yes. I have it stored in Custom Settings. But the value in the custom settings will change from org to org. So the value that I will be querying from the Custom Settings needs to supplied to the DML insert. So the DML will have the second-master-details API name being taken from the Custom Settings dynamically.
Indeed I am looking for some Schema method, that might provide us this flexibility for DML Insert, but I am not able to figure out the correct approach.
Any help is much appreciated.
Re: Dynamic Insert Query
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-03-2013 06:11 AM
If you are looking for an example that details some of the schema / describe methods, please see my blog post here. The post contains a link to the git hub repository that contains the code.
The post is on how to create a visual force component that will take an object coming in and using the describe methods will display all of the fields on that object for the purposes of building a SOQL where clause.
Hopefully that will give you a good intro to how the methods can be used.
Salesforce.com Certified Advanced Administrator
http://www.forcedisturbances.com/
Re: Dynamic Insert Query
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-03-2013 06:14 AM
Also, you might find the "Setting and Retrieving Field Values" section of this page interesting.
Salesforce.com Certified Advanced Administrator
http://www.forcedisturbances.com/

