Adsense

April 15, 2020

Salesforce Process Builder

Salesforce Process Builder
Process Builder is a tool provided by Salesforce to automate your business process via point and click.For Example:If Amount has crossed its threshold(1000) then send a notification to the sales representative with the details.


Actions Available In Process Builder
There are several different actions you can trigger the process builder. These actions are:
  • Trigger Apex code: You can use the Salesforce process builder to invoke Apex code you have written within Salesforce. Apex can be anything from custom logic to save a record to complex business processes. To invoke an apex class in process builder we have to use @InvocableMethod attribute.Example:There is a Apex class named CampingListController having a method defined as @InvocableMethod. Hence we can call this method from Process builder as shown below:
    Calling Apex from Process Builder
  • Create a record: This will allow you to create new records and set certain field values for the new record.Example: When an opportunity is 'Closed Won' then create a case for the sales team.
    New Case Creation
  • Email alerts: Once a criteria is met then you can send a notification to pre defined user. To do so you first create an email alert and associate it with an existing Email Template. Email Template will be having the format in which recipients will get the message.Example: If Opportunity is 'Closed Won' and Account's industry is Banking then send an email alert to users.
    Process Builder to send email alert
  • Trigger a flow: You can launch a flow from your process to automate complex business processes.Only active autolaunch flows can be launched from Process Builder. It can launch active flows which do not contain screens.Example: If Opportunity is 'Closed Won' and Account's industry is Banking then launch a flow for his/her experience on the Opportunity journey.
  • Post to Chatter: Process builder post to chatter action helps to post information to any user or group chatter feed within Salesforce. The post will appear in the chatter field as if the person who triggered the process had written it. You can reference groups or topics and add merge fields.Example: When a case status is changed, post to chatter so that user knows that some action has been taken on the case.
    Process Builder posting to Chatter
  • Submit for approval: Only the record that started the process will be submitted. You can’t submit any related records for approval.
  • Update records: Update one or more records that are related to the record that started the process. You can update the record with manually entered values or by using the values from related records. We can update records of parent or child whereas workflow only updates same or parent object from the child.
  • Quick actions: You must already have global actions or an object specific action created within Salesforce to use these quick actions. You can then select to log a call, send an email, or update a record.Example: A contact will be created for Camping Item once the flow returns a CampList item.
    Quick Action via Process Builder
  • Process: This action will call another process to another process. For this action, you need to choose process type as it invoked by another process.You can invoke processes with objects that share at least one unique ID. For example, in the Account and Case objects, the AccountId field is unique to Account and also used by Case. You can create an invocable process that updates a Case record. Then you can invoke it from:
           A process that updates an Account record’s owner
               A process that adds an Account shipping address or updates it


Read More »

April 05, 2020

Munit validation for Multipart message - Mule4


In this article, I will try to show how we can write and execute MUnit validation for Multipart messages.

Mulesoft provide functions for creating MultiPart and formats and parts (including fields and boundaries) of MultiPart formats.

Below header needs to be added while using dataweave scripts to create multipart messages.

%dw 2.0
import dw::module::Multipart
output multipart/form-data




You will find a github link for sample project at the end of this article.

Now let us understand how we can parse and validate Multipart messages using Munit.

Multipart message formats doesn't provide flexibility for normal traversing to validate the transformation or output. To validate multipart message we need to transform the message with "application/java" format as highlighted below.

%dw 2.0 output application/java input payload multipart/form-data --- payload.parts


Validate size with function sizeOf():




Validate content:




https://github.com/manishkumarsah/multipart-munit-validation-mule4

Happy Learning :)
Read More »

March 13, 2020

WhoId and WhatId in salesforce

WhoID in Salesforce refers to people things. So that would be typically a Lead ID or a Contact ID. The WhoId represents a human such as a lead or a contact. WhoIds are polymorphic. Polymorphic means a WhoId is equivalent to a contact ID or a lead ID. The label is Name ID.

Example: Use of whoId in salesforce. Create a visualforce page:

<apex:page controller="checkwhocontroller" >
<apex:pageBlock>
<apex:pageBlocktable value="{!mywho}" var="w">
  <apex:column width="400px">
                  <apex:facet name="header">Name</apex:facet>
<apex:outputLink value="/{!w.whoid}" >
                        <apex:outputText value="{!w.who.name}"/>
                   </apex:outputLink>
        </apex:column>
        </apex:pageBlocktable>
</apex:pageBlock>
</apex:page>

Apex Class:
public class checkwhocontroller {
    public Task[] getMywho() {
    task[] mytaskArray = new task[]{};
    mytaskArray=[SELECT Subject, Who.Name FROM Task LIMIT 20];

        return mytaskArray;
    }
}


WhatID in Salesforce refers to object type things. That would typically be an Account ID or an Opportunity ID. The WhatId represents nonhuman objects such as accounts, opportunities, campaigns, cases, or custom objects. WhatIds are polymorphic. Polymorphic means a WhatId is equivalent to the ID of a related object.The label is Related To ID.

Example: Create a task whenever a case is inserted into salesforce.

trigger CaseTrigger on Case (after insert, after update){
    List<task> taskList = new List<task>();
    for (Case c : trigger.new){
        //Create a task when case is created
        if(trigger.isInsert){
            task t = new task();
            t.whatId = c.Id;
            t.Subject = c.Subject;
            taskList.add(t);
        }
    }
insert taskList;
}
Read More »

February 09, 2020

Benefits of Git tagging in DevOps Release

In this article, we will be trying to understand the uses and benefits of tagging with your repository. How it helps you with your release management cycle and hot fixes in real time projects.There are few benefits as highlighted below:
  • A tag is immutable.
  • Tags are branches without branches anyway, just adding a way to reference a specific version of the project to reduce complexity.
  • Use of tags for release versioning is better than using branches commits.
  • You can easily compare the changes between the releases.With Tags you can keep track release versions with every project release cycle.
  • Tags are mainly used for future reference to the specific version of the project, by tagging a commit.
  • With every project releases we should provide an additional piece of documentation that can be extremely helpful in certain cases. With Tags you can add these documentation easily that can be useful for your team-members and clients.
  • Tags are easy to refer while discussion of any release bugs/ defects with your team members.
  • Tags also helps to easy rollback changes to last stable release in case of something breaks with the new release deployments.
  • With tags it is easy to investigate/replicate in local when defects are hard to identify.
  • In some of retail companies which sells their product online might release/deploy with high frequency.

Now Let's understand the different types of branches which we normally use in our project developments. Each of these branches is having a specific purpose. Based on the situation these branches behaves as an originating or merge targets branch.
Git-branches


In my next article, I will show you how these branches can be useful for your git release in DevOps environments. 

Read More »

February 08, 2020

Optimize Json data using DataWeave

In this Article, we will see how we can optimize and allow Json data to accept and transform duplicate elements. In real-time projects optimizing data really matters when we talk about tuning performance. Either you say in terms of  logging data or in terms of processing data every byte matters.


In DataWeave, we have two properties which will hep us to optimize our application data.

  • duplicateKeyAsArray: JSON data does not allow duplicate keys within same parent, so we may get exception in real-time project development scenario. With this attribute, if your dataweave finds any duplicate keys, it will create an array with all those values.

Sample XML Input:

<users>
 <user>
  <personal_information>
   <first_name version="V1">Manish</first_name>
   <first_name version="V1">Mak</first_name>
   <middle_name>Kumar</middle_name>
   <last_name>Sah</last_name>
  </personal_information>
 </user>
</users>


Dataweave Script:


%dw 2.0
output application/json duplicateKeyAsArray=true
---
payload


Sample Output:


{
  "users": {
    "user": {
      "personal_information": {
        "first_name": [
        "Manish",
        "MaK"
        ],
        "middle_name": "Kumar",
        "last_name": "Sah"
      }
    }
  }
}

  • indent: It indicates whether you want to compress your JSON data into a single line or you need JSON data for better readability.
Sample Input:
<users>
 <user>
  <personal_information>
   <first_name version="V1">Manish</first_name>
   <first_name version="V1">Mak</first_name>
   <middle_name>Kumar</middle_name>
   <last_name>Sah</last_name>
  </personal_information>
 </user>
</users>


Dataweave Script:


%dw 2.0
output application/json duplicateKeyAsArray=true, indent=false
---
payload


Sample Output:


{"users": {"user": {"personal_information": {"first_name": ["Manish","MaK"],"middle_name": "Kumar","last_name": "Sah"}}}}


Happy Learning :)

Read More »