Posts

Showing posts with the label Sobject

Salesforce Fact #945 | PathAssistant Sobject

There is an Sobject 'PathAssistant' in the Tooling API which we can query to get the list of all paths in the org. Few things to note: 1) If we include the FullName field in the query, we need to make sure the query returns 1 row else we encounter an error. 2) SobjectProcessField denotes the picklist field for which the path has been setup. Reference:  https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_pathassistant.htm

Salesforce Fact #871 | Sobject Tree API in action

Image
With the Sobject Tree API, it is possible to create parent record with multiple child records using the same request. In this example, we are creating two account records, one with two related contacts and another one with two related opportunities in the same POST request. Reference:  https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobject_tree.htm Attached are the screenshots.

Salesforce Fact #853 | Sobject update fact

Image
In apex, if we add an sobject record to a list and then update any of the field value the final list would include that value. But that's not the case in case of flow. In this example, we are adding an account record to a list and then updating the rating to 'Cold'. After DML is made on the list, the account rating would be 'Cold'. In case of flow, it doesn't update the rating. Note: As a best practice, always make the necessary updates to sobject record and finally add to the list. The above example is only for demonstration purpose and should not be followed.

Salesforce Fact #627 | Passing list of Sobject across batch apex

Image
Suppose we need to pass List<Sobject> records from one batch apex to another. We can call the 2nd batch from finish method of the 1st one and pass the list of records. In this example, we are creating 5 account records in batch1 and then passing the records to batch2 from the finish method of 1st batch. In this case, we need to use the  Iterable<SObject> type and the 1st batch needs to implement Database.Stateful interface to retain the value. Attached are the screenshots.

Salesforce Fact #617 | Fetching field help text

While trying to fetch the field help text using SOQL on FieldDefinition object, we get the below error: No such column 'inlinehelptext' on entity 'FieldDefinition'. So, to get the help text we can use the getDescribe() call in the format: SobjectApiName.FieldApiName.getDescribe().getInlineHelpText(). For example, Account.AccountSource.getDescribe().getInlineHelpText();

Salesforce Fact #578 | putAll() method in map

Image
There is a method named putAll() in Map Class in Apex. It has two variations. Suppose, we already have a number of sobject records in the map. Now if we want to add further sobject records from the another list of records, we can use the putAll() method instead of iterating over the sobject list. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_map.htm#apex_System_Map_putAll Attached is the screenshot.

Salesforce Fact #8 | pass entire record to flow

Besides passing the record Id, we can also pass the entire Sobject record to the flow from the record detail page. Let's say we have a flow in the Account record detail page and we want to pass the entire record to the flow. To do this, 1. Create one record variable in flow say accountRec and select the checkbox for Available for input. 2. After creating the flow, activate it. 3. While adding the flow in the record detail page using lightning app builder, an option will be given ('Pass all field values from the record into this flow variable') to populate the flow variable with the record. Select the option. 4. Now the record is available in the flow and we can access the fields like: {!accountRec.Industry} / {!accountRec.Name} etc.