meghamanu – ABSYZ https://absyz.com Salesforce Gold Consulting and Implementation Partner Thu, 26 Nov 2020 05:38:28 +0000 en-US hourly 1 https://absyz.com/wp-content/uploads/2020/06/cropped-favicon-1-1-32x32.png meghamanu – ABSYZ https://absyz.com 32 32 Blockchain for Salesforce https://absyz.com/blockchain-for-salesforce/ https://absyz.com/blockchain-for-salesforce/#comments Fri, 12 Jul 2019 07:10:28 +0000 http://blogs.absyz.com/?p=9936

Introduction of Blockchain

 

Blockchain is a technology
that uses cryptography to create a secure linkage between records.

 

Blockchain was first described in 1991 by Stuart Haber and W. Scott Stornetta.

 

Blockchain has nodes, and these nodes are called Blocks. Each block contains the hash, hash of the previous block, timestamp and the data. Tempering with blockchain is not easy. If a block has been corrupted than the chain gets corrupted.

The Concept of Blockchain

A Block is similar to the linked list but with more complexity. A block’s hash is generated by the data from the block. But it is simple to generate the hash from data. To prevent this it also contains the hash of the previous block. so, if any data is touched then block get invalid and the chain as well. If someone wants to hack the blockchain then hacker needs to update all the blocks. It is not that simple and it is time-consuming as well.

 

Block Diagram for BlockChain

What is Salesforce Blockchain

 

Salesforce Blockchain is a new way to create, secure and share data from applications with a network of partners. This is because Salesforce Blockchain provides the infrastructure of a distributed ledger(A distributed ledger is a database that is consensually shared and synchronized across multiple sites) and adds on the power of Salesforce metadata. A partner can securely publish and independently verify records on Salesforce Blockchain from whatever system they use.

Benefits that you can get from aligning Blockchain with Salesforce

A). The Increase of CRM Data Security

That is the point at which your organization can get
demonstrated information that is ensured by blockchain innovation. It is a huge
element while utilizing cloud arrangements.

B). The Ability to Be Closer to Your Customers and Grasp their Demands

Blockchain can give you a top to the bottom outline of the
prospects and clients, break down their requests and choose where to convey the
business assets. That is the reason for applying the blockchain innovation
inside CRM can support consumer loyalty and give you an inventive apparatus for
dealing with the business procedure.

C). The Customer Experience Management Improvement

That is how you will guarantee the customer’s information
security and deal with the customer’s experience in any case of the
business.

Consequently, the blockchain together with CRM can expand the
security, quality, and speed of your client administration higher than ever.

Build Your First Blockchain with Salesforce Apex

1.The first step is to create a class called Block. This class will further be utilized to create new blocks in the chain.

 

public class Block 
{
    public integer index;
    public long timestamp;
    public string data;
    public string prevHash;
    public string hash;
    //The constructor of the class will have three parameters.index,data and prevhash
    public Block( integer index,string data,string prevHash)
    {
        this.index=index;
        this.timestamp=generateTimeStamp();
        this.data=data;
        this.prevHash=prevHash;
        this.hash = this.getHash();
    }
    //This method will generate timestamp for the block.
     private long generateTimeStamp()
    {
        return DateTime.Now().getTime();
    }
    //This method creates hash code from data + prevHash + index + timestamp.
    public string getHash()
    {
        Blob dataToEncrypt = Blob.valueOf( this.data + this.prevHash + this.index + this.timestamp);
        //using the generateMac method from Crypto class,selecting HmacSHA256 in the algorithm,choosing Private key to generate a message authentication code (Mac).
        Blob encrypted = crypto.generateMac('HmacSHA256', dataToEncrypt, Blob.valueOf('key'));
        return EncodingUtil.base64Encode(encrypted);
    }
}

2. Create a Class called Blockchain. This class will be used to create the new blocks in the chain and Validate chain. This class  method will check for the valid block. if the block is not valid then it will return false or it will return true

 

public class BlockChain
 {
    public List<Block> chain;
    public BlockChain()
     {
        chain = new List<Block>();
     }
     public void addBlock(string data)
{
        //Defining Index from chain size
        integer index = chain.size();
    //Checking for previous block's hash, If it is first block then it set previous block as '0'
        string prevHash = chain.isEmpty()==true ? '0' : chain.get(chain.size()-1).hash;
        
        //Creating a block from index, data and previous block's hash
        Block newBlock = new Block(index, data, prevHash);
        
        //Adding the new block in the chain
        chain.add(newBlock);
    }
    
    //This method is checking for the valid chain.
    public boolean isChainValid(){
        
        for(integer i=0; i < chain.size() ; i++ ){ 
            //if the chain is not valid then it will return false or it will return true
            if( !isBlockValid(i) ){
                return false;
            }
        }
        
        return true;
    }
    
    //Checking block's hash with run time calculated a hash from the block
    public boolean isBlockValid(integer index){
        
        
        //If someone has changed the block data then getHash will return a new data and not be same as the block's Hash
        if(chain[index].hash != chain[index].getHash() ){
            return false;
        }
        //If the index is greater than zero then it is also checking the block's prevHash from previous block's hash. 
        if(index > 0 && chain[index].prevHash != chain[index-1].hash ){
            return false;
        }
        return true;
    }
}

 

Test Class

 

@isTest
public class TestBlockchain{
    
    //Testing Blockchain 
    @isTest
    public static void testBlockChain(){
        /**Data Setup**/
        
        //Creating Instance of Blockchain
        BlockChain bChain = new BlockChain();
        
        //addBlock method take data as the string
        //Changing data to the string with the JSON format
        
        //Adding the first block to the chain
        bChain.addBlock( json.serialize( new BCTestDataWrapper('Iron Man', '2334343434') ) );
        
        //Adding the second block to the chain
        bChain.addBlock( json.serialize( new BCTestDataWrapper('Thor', '34343434') ) );
        
        
        /**Positive Testing**/
        
        //isChainValid will return true, as no data has been modified from block
        system.assertEquals(true, bChain.isChainValid() );
        
        //Print Blockchain
        system.debug('-Blockchain Data Before Modifying--'+Json.serialize( bChain.chain));
        system.debug('-Blockchain Data Before Modifying--' +bChain.isChainValid());
        
        
        /**Negative Testing**/
        
        //Now updating the 0 index's block
        BCTestDataWrapper tData = (BCTestDataWrapper)JSON.deserialize(bChain.chain[0].data, BCTestDataWrapper.class);
        tData.name = 'Thanos';
        bChain.chain[0].data = json.serialize(tData);
        
        //isChainValid will return false, as the data has been modified from block
        system.assertEquals(false, bChain.isChainValid() );
        
        //Print Blockchain
        system.debug('-Blockchain Data After Modifying--'+Json.serialize( bChain.chain) );
        system.debug('-Blockchain Data After Modifying--' +bChain.isChainValid());
    }

Test Data Wrapper Class

 

public class BCTestDataWrapper{
    public string name;
    public string accountNumber;
    
    public BCTestDataWrapper(string name, string accountNumber){
        this.name = name;
        this.accountNumber = accountNumber;
    }
}

Output

On the execution of the above code, the obtained output is as follows:

isChainValid will return true, as no data has been modified from block

Blockchain Data Before Modifying–[{“timestamp”:1561687116,”prevHash”:”0″,”index”:0,”hash”:”GCS4SGVQ=”, “data”:”{\”name\”:\”IronMan\”,\”accountNumber\”:\”23343434\”}”},{“timestamp”:1561687118,”prevHash”:”GCS4SGVQ=”,”index”:1,”hash”:”uEFcuKCfhhlIVx

Blockchain Data Before ModifyingTRUE

isChainValid will return false, as data has been modified from block

-Blockchain Data After Modifying–[{“timestamp”:1561687116,”prevHash”:”0″,”index”:0,”hash”:”GCS4SGVQ=”, “data”:”{\”name\”:\”Thanos\”,\”accountNumber\”:\”23343434\”}”},{“timestamp”:1561687118,”prevHash”:”GCS4SGVQ=”,”index”:1,”hash”:”uEFcuKCfhhlIVxFn0

Blockchain Data After ModifyingFALSE

 

]]>
https://absyz.com/blockchain-for-salesforce/feed/ 1
How to Export data from salesforce using Talend https://absyz.com/how-to-export-data-from-salesforce-using-talend/ https://absyz.com/how-to-export-data-from-salesforce-using-talend/#comments Wed, 17 Oct 2018 09:37:26 +0000 http://blogs.absyz.com/?p=9413

Transferring data to and from Salesforce is not very difficult. Salesforce data import wizard and Salesforce Dataloader.io tools made the job of data migration a rather point-and-click process. However for repetitive, complex, or large scale data transfer operations, these tools become too difficult.

Talend is one such tool with a great portfolio of data integration and migration offerings that can be used to migrate data to and from Salesforce. The free data migration tool Talend Open Studio, is even popular among our Salesforce developers.

What is Talend?

Talend is an open source data integration platform. It provides various software and services for data integration, data management, enterprise application integration, data quality, cloud storage and Big Data. Using Talend, data becomes more accessible, its quality enhances and it can be moved quickly to the target systems.

Please find below link for the installation and introduction about talend.

https://teamforcesite.wordpress.com/2018/10/16/introduction-to-talend-integration-tool/

Steps to  Export data from salesforce in Talend

Step 1: Open Talend and Create a Job

The first step is to open Talend and create a new project. You can create a local project with default credentials or you can access a cloud hosted project through proper login and password.

screenshot 1

Once you have opened a new project, the first step is to create a new job. In the left side panel labeled Repository, you will find an entry named Job Design. Right click on it and create new Job.

screenshot2

Step 2: Establishing Connections for Export

1.Once you have created your Job, you can drag and drop the connection to the Job Designer panel. Drag  tSalesforceInput component to extract the data from salesforce . This component can be found in the  Palette.

2.Connect the tSalesforceInput component to the tfileOutputDelimited component which outputs data to a delimited file using a Row > Main connection.

screenshot 3

Step 3:Configuring the Components

1.Double-click the tSalesforceInput component to open its Basic settings view.

screenshot9

2.In the User IdPassword and Security Key fields, enter the user authentication information required to access Salesforce.

3.Click the […] button next to the Module Name field and in the pop-up dialog box, select the object you want to access. In this example, it is Account.

4.Click the […] button next to Edit schema to open the schema dialog box.

5.Remove all columns except IdName.

Note that to retrieve a column from a linked object, it is necessary to define the name of the column in a particular manner in the schema editor.

Click OK to save the changes and close the schema dialog box.

screenshot 5

6.Select the Manual Query check box and in the Full SOQL query string field displayed, enter your SOQL statement used to search the data to be retrieved. In this example, the statement is as follows:

 screenshot 6

7.Double-click the tfileOutputDelimited component to open its Basic settings view.

screenshot10

8.In the Property Type field, set the type to Built-in and fill in the fields that follow manually.

9.Click the […] button next to the File Name field and browse to the output file you want to write data in, Account.csv  in this example(extension can be .txt,.xsls  etc).

10.In the Row Separator and Field Separator fields, set “\n” and “,” respectively as row and field separators.

11.Select the Include Header check box if you want to output columns headers as well.

12.Click Edit schema to open the schema dialog box and verify if the recuperated schema corresponds to the input schema. If not, click Sync Columns to recuperate the schema from the preceding component.

13.Press Ctrl+S to save your Job.

14.Press F6 or click Run on the Run tab to execute the Job.

screenshot 8

The two specified columns IdName are output in the defined output file.

Note: There is no built-in limit to the number of records you can output with a tFileOutputDelimited. Once you get into really HUGE (1B+) numbers of records, you do need to start considering resources on the server and may find that your particular job and hardware configuration imposes a limit on the number of records you can process ( disk space, memory, etc… )

 

 

 

 

 

]]>
https://absyz.com/how-to-export-data-from-salesforce-using-talend/feed/ 1