Posts

How to get the current sandbox-name programmatically (dynamically) via APEX?

There is now an official solution that is out with the  Spring' 22 release . You can use the new  getSandboxName()  method: System. Domain d = System.DomainParser.parse(URL.getOrgDomainUrl()); System.debug(d.getSandboxName()); You can get more information about this new method in the Apex Reference Guide  here . There are also so other new and useful methods like  getMyDomainName() .

Adding a red asterisk to required fields using label in LWC

Image
I am trying to add a double or single asterisk to lightning: input tags in LWC, by using "required" tag inside the tag I am able to see the asterisk, but two issues with this are I have to show a red asterisk to some conditionally mandatory issues. Solution -  You can use  label-hidden  variant and put a label. <template> <label>Middle Name</label> <abbr title="required" class="slds-required">**</abbr> <lightning-input label="Middle Name" variant="label-hidden" aria-required="true" maxlength="80"></lightning-input> </template>

How to Deploy Platform Event from Sandbox to Production ?

Custom platform events are sObjects, similar to custom objects. Define a platform event in the same way you define a custom object. Please visit this link - https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_define.htm

Run One Apex Batch for two object but remember always prefer to write batch per object.

  Hi Friends, I have shared one of the concepts in which we have used one apex batch for two objects. but remember it depends based on the condition. And according to my opinion, always write apex batch class per/each objects. global class Batchsampledeleterecord implements Database.Batchable<string>, Database.Stateful, Schedulable {     global boolean bReRun = false; //will be used to determine if batch has to re-run in case there are more that 10K of records     global Iterable<String> start(Database.BatchableContext bc) {         return new list<String> { 'custom_object__c', 'custom_object2__c'}; //list of strings with my object names     }     global void execute(Database.BatchableContext bc, list<string> lstsObjectName){         list<sObject> lstDeleteRecords = new list<sObject>();         for(string strObjectName : lstsObjectName) {   ...

How to populate maximum time string repeat in record /Child Record - Similar Rollup summary Max function.

Hi Rowdies, This is a Sample code for displaying maximum time repeat string in child records like Invoice and Invoice line. <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9744265961313227"      crossorigin="anonymous"></script> Set<String> strSetTaxCode = new Set<String>();  for (custom__c obc : [SELECT  Id , customfield__c, customfield2__c FROM custom__c ]){             if(String.isNotBlank(oinvline.customfield__c)){                 lstTaxCode.add(oinvline.customfield__c);             }  } for (string settemp : lstTaxCode){      strSetTaxCode.add(settemp); }         for(String str: strSetTaxCode){     Integer countofChar = 0;      for(String strl: lstTaxCode ){                 i...

How to Refresh Page using Lightning Web Component

 eval("$A.get('e.force:refreshView').fire();");

How to delete files from using Apex in salesforce

list < ContentDocument > lstCntDocsToDelete = new list< ContentDocument >(); for ( ContentDocumentLink iterator : [ SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = '1234567890123456' ]) { lstCntDocsToDelete . add( new ContentDocument ( Id = iterator . ContentDocumentId )); } if ( ! lstCntDocsToDelete . isEmpty() && lstCntDocsToDelete != null ) { Database . delete(lstCntDocsToDelete, false ); Database . emptyRecycleBin(lstCntDocsToDelete); }  

Use BatchApexErrorEvent Triggers to Monitor ISV Applications With Example (Salesforce Spring ’21 Release)

Include BatchApexErrorEvent triggers in your managed package to monitor the health of batch jobs and take necessary corrective action without any post-installation steps. Where:  This change applies to Lightning Experience and Salesforce Classic. How:  The BatchApexErrorEvent object represents a platform event associated with a failing batch Apex execution. To fire this platform event, a batch Apex class declaration must implement the  Database.RaisesPlatformEvents  interface. A  BatchApexErrorEvent  platform event is fired when a batch Apex job encounters an unhandled exception. For more details, see  Firing Platform Events from Batch Apex  in the  Apex Developer Guide . The BatchApexErrorEvent object represents a platform event associated with a batch Apex class. This object is available in API version 44.0 and later. If the  start ,  execute , or  finish  method of a batch Apex job encounters an unhandled exception, a...