Deprecated: Optional parameter $list declared before required parameter $is_script is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php on line 21
Deprecated: Optional parameter $register declared before required parameter $footer_or_media is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php on line 45
Deprecated: Optional parameter $register declared before required parameter $footer_or_media is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php on line 104
Deprecated: Optional parameter $expire declared before required parameter $path is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_functions.php on line 54
Deprecated: Optional parameter $depth declared before required parameter $output is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/themes/entaro/inc/classes/megamenu.php on line 155
Deprecated: Optional parameter $depth declared before required parameter $output is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/themes/entaro/inc/classes/mobilemenu.php on line 147
Deprecated: Optional parameter $args declared before required parameter $wp_customize is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/extensions/customizer/extension_customizer.php on line 583
Deprecated: Optional parameter $args declared before required parameter $wp_customize is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/extensions/customizer/extension_customizer.php on line 606
Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":844,"date":"2017-07-27T05:24:30","date_gmt":"2017-07-27T05:24:30","guid":{"rendered":"http:\/\/www.salesforcenextgen.com\/?p=844"},"modified":"2020-12-28T19:45:40","modified_gmt":"2020-12-28T19:45:40","slug":"workingwithdatainapex","status":"publish","type":"post","link":"https:\/\/salesforcenextgen.com\/workingwithdatainapex\/","title":{"rendered":"Working with Data in Apex"},"content":{"rendered":"Working with Data in Apex<\/strong><\/p>\nAs discussed now it\u2019s the time for some real action, in this series you will learn how to interact with data in your Salesforce org.\u00a0 Before we begin to make sure have created a Salesforce developer org, it is available for free and it is the environment where we will try to implement the Apex we learn here.<\/p>\n
\n- Working with sObjects<\/li>\n
- Data Manipulation Language<\/li>\n
- SOQL and SOSL Queries<\/li>\n
- SOQL For Loops<\/li>\n
- sObject Collections<\/li>\n
- Dynamic Apex<\/li>\n
- Apex Security and Sharing<\/li>\n
- Custom Settings<\/li>\n<\/ul>\n
Working with sObjects<\/strong><\/p>\nsObject is the representation of a row of data in the database and can be a standard (created by Salesforce) or custom (created by user). They are similar to SOAP API, therefore generic sObject abstract type can be used to represent any object. DML works on both generic sObjects and regular sObjects.<\/p>\n
Ex:<\/p>\n
Account acc = new Account();<\/p>\n
Object__c custObj = new Object__c ();<\/p>\n
Casting of sObjects :<\/p>\n
sObject s =\u00a0new\u00a0Account();<\/p>\n
Account a = (Account)s;\u00a0 —–\u00a0 Allowed<\/p>\n
Contact c = (Contact)s;\u00a0 —– Not Allowed<\/p>\n
*Id of a sObject is read-only and can never be modified.<\/p>\n
Accessing sObjects Fields<\/strong><\/p>\nFields of sObject are accessible or updateable via the dot notation similar to Java.<\/p>\n
Fields which is generated by Salesforce system cannot be modified by the user directly.<\/p>\n
Also, the fields which are generated using a formula are also not modifiable.<\/p>\n
Ex:<\/p>\n
\n\n\nAccount a =\u00a0new\u00a0Account();<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<\/td>\n | a.Name =\u00a0\u2018Nameoftheaccount\u2019;<\/p>\n Validating sObjects and Fields<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\nBefore execution of the code, the values captured are first parsed against the sObject and if there is any mismatch a run time parse error is encountered.<\/p>\n Salesforce also prevents us from making changes which may result in making some apex code invalid, as mentioned below scenario.<\/p>\n \n- Changing the API name of a field or object<\/li>\n
- Changing the data type of a field<\/li>\n
- Deletion of an object or one of its field<\/li>\n
- Making OWD(organization wide changes)<\/li>\n<\/ol>\n
Next: Data Manipulation Language DML<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"Working with Data in Apex As discussed now it\u2019s the time for some real action, in this series you will learn how to interact with data in your Salesforce org.\u00a0 Before we begin to make sure have created a Salesforce developer org, it is available for free and it is the environment where we will … Continue reading Working with Data in Apex<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72],"tags":[70,73,38,51,52],"_links":{"self":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts\/844"}],"collection":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/comments?post=844"}],"version-history":[{"count":3,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts\/844\/revisions"}],"predecessor-version":[{"id":2217,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts\/844\/revisions\/2217"}],"wp:attachment":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/media?parent=844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/categories?post=844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/tags?post=844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} | |