Wednesday, 31 January 2018

Validate duplicate record using Workflow in Salesforce

Hi Guys, Here we are going to do a thing that 'How to validate duplicate record using Workflow'.

Now you are thinking What !!, is it really possible without Trigger?


Then I will say, Yes. Do not believe me, Go and implementation firstly before believing me.


Let's Go.


1. Create a field on your object where you want to validate the duplicate records.

We are working here on Account.

Note - When you create a field make sure to True the checkbox and Save.



Create a field and make sure it is ‘Read Only’.

Now, Create a Workflow that updates a field that is created by you.

Now, We have a task that validates duplicate records on the Account object if the Account
Name already exists.

Step 1. Create a field as above image and make sure the ‘Unique’ checkbox is true and save.

Step 2. Now, create a workflow that updates the standard ‘Account Name’ field to your created field ‘Account Name’.

a)  Type ‘Workflow’ in Quick Find Box and select ‘Workflow Rules’ then click on “New Rule”.
b)  Select Your object, here we select the “Account” object and click Next.


c)  Enter your “Rule Name” and “Rule Criteria” (for - when your workflow work ) and click “Save and Next”.

Rule Name – “Test Account Validation using Workflow

Evaluation Criteria - created, and any time it's edited to subsequently meet criteria

      Rule Criteria – Account: Created Date not equal to null


d) Click on “Add Workflow Action” and choose “New Field Update”.


e)  Enter “Name” and “Field to Update” (make sure to choose the custom field which is created by you, here is – “Account Name”).
Click on “Use a formula to set the new value” under the “Specify New Field Value” section and choose Account Name (Standard field) from “Insert Field” to insert in the formula field Text Area and Save.


f) Done and Activate your “Workflow”.



All Done, Test your validation rule using Workflow. Create two records with the same name as the Account.

Pros –
1. No Apex code.
2. Validation using Workflow, so can Deactivate any time. Like – trigger.

Cons –
1. Validation Error does not show on the side of the field.

If you find any Pros & Cons then please comment for the other person and also me.

Thanks for Reading and Implementing 😐😐😐😐😐. 

Monday, 29 January 2018

Show Hide DIV with TextBox based on DropDownList Selected Value (Selection) using JavaScript



Code for - Show Hide DIV with TextBox based on DropDownList Selected Value using JavaScript.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<html>
<head>
 <script type="text/javascript">
    function ShowHideDiv() {
  var ddlGender = document.getElementById("ddlGender");
  var dvFemale = document.getElementById("dvFemale");
  dvFemale.style.display = ddlGender.value == "F" ? "block" : "none";
  
  var dvMale = document.getElementById("dvMale");
  dvMale.style.display = ddlGender.value == "M" ? "block" : "none";
    }
 </script>
</head>
<body>
 <table>
  <tr>
   <td>
    <span>Gender</span>
    <select id = "ddlGender" onchange = "ShowHideDiv()">
     <option value="select">--Select--</option>
     <option value="M">Male</option>
     <option value="F">Female</option>
    </select>
   </td>
   <td>
   <div id="dvFemale" style="display: none">
    <input type="radio" name="gender" value="single"> Single
    <input type="radio" name="gender" value="married"> Married
    <input type="radio" name="gender" value="divorced"> Divorced
   </div>
   <div id="dvMale" style="display: none">
    <input type="radio" name="gender" value="single"> Single
    <input type="radio" name="gender" value="married"> Married
   </div>
   </td>
  </tr>
 </table>
</html>

       For Output Save this code as an HTML file.
       Select any value from the Drop-Down List.
     




Wednesday, 17 January 2018

System.Today() Vs System.Now() in Apex (Salesforce) and Change the Date Format Style

Difference between System.Today() & System.Now ?

***** System.Today() *******

1. The return type of System.Today() is Date, so you can't store it in other data types like- integer, string, etc.
    i.e. - Date date1 = System.Today();

2. Return only the Date but not the time, if you debug the upper code then you will find it.
    i.e. 2018-01-16 00:00:00

***** System.Now() *******
1. The return type of System.Now() is DateTime, so you can't also store it in other data types like- integer, string, etc as well as System.Today().
    i.e. - DateTime date1 = System.Today();

2. Return both Date and Time, if you debug the upper code then you will find them.
    i.e. - 2018-01-16 10:17:23

REMEMBER - 
    If you can code this by mistake where the return type is Date of  DateTime then you will get the error.
    i.e. - Date date1 = System.Now();

Result - ErrorIllegal assignment from Datetime to Date

Because the Now() function always returns Date, the same as the Today() function always returns Date and Time both. In a real-world example, if you can accept 5 characters then you can never store more than 5 characters (the same concept is here).


********** Change the Date Format Style *************

String date1 = system.today().month()+'/'+system.today().day()+'/'+system.today().year();
system.debug(date1);

Result - 1/16/2018

Datetime Date1= Datetime.now();
// Change the format of your date and store in a String Data Type using '.format'.
String dateOutput = Date1.format('MMM/dd/yyyy');
system.debug(dateOutput);

Result Jan/16/2018


You can also change the date format as you want



// MM = Month, DD =  Date, YYYY = Year
String dateOutput = Date1.format('MM/dd/yyyy');

Result 01/16/2018

String dateOutput = Date1.format('MM-dd-yyyy');

Result 01-16-2018

String dateOutput = Date1.format('MM,dd,yyyy');

Result 01,16,2018

// Date  Month  Year
String dateOutput = Date1.format('dd/MM/yyyy');

Result 16/01/2018

Result Of Date Formats -




Saturday, 13 January 2018

Optimizer In Salesforce

What is Optimizer In Salesforce – Optimizer optimizes and monitors your whole Salesforce Org. It also checks all governor's limitation with uses means how much Salesforce provide you storage and other things which you can use.
Why We Use – It will so much helpful for an Admin. We can check all org usage detail in a single place.
How it Works – Use Optimizer to evaluate how you can improve features for your users. After you run the evaluation, Salesforce email you a personalized Optimizer report in PDF format with advice and recommendations about how you can streamline your implementation.
How you can use it?
Please use these steps in your Salesforce Org.
  1. Type “Optimizer” in Quick Find Box and click on Optimizer.
1

2. Click on “Run Optimizer“, it will ask for access to your Salesforce Org.

2

3. Click “Allow” on the Popup, when you click it will again show a new popup then Click on “Got It“.

3

Please read before you click on “Got It“, it says that After evaluate your org it will send a report to your related Email Account.

4

4. Now check your Email, you have received an email from Salesforce, Open it and scroll down.

5

You will find an attachment file on this Email, please open that attached pdf file.

6

5. Now scroll down and read what Salesforce provides you and how much you are using in present.

7


8

9

Thanks & Regard

Friday, 12 January 2018

Get Ready for Google to Salesforce Integration

Get Ready for my first blog for Google to Salesforce Lightning Integration with Sitanshu Tripathi.





Total Pageviews