Using static DML you generally manually type all the fields required for the object in the soql query . It requires lot of manual work. It doesn't work based on user privelege like say if employee user shouldn't see money field of user while manager should see ,you will have different profile for each user Now at code level you may have to write two queries List<Account> soqlQueryResult if(user==manager) { soqlQueryResult=[select id,money from account]; } else { soqlQueryResult=[select id,name from account]; } if you fetch with money on the normal user who dont have privelege to read you will get errors on the soql query Here come's the dynamic dml, You can dynamically choose the fields based on the preveliges on the soql https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_dml.htm Do read those documents Do let me know if you need further help.
This link explains the dynamic loading of fields using dynamic dml http://www.sfdcpoint.com/salesforce/dynamic-soql-query-fetch-fields-object-salesforce/ Similar way you can load fields based on user profile previleges Thanks and Regards, Shiva RV
May I request you to please refer the below link for reference.
- http://sfdcsrini.blogspot.com/2014/08/what-is-difference-between-database-dml.html
I hope it will be helpful.Best Regards
Rahul Kumar
Using static DML you generally manually type all the fields required for the object in the soql query .
It requires lot of manual work.
It doesn't work based on user privelege like say if employee user shouldn't see money field of user while manager should see ,you will have different profile for each user
Now at code level
you may have to write two queries
List<Account> soqlQueryResult
if(user==manager)
{
soqlQueryResult=[select id,money from account];
}
else
{
soqlQueryResult=[select id,name from account];
}
if you fetch with money on the normal user who dont have privelege to read you will get errors on the soql query
Here come's the dynamic dml,
You can dynamically choose the fields based on the preveliges on the soql
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_dml.htm
Do read those documents
Do let me know if you need further help.
Thanks and Regards,
Shiva RV
http://www.sfdcpoint.com/salesforce/dynamic-soql-query-fetch-fields-object-salesforce/
Similar way you can load fields based on user profile previleges
Thanks and Regards,
Shiva RV