Wednesday, August 10, 2022

Push Topics In Salesforce

We might have heard about the Push topics, If not these are mainly used for generating the events basis on some criteria defined on the SOQL and all these events will be consumed by the all the subscribers of the topic.

Let's assume if you have created some functionality using the Push topics either on VisualForce or in #lightningwebcomponents. It's Working as expected whenever there is change in specified object record etc..

We have refreshed the sandbox from the production and the same functionality is not working in sandbox 🤔. Interesting what is missing here regarding #pushtopics.


The point to be noted here is when we created any #pushtopics either on production or sandbox salesforce by defaults creates an entry in #pushtopic table as a record data not like metadata.

So, obviously when we refreshed the sandbox the records/data will not be created in sandbox from production only metadata will be copied from the production.

If you need these #pushtopic you need to create it again in sandbox manually.

Happy Learning 😊 


Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.


FaceBook Page - I Love Coding. You?


Hope this helps you..Enjoy..!

Tuesday, July 26, 2022

How To Download the Package.xml Using the Outbound Change Set Name

As we know the easiest way to deploy the components from sandbox to sandbox/production by using the  Change Sets. Some times we might end up use cases where change sets might not be supported and we are trying to deploying using the ANT, Workbench or Visual Code. In all these cases we might need the package.xml file is required either to retrieve the package or to deploy the package.

Preparing the package.xml file by adding the each component manually is little bit of hard .So, I want to try adding the all the list of components using the change set name because it's easy to add from the UI and with help of change set name I want to download the package.xml for further processing. 

Is it really possible to download the package.xml file using the change set name 🤔? The simple answer is Yes ,we can do this by following the below steps .


1. Go to Setup ---> Search for Outbound Change Sets.

2. Click on New --> Enter Change set name and Description.



3. Add all the components you want to deploy.

4. Copy the Change set name as shown below.



5.Login to the Workbench with same sandbox where change set is created.

6. Click on the retrieve option under the Migration.



7. Enter the Change Set Name in Package Names text box and Check Single Package



8. Click Next and then on Retrieve button.

9. Once Retrieve result Zip file is ready just click on download zip file.


10.Extract the file inside that you can see the package.xml file.


Happy Learning 😊 



Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.


FaceBook Page - I Love Coding. You?


Hope this helps you..Enjoy..!




Saturday, July 16, 2022

How To Stop Workflow Rules and Outbound Messages in Sandbox Automatically

We have couple of outbound messages linked under the workflow rules and all these outbound message will send some of custom objects data and standard objects data to external systems everytime any kind of DML operation happens on these objects. 

Everything got set up and working as expected. But recently we have come across a situation where all the outbound messages are pushing data from sandboxes to same external systems assuming that we forgot to disable these workflow rules in sandbox before we activate it and somehow we missed to change the outbound messages end point from production to sandbox.

Because of all these things the sandbox data got messed up with the production data. So, we started exploring the options how can we stop all these Workflow rules automatically in sandbox or can we change the endpoint from production to stage automatically after refreshing the sandbox.

As a solution we come across multiple options but as a quick fix we have chosen to use the below solution.


1. Identify the environment like sandbox or production.

  • Use the username to identify this assuming we will add sandbox name in the end of username but in production we will not have any name after email Id.
  • Use the SOQL to identify the environment 
2. Assuming we have decided to move with username flow create a formula field on User Object as Checkbox. 

3. Assume formula field name as "isProduction__c" and this will get updated to true in case of if user in production env and else false in sandbox.

4. Use this field in all your workflow rule by adding CurrentUser under that select isProduction__c field.

Now all your workflow rules will get evaluated to true if the logged in user in production else the rule will not get satisfied so your Workflow rules will not get fired in sandbox. 

With this approach we don't need to worry about the disabling the workflow rules and changing the outbound messages endpoints to stage. We can use other options to as well but we thought this is simple and easy to implement for Admins too...

Happy Learning 😊 

Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.


FaceBook Page - I Love Coding. You?


Hope this helps you..Enjoy..!

Sunday, June 19, 2022

Salesforce Einstein Products

 Salesforce Einstein Products

-----------------------------------------------------

As we know Salesforce has it's own artificial intelligence, natural language processing and deep learning technologies embedded product named it as "Einstein".

Some of this product features are already part of Salesforce clouds like sales cloud, service cloud and marketing cloud etc.. 

As a developer if you want to use these feature to build out of box features use it as well. 

Some of the key products of einstein are listed below. 

1. Einstein Bot

2. Einstein Next Best Action

3. Einstein Case Classification

4. Einstein Discovery

5. Einstein Prediction Builder

6. Einstein Language

7. Einstein Vision






Wednesday, June 15, 2022

Write A Test Class For Getter and Setter Methods in Salesforce Apex

Please use the below code snippet in you case you have getter and setter methods in your apex class and want to cover up the same lines in test class.

Main Class:

Public class SreeTestCase
{
 public List<SelectOption> caseStatusList 
 {
  get {
	List<SelectOption> options = new List<SelectOption>();
	for( Schema.PicklistEntry f : Case.Status.getDescribe().getPicklistValues()) 
        {
	  options.add(new SelectOption(f.getValue(), f.getLabel()));
	}
	return options;
  }
		set;
 }
}

Test Class:

@isTest 
private class SreeTestCaseTestClass 
{
    static testMethod void testStatusList() 
	{
		SreeTestCase st = new SreeTestCase();
		List<SelectOption> options = new List<SelectOption>();
		options = st.caseStatusList;
	}
}


Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.


FaceBook Page - I Love Coding. You?


Hope this helps you..Enjoy..!

How to Delete (Bulk) Custom Metadata Records in Salesforce.

 Scenario:

You might have used the "Custom Metadata Loader" to perform the bulk insert and bulk update. Sometimes it's might be required to perform the bulk delete also ,but unfortunately this tool doesn't support as of today.

Solution:

So as a workaround we can have apex code snippet which can be used to perform the bulk deletion(in a single run max 200 records) of metadata .Please use the below code snippet for the same.

Source Code:

MetadataService.MetadataPort service = new MetadataService.MetadataPort();

// Set the session id
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();

//Add all your metadata records developer name to list
List<String> recordsToDelete = new List<String>();
For(YourMedataDataName__mdt m :[SELECT Developername from YourMedataDataName__mdt Limit 200])
{
	String s = 'YourMedataDataName__mdt.'+m.Developername;
	recordsToDelete.add(s);
}

//Perform the bulk deletion at a time max of 200 records
MetadataService.DeleteResult [] results = new MetadataService.DeleteResult []{};
results = service.deleteMetadata('CustomMetadata', recordsToDelete);

Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.


FaceBook Page - I Love Coding. You?


Hope this helps you..Enjoy..!

Thursday, June 9, 2022

How can we setup different work item capacity for agents in Salesforce Omni-Channel

 Scenario:

Let's assume we have group of users assigned under the omni channel for handling of incoming chat request.
How can we set the different maximum chat limit for user basis on experience. Ex For new joiner we want to setup of maximum cap as 5 and others as 7 chats.

Solution:
Ideally in omni channel the agent capacity and which Omni-channels features can be accessed like auto decline or auto accept of the work items can be performed using the "Presence Configuration" settings.

So in our case also we can create two presence configurations ,one for the new joiners and second for the others. Under the new joiners configuration we will add all the new joiners so when they logged into Omni channel the chat capacity will be picked up from here automatically.



Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.


FaceBook Page - I Love Coding. You?


Hope this helps you..Enjoy..!

Sunday, May 29, 2022

Aura:if isTrue issue in salesforce

If you're facing an issue with Aura:if isTrue while using the And Clause or OR clause we need to know the below points.

According to salesforce documentation And/Or clause only supports two arguments for evaluation.

If you're using more than 2 arguments in And/Or clause by default Salesforce ignores it.


<Aura:if IsTrue ="Or(expression 1,expression 2)">   - - This is valid.

<Aura:if IsTrue ="Or(expression 1,expression 2, expression 3)"> - - This will not work as expected because Salesforce ignores the expression 3 for evaluation. 


Workaround :

If you need to solve this problem simply convert them into simple multiple chain expressions. 

Aura:if IsTrue ="Or(expression 1,expression 2) || expression 3)"> 

Aura:if IsTrue ="Or(expression 1,expression 2) || Or(expression 3, expression 4)"> 


Hope this helps you..Enjoy..!


Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.























Friday, May 27, 2022

How to Link a Child Record Every Time it's Created With An Existing/New Parent Record.

Lets take a use case when a child record has been created it should be automatically link to existing parent record ,in case if parent is not available it should create a parent and link the child record automatically.

The relationship between these objects is "Lookup Relationship" and the identifier to map the child with parent and the identifier when to create a new parent will be discussed below.

Simple use case here is we will have daily time sheet entries of an employee and all these daily time sheet entries should get linked under weekly time sheet entry which is like one entry for one week with 7 daily time sheet under same parent.

We can assume child object as "Daily_Time_Sheet__c" and parent object as "Weekly_Time_Sheet__c". On parent object we will have one field with name as "Parent_User_Week_Start__c(which is an external id) " which is the combination of user id and start date of the week of a given date in "Daily_Time_Sheet__c".The field name in child would be something like "ChildUserIdWeekStrartDate__c".

Source Code:

Trigger DailyTimeSheetTrigger On Daily_Time_Sheet__c(after insert)
{
	List<Weekly_Time_Sheet__c> listWTSToUpsert = new List<Weekly_Time_Sheet__c>();
	List<Daily_Time_Sheet__c> listDTSUpdate = new List<Daily_Time_Sheet__c >();
	Map<String,id> mapHours = new Map<String,id>();
	set<string> setUniqueParent = new set<string>();

	for(Daily_Time_Sheet__c dts:Trigger.new)
	{
		if(dts.ChildUserIdWeekStrartDate__c!=null && dts.Weekly_Time_Sheet__c==null)
		{
			Weekly_Time_Sheet__c wts = new Weekly_Time_Sheet__c();
			wts.Parent_User_Week_Start__c = dts.Chi;
			if(!setUniqueParent.contains(wts.Parent_User_Week_Start__c))
			{
			  listWTSToUpsert.add(wts);
			  setUniqueParent.add(wts.Parent_User_Week_Start__c);
			}
		}
	}
	
	try
	{
		if(!listWTSToUpsert.isEmpty())
		  Database.UpsertResult[] wtsUpsertResult = Database.upsert(listWTSToUpsert,Weekly_Time_Sheet__c.Parent_User_Week_Start__c,false);
	  
		for(Weekly_Time_Sheet__c ws:listWTSToUpsert)
		{
			mapHours.put(ws.Parent_User_Week_Start__c,ws.id);
		}


		for(Daily_Time_Sheet__c dts:[SeLEcT id ,ChildUserIdWeekStrartDate__c,Weekly_Time_Sheet__c FROM Daily_Time_Sheet__c WHERE ID IN: Trigger.new])
		{
			if(dts.ChildUserIdWeekStrartDate__c!=null && dts.Weekly_Time_Sheet__c==null)
			{
				if(mapHours.containsKey(bh.ChildUserIdWeekStrartDate__c))
				{
					bh.Weekly_Time_Sheet__c = mapHours.get(guid);
					listDTSUpdate.add(bh);
				}
			}
		}
		
		if(!listDTSUpdate.isEmpty())
			Database.SaveResult[] wbhUpsertResult2 = Database.update(listDTSUpdate,false);
	}
	catch(exception e)
	{
		system.debug('exception ..'+e);
	}
}

Hope this helps you..Enjoy..!


Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.






Wednesday, May 25, 2022

Convert Date into Long Time String in Salesforce Apex

  • First convert the date feild into the datetime field format
  • The getTime() in the datetime class will returns the number of milliseconds of a given date starting from  January 1, 1970, 00:00:00 GMT.

Source Code:

Date todayDate = Date.today();
DateTime todayDateTime = DateTime.newInstance(todayDate.year(),todayDate.month(),todayDate.day());
string longTime =String.valueOf(todayDateTime.getTime());
System.debug('Date in long time string..'+logTime);



Hope this helps you..Enjoy..!


Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.








How to get the start date of the week for the given date in Salesforce

 If your trying to know the starting date of the week for the given date in salesforce please use the below 2 formats.


Using the Formula Fields:

The return type of the formula is date.

(Yourdatefield__c- MOD(Yourdatefield__c- DATE(1900, 1, 7), 7))

Using the Apex:

In case of apex we can use the salesforce in built date function called toStartofWeek() which returns the start date of week basis on the user locale.

  • Sunday will be treated as US locale
  • Monday in case of European locale

Date startWeek = Yourdatefield__c.toStartofWeek();

In my case given date is 20th Friday and start of the week will returns as 15th on Sunday


Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.




Tuesday, May 24, 2022

Salesforce Data Loader Log4j Vulnerability or Data Loader Installation Issues

Salesforce Data loader is a tool which will be used to insert, update, delete, export and hard delete salesforce objects data. As we know in recent times Log4j vulnerability caused a lot of issues on multiple systems.

Basically to run the data loader we must have JDK setup on your systems so a part of the this vulnerability data loader has started facing some issues. So, Salesforce has suggested to delete the existing data loader and to set up this again after downloading the latest version from salesforce setup which is not have these issues. 

While setting up this i have come across some of the java/jdk related issues and it's been sorted out with the help of the articles mentioned below. If anyone of facing same issue related to java/jdk setup you can refer the below posts for step by step process.

How to Install Azul Zulu OpenJDK Version 11 on Windows for data loader?

Install Azul Zulu on Windows


Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.




Hope this helps you..Enjoy..!


 

Thursday, May 19, 2022

RecordType Translations Are Not Working in Salesforce

 In case of these scenarios please cross check the below things.

  • Whether logged in user county and language are properly settled or not.
  • Whether translations are mapped correctly for the logged in user language or not.
  • Check whether record type name and record type api name both are same or not.
  • If both are not same and if the data comes from the SOQL please try to use the toLabel(RecordType.Name) in SOQL. Whenever we are making a query returns the api name instated of record type label so the translations might break.

Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.




Hope this helps you..Enjoy..!

Tuesday, April 26, 2022

How to Stop Email-to-Case: Error(s) encountered while processing Error Emails

 In previous post we have clearly discussed about all the scenarios why all these emails comes .In this post we will be discussing how to stop receiving these emails from salesforce.

Please follow below steps to update the config.

  1. Go to Service Setup
  2. Search Process Automation -->Support Settings
  3. Click on Edit of Support Settings
  4. Find the "Automated Case User".


  • If it's selected as "System" 
  • Check the "Email for Automated Case User Notifications" field value might be our yours
Now if you want the keep the "Automated Case User " as System just keep that same and modify the email field of  "Email for Automated Case User Notifications" field with emailid of whom you want to send all these emails.

Even if you want to change the "Automated Case User " from System to User in this case the "Email for Automated Case User Notifications" will be marked as grayed out and all emails go to the selected user email address automatically.



Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.




Hope this helps you..Enjoy..!

Email-to-Case: Error(s) encountered while processing

Have you ever started receiving an email from Salesforce Support email ,the from address would be support@salesforce.com <support@salesforce.com> whenever there is an error while creating an email-to-case in salesforce.

One of the sample error email looks like as below



If your worrying why it's been been to you, the simple reason is that before we setup the email-to-case/support application we need to configure the Support Process in salesforce first.

If in this support process if your user has been configured as "Automated Case User" or Your email has configured as the "Email for Automated case user notifications " you will be get notified all the kind of system errors occurs on email-to-case process.



Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.




Hope this helps you..Enjoy..!