Posts

Salesforce Fact #914 | Rerender in Aura to refresh screen flow

Suppose we have created an aura component which embeds a screen flow and it is used as the New button override for the Contact object. Now, while creating record from the Contact related list in the Account detail page we are passing the current account id by parsing the URL. Now, if we leave the screen flow midway and open another account record without refreshing the page and click on the new button on contact related list, it lands on the same page where we had left and the accountId passed is also the old one. To resolve this, we can add the below piece of code in the renderer JS: ({      // Your renderer method overrides go here rerender : function(cmp, helper){     this.superRerender();     // do custom rerendering here      $A.get('e.force:refreshView').fire(); } }) With this code added, every time the flow is invoked it gets the correct accountId and starts from first screen.

Salesforce Fact #913 | Access selected record field values in screen flow lookup w/o Get Records

Image
Suppose we are using the Lookup element in the screen flow and once a record is selected, we would like to get the value from other fields. Now, Lookup provides record Id and record Name field values by default. So in order to get the other field value we need to use a Get Records. But hold on! There is an option to get the field values without using a Get Records element. We need to define a child sobject variable and then in the advanced section, set the parent field Id with the record Id of the selected record in Lookup. In this example, we have a lookup of Account record and we are using a Contact record variable and setting the AccountId field with the selected record Id and later on accessing the field values from account. Attached are the screenshots.

Salesforce Fact #912 | Screen flow footer button visibility issue

If we are using a screen flow on any button click and for the particular app, there is utility bar present. In that case, the footer buttons get hidden in the utility bar. To resolve this, we can hide the standard footer section and use the Flow button bar component from UnOfficialSF and add extra blank sections to cover the space. Reference:  https://salesforce.stackexchange.com/questions/410593/flow-footer-being-hidden-for-utility-item-bar  

Salesforce Fact #911 | Creating Location records from apex

Have you encountered this error:  DML requires SObject or SObject list type: System.Location. While creating Location records from apex, we need to specify the type as Schema.Location, else we get the above error. Sample code: Schema.Location lc = new Schema.Location(); lc.Name = 'Test location'; insert lc; Reference:  https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007X80VFSAZ

Salesforce Fact #910 | Picklist Contains operator in flow Get Records with translation

Image
Similar to apex, we need to be careful while using Contains operator in flow along with picklist translation. In this example, we have added the french translation for the Account Industry picklist value 'Banking'. Now, while using Contains operator on the Industry picklist in Get Records element, it works fine for English language but does not work for French language. No records are fetched in the Get Records for french user. To resolve this, we need to remove the Contains check from the Get Records and check the same by adding a decision element afterwards. Attached are the screenshots.

Salesforce Fact #909 | Editable date column in lightning datatable

Image
In lightning datatable, if we have a date format editable column we can use the type as 'date' or 'date-local'. If we use 'date' the editable window shows the time part also, using 'date-local' shows only date part. Reference:  https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation Attached are the screenshots.

Salesforce Fact #908 | Check if current org is sandbox in LWC

Image
How to check if the current org is sandbox in LWC? One option is to call an apex method and get the data. Another option is we can use a custom field and LWC to get the data. In this approach, we create one formula field on the User object to store the current org id and then using this one, we get the IsSandbox value using getRecord on Organization object. Attached are the screenshots.