Integration – ABSYZ https://absyz.com Salesforce Gold Consulting and Implementation Partner Fri, 27 Nov 2020 11:02:27 +0000 en-US hourly 1 https://absyz.com/wp-content/uploads/2020/06/cropped-favicon-1-1-32x32.png Integration – ABSYZ https://absyz.com 32 32 Create/Update Salesforce Picklist definitions using metadata API https://absyz.com/create-update-salesforce-picklist-definitions-using-metadata-api/ https://absyz.com/create-update-salesforce-picklist-definitions-using-metadata-api/#respond Thu, 21 May 2020 07:51:19 +0000 http://blogs.absyz.com/?p=11116
Introduction:

Imagine you have a customer who is not familiar with Salesforce and there is a need to add/update picklist values along with record types in the system, then you cannot expect him to follow the ideal steps (Setup->Object Manager->) to make the changes. So, this problem can be solved by using Lightning Component with Metadata API Service. This component enables a user to make the required changes  across multiple fields in your Salesforce instance with couple of clicks from the UI itself.

Unique features:

1. On click Create/Update picklist values.

2. On click assigning of picklist values to the record types.

3. On click removing of picklist values from the record types.

4. On click Update of records upon updation of picklist values.

Display UI:

 

Functionality:

Step1: Object Name – Displays all the object names present in your Salesforce instance

Select an Object

 

Step2: Picklist – Displays all the fields of the selected Object

Select a Picklist

 

Step3: Action – Displays two actions available Create/Update

Select an Action which you want to perform

 

Step3a: If Action selected is ‘Create’

Select Record Types: – Displays all the available record types

Select the Record Types to which you want to assign the new picklist value

 

Step3b: Description – Contains the name of the new picklist value

Give the name of the new picklist value here

 

Step4: Action – Displays two actions available Create/Update

Select an Action which you want to perform

 

Step4a: Picklist Value to Update – Displays the picklist values related to the picklist field selected

Select a picklist value which you want to update

 

Step4b: Select RecordTypes

Selected Options – Displays all the record type names in which the selected value is already present

Available Options – Displays all the record type names in which the selected value is not present

Select the record types to which the picklist value need to be assigned and remove the record types from which the picklist value need to be removed

 

Step4c: Description – Contains the updated name of the picklist value

 

Step5: Save

Clicking on

 

required operation will be performed.

UI:

UniversalPicklist.cmp

You have to build a lightning component to get UI as shown in the above snippet, you need to display five fields and a button.

 

Object Name: You can either hard code what all objects you want to display in this field or get all the objects using schema

 

Picklist: As soon as you select an Object Name you need to make a server call and get all the respective picklist fields available. You can get all the fields using schema

Action: Since we need only two different actions here, you can display those two values using <lightning:select>

 

  • Create:- If you select ‘Create’ you need to make another server call and get all the record types in that particular object and display them in a format shown in the above snippet using <lightning:dualListbox>
  • Update:- If you select ‘Update’ this means that you want to update an existing picklist value. So, here also you need to make a server call get all the picklist values for a selected picklist field. You can refer to this doc for getting the picklist values

Picklist Value to Update: The obtained picklist values will be displayed here. As soon as a picklist value is selected, you should get all the record types which has and which doesn’t have this picklist value and display on the UI accordingly, as shown in the snippet.

Description: This field holds the new or updated picklist value which user enters

Back end Logic:

MetadataApiService.apxc

You should have a MetadataApiService class.

Refer this link, you can use the same class.

UniversalPicklistController.apxc

Create/Update picklist value for custom fields: You can refer to this link for creating or updating the piclist values using metadataservices

Create/Update picklist value for standard fields: Refer the below code for standard fields:

 

//Read
        MetadataApiService.StandardValueSet StandardField = (MetadataApiService.StandardValueSet) service.readMetadata('StandardValueSet', new String[] { picklistapiname }).getRecords()[0];
        
        MetadataApiService.StandardValue sv = new MetadataApiService.StandardValue();
        sv.fullName = valueInTheDescription;
        sv.default_x = false;
        StandardField.standardValue.add(sv);
        
        // Update 
        List<MetadataApiService.SaveResult> lstResults = service.updateMetadata( new MetadataApiService.Metadata[] { StandardField });

Updating Record Types: You can refer to this link to update Record Types

UniversalPicklistCntrlSessionIdGenerator.vfp

Use this code for generating session Id

 

<apex:page >
    Start_Of_Session_Id{!$Api.Session_ID}End_Of_Session_Id
</apex:page>

UniversalPicklistControllerUtils.apxc

 

global class UniversalPicklistControllerUtils {
    global static String getSessionIdFromVFPage(PageReference visualforcePage){
            String content= visualforcePage.getContent().toString();
            Integer s = content.indexOf('Start_Of_Session_Id') + 'Start_Of_Session_Id'.length(),
                e = content.indexOf('End_Of_Session_Id');
            return userinfo.getSessionId();
    }
}

 

]]>
https://absyz.com/create-update-salesforce-picklist-definitions-using-metadata-api/feed/ 0
Increase your Productivity with the Apex Metadata API https://absyz.com/increase-your-productivity-with-the-apex-metadata-api/ https://absyz.com/increase-your-productivity-with-the-apex-metadata-api/#respond Mon, 23 Mar 2020 10:45:09 +0000 http://blogs.absyz.com/?p=10385

The force.com Platform provides us with features which are out of the box and helps increase productivity! Such is the “Metadata API”.

Here, we will see how we can leverage the Metadata API and avoid doing tasks manually thus ultimately saving a lot of time!

What is Metadata API?

Launched back in the Summer’17 release the Apex Metadata API lets you make metadata changes directly from apex.

We can use the handy features of apex in order to build custom setup UI scripts and perform automation actions behind the script.

Let’s consider an example and see how it can help :

Suppose you are an ISV and have created an app involving automation’s and many other features which are not generally available.You have packaged all your changes and is ready to be installed across org’s.

Now, the admin team comes into picture for rolling out the changes. The admin team has to perform a lot of post installation steps manually using the setup UI over and over.

This is where the metadata API comes in, you can create custom setup UI scripts to guide the admins through the process, and perform back end change actions using metadata api which updates the metadata while they go through the process over clicks and that’s it the changes will be available.

Thus, avoiding repetitive steps.

Let’s look at few use cases where we can use the Metadata API:

  1. Using the Metadata API we can build tools which can automate configuration changes.
  2. We can update our metadata changes in multiple org’s by deploying it across multiple org’s from apex using the Metadata API Deploycallback class which uses a deployment container and executes based on actions specified.
  3. We can control multiple org metadata in a single org. And can perform CRUD operations.

There are lots of use cases around, let’s implement few and see how actually the Metadata API can help us increase productivity!

In our example here we will be retrieving the metadata from the contact object. We will retrieve a section named ‘Additional Information’ from the page layout of contact, add a new field into that section all from apex!!

Sounds Interesting ain’t that? Let’s check it out…

[sourcecode language=”Java”]

public class UpdateContactPageLayout {
public Metadata.layout addLayoutItem(){

//Retreive metadata from the contact page layout using Metadata.Operations.retrieve method
List Metadata.Metadata layoutsList =
Metadata.Operations.retrieve(Metadata.MetadataType.Layout,
new List String{‘Contact-Contact Layout’});

//Getting Layout from the contact object
Metadata.Layout layoutMetadata = (Metadata.Layout) layoutsList.get(0);
Metadata.LayoutSection contactLayoutSection = null;
List Metadata.LayoutSection layoutSections = layoutMetadata.layoutSections;

for (Metadata.LayoutSection section : layoutSections) {
/** Assigning section value to contactLayoutSection Variable if section label satisfies condition **/

if (section.label == ‘Additional Information’) {
contactLayoutSection = section;
break;
}

}

List Metadata.LayoutColumn contactColumns = contactLayoutSection.layoutColumns;
List Metadata.LayoutItem contactLayoutItems = contactColumns.get(0).layoutItems;

Metadata.LayoutItem newField = new Metadata.LayoutItem();
newField.behavior = Metadata.UiBehavior.Edit;
newField.field = ‘AMAPI__Apex_MD_API_Twitter_name__c’;
contactLayoutItems.add(newField);

system.debug(‘newfield Inserted’);
system.debug(‘contactLayoutItems’ + contactLayoutItems);
system.debug(newField);

return layoutMetadata;
}
}

[/sourcecode]

 

Let’s check out the logs and see whether a new field was created or not!

If you are trying this out instead of “amapi” in the newField.field variable specify your org’s namespace followed by the field you want to create.

E.g: ‘yourOrgNameSpace_Field_Name__c’

Screenshot (73)

We can see that the field got created, but in order to finally add the field in your layout we need to deploy the Metadata changes using Deploy container. This will finally add your metadata to the page layout.

Refer here for Deployment Container Class.

Now, let’s quickly look at another example of creating a record in a Custom Metadata Type.

In our case we have already created a Custom Metadata type called “Vat Rate”.

And we will be creating a new record for the custom Metadata Type using Custom Metadata API from apex.

If you are a newbie and have no idea how to create a custom metadata type refer this “Create Custom MetadataType“!

Let’s look at the code:

[sourcecode language=”Java”]

public class MetadataExample {
public void updateMetadata(){

//Retreive custom metadata type details from org
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();

//insert the fullName and Label value for the record you want to create

customMetadata.fullName = ‘VAT_Rate.NewRecordFromMetadataAPI’;
customMetadata.label = ‘NewRecordFromMetadataAPI’;

//We will populate the field called Rate in the Custom Metadata type with some value
Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
customField.field = ‘Rate__c’;
customField.value = 10;

/**Adding record values to the customMetadata type ***/
customMetadata.values.add(customField);

/** Deployment Container to deploy the metadata changes **/

Metadata.DeployContainer deployContainer = new Metadata.DeployContainer();
deployContainer.addMetadata(customMetadata);

/** This will invoke the deployment Process of the changes **/
system.debug(‘customMetadata’+customMetadata);
system.debug(‘Metadata deployed’);

Id asyncResultId = Metadata.Operations.enqueueDeployment(deployContainer, null);
}
}

[/sourcecode]

Also, check the logs just to be sure there are no errors! 😀

Screenshot (74)

You can track your metadata change deployment in the Deployment Status.

Navigate to Setup –>In Quick Find type “Deployment Status” and click on the record initiated with proper timestamp details.

Screenshot (77)

Once the changes are deployed, we will navigate to the Custom Metadata Type and check whether a record has been created or not.

Let’s navigate to the Vat Rate Custom metadata type and see.

Screenshot (78)

 

Now let’s navigate to the record detail page and check whether the value of “rate” specified in code is populated or not.

Screenshot (79)

That’s it! We have created a metadata record type using the Metadata API from Apex and not manually!!

Advantages of using the Metadata API:

  1. You can deploy your metadata changes using deployable packages across multiple org’s without needing to create change sets and doing tasks manually.
  2. You can write custom scripts to perform backend actions for automating metadata changes across the org. thus eliminating a major heck of manually work for the SF admins out there!! Interesting? Ain’t that.

You can also create CustomMetadata types using the MetadataService class library.

That shall be all for now!

We will continue to dive deep on this in the next follow up blog and also check how to test your MetadataAPI and discuss possibilities of designing a solution for Bulk Creation of Custom Metadata Types and automate Metadata Changes.

Thank you for reading!!

Don’t be shy to try it out, and keep on blazing your trails!! 🙂 

 

 

 

 

 

]]>
https://absyz.com/increase-your-productivity-with-the-apex-metadata-api/feed/ 0
Send ICS calendar invitations for Outlook meetings https://absyz.com/send-ics-calendar-invitations-for-outlook-meetings/ https://absyz.com/send-ics-calendar-invitations-for-outlook-meetings/#comments Wed, 18 Dec 2019 10:13:40 +0000 http://blogs.absyz.com/?p=10675

Here we are going to send the meeting invites from salesforce using ICS calendar to our outlook. In general ICS is the  iCalendar/.ics/.ical file and it is used to store the calendar information. Whenever you export anything a outlook, google, etc., calendar  it will automatically save as .ics file.

New and updated meetings are sent to participants using an email notification from particular person. This requires diligent effort from all participants to update their local calendars manually.  The idea is to automatically generate an ICS file with the meeting details and attach it to the notification email whenever an meeting is scheduled or rescheduled. This would allow participants to see the appointment into their calendars.

Let’s assume we have Meeting object in our Org with the following fields

 

  • Subject  – text field
  • Meeting Leader – email field
  • Objective of meeting – picklist field
  • start – Date/Time field
  • End – Date/Time field

Now we are trying to send the meeting invite after inserting or updating the record in salesforce. For that i was using the trigger whenever the record in inserted or updated.

Check the below code to send the ICS calendar invite..!!

 

[sourcecode language="java"]
 trigger meeting on Meeting__c (after Insert,after Update) {
    list<Meeting__c> meetList= new list<Meeting__c>();
    for(Meeting__c meet:trigger.new){
        meetList.add(meet);
    }
    AP_Meeting.sendInvite(meetList);
 }

[/sourcecode]

Below is the helper class..!!

 

[sourcecode language="java"]
public class AP_Meeting{
    public static void sendInvite(list<Meeting__c> meetingList) {
        list<string> UserEmailList = new list<string> ();
        string title;
        string meetingTitle;

        for(Meeting__c meet:meetingList){
            UserEmailList.add(meet.MeetingLeader__c);
            meetingTitle=meet.name+': '+meet.Subject__c;
            title=meet.Subject__c;
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(UserEmailList);
            mail.setPlainTextBody('This to inform that we have meeting related to particular problem');
            mail.setSubject(title);
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            attach.filename = 'meeting.ics';
            attach.ContentType = 'text/calendar; charset=utf-8; method=REQUEST'; //PUBLISH';//
            attach.inline = true;

            /***************************/
            attach.body = invite(UserEmailList, meet.MeetingLeader__c, 'Harish Lingam', meet.Subject__c, meet.start__c, meet.end__c, meet.createdDate, system.now(), meet.ObjectiveOfMeeting__c, meet.LastModifiedDate);
            mail.setFileAttachments(new Messaging.EmailFileAttachment[] {
                attach
                    });
            Messaging.SendEmailResult[] er = Messaging.sendEmail(new Messaging.Email[] {
                mail
                    });
        }
    }

    public static Blob invite(List<String> emailsList, String Organiser, string name, string subject, dateTime startDate, dateTime endDate, dateTime createdDate, string description, dateTime lastmodifiedDat) {
        String txtInvite = '';
        string startdateTime;
        string enddateTIme;
        string createdDateTime;
        string lastmodifiedDatTime;

        startdateTime = startDate.formatGMT('yyyyMMdd\'T\'HHmmss\'Z\'');
        enddateTIme = endDate.formatGMT('yyyyMMdd\'T\'HHmmss\'Z\'');
        createdDateTime = createdDate.formatGMT('yyyyMMdd\'T\'hhmmss\'Z\'');
        lastmodifiedDatTime = lastmodifiedDat.formatGMT('yyyyMMdd\'T\'hhmmss\'Z\'');

        txtInvite += 'BEGIN:VCALENDAR\n';
        txtInvite += 'PRODID:-//Microsoft Corporation//Outlook 16.0 MIMEDIR//EN\n';
        txtInvite += 'VERSION:2.0\n';
        txtInvite += 'CALSCALE:GREGORIAN\n';
        txtInvite += 'METHOD:REQUEST\n';
        txtInvite += 'REPLAY:ACCEPTED\n';
        txtInvite += 'BEGIN:VEVENT\n';
        txtInvite += 'ATTENDEE\n';
        txtInvite += 'CN=' + subject + '\n';
        for (String email: emailsList) {
            txtInvite += 'ATTENDEE:' + email + '\n';
        }
        txtInvite += 'X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n';
        txtInvite += 'X-WR-RELCALID:{0000002E-9CDF-9CE8-AD4C-66FC0A5A25F7}\n';
        txtInvite += 'CLASS:PUBLIC\n';
        txtInvite += 'CREATED:' + createdDateTime+'\n';
        txtInvite += 'DTEND:' + enddateTIme+'\n';
        txtInvite += 'DTSTART:' + startdateTime+'\n';
        txtInvite += 'LAST-MODIFIED:' + lastmodifiedDatTime+'\n';
        txtInvite += 'ORGANIZER;CN=' + name + ':mailto:' + Organiser + '\n';
        txtInvite += 'RSVP=TRUE\n';
        txtInvite += 'ROLE=REQ-PARTICIPANT\n';
        txtInvite += 'PARTSTAT=NEEDS-ACTION\n';
        txtInvite += 'CN=' + subject + ':mailto:' + Organiser + '\n';
        txtInvite += 'LOCATION:Skype\n';
        txtInvite += 'PRIORITY:5\n';
        txtInvite += 'SEQUENCE:0\n';
        txtInvite += 'SUMMARY:\n';
        txtInvite += 'STATUS:NEEDS-ACTION\n';
        txtInvite += 'LANGUAGE=en-us:\n';
        txtInvite += 'TRANSP:OPAQUE\n';
        txtInvite += 'UID:4036587160834EA4AE7848CBD028D1D200000000000000000000000000000000\n';
        txtInvite += 'X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD><META NAME="Generator" CONTENT="MS Exchange Server version 08.00.0681.000"><TITLE></TITLE></HEAD><BODY><!-- Converted from text/plain format --></BODY></HTML>\n';
        txtInvite += 'X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n';
        txtInvite += 'X-MICROSOFT-CDO-IMPORTANCE:1\n';
        txtInvite += 'BEGIN:VALARM\n';
        txtInvite += 'TRIGGER:-PT15M\n';
        txtInvite += 'ACTION:DISPLAY\n';
        txtInvite += 'STATUS:CONFIRMED\n';
        txtInvite += 'DESCRIPTION:Reminder\n';
        txtInvite += 'END:VALARM\n';
        txtInvite += 'END:VEVENT\n';
        txtInvite += 'END:VCALENDAR';
        return Blob.valueOf(txtInvite);
     }
 }
[/sourcecode]

Now lets create a record in the org.  fill the information needed…!!

Now it will directly create a meeting calendar invite in outlook with the details provided. Make sure the all the details filled whatever it is we have used in the code.

 

m5-e1576651434409.png

 

m2

Now we can check calendar for invite.

Now if you want to reschedule the meeting, for that we need to update the record, by updating Start and End time. Now we have rescheduled the meeting to the next day and now the calendar is updated,

 

m6.png

So now you will receive new email with the updated calendar info. Now check the calendar for the updated information.

 

m4

Finally you can add the email template in what ever format you need it, you can also send to the bunch of the people by adding them to the public groups.

 

]]>
https://absyz.com/send-ics-calendar-invitations-for-outlook-meetings/feed/ 1
Salesforce integration with Paypal https://absyz.com/paypal-integration-with-salesforce/ https://absyz.com/paypal-integration-with-salesforce/#respond Fri, 25 Oct 2019 09:41:15 +0000 http://blogs.absyz.com/?p=10452

Purpose of Integration

The main purpose of this blog is to integrate the Paypal Payment Gateway with Salesforce. Paypal is useful to make the payment from e-com community or sites.In this blog, we are going to implement Paypal integration with Salesforce for a basic payment for Merchant Type account, the payments would be from Customers using Credit Cards like Visa etc. where customer enters the payment details on lightning component which will complete the payment on click of submit button.Firstly,we need to set up a paypal account.So let’s get started.

 

 

Integration Steps:

1) Set up Paypal Account:

1.Create a Personal or Business Paypal Account.

(i).To create business Paypal Account visit developer.paypal.com

(ii).To create Personal/Individual Account visit https://www.paypal.com/in/signup/account

For this blog,I have created a Business Paypal Account.

 

2.Login with your credentials and you will be landed in Dashboard Page.

 

3.Select Sandbox under Accounts from left side.You will find one default Business and one Personal account.

Click on Create Account and Create one Business account and Personal Account.You can also create custom Account.

 

Select the Business Account you created now and click View/Edit Account and click Upgrade to Pro beside Account Type Business.Because Business Pro Account is required for Business(Merchant)  Account to process transactions.

 

4.Copy the API Credentials(username,password and signature) generated for  the Business Pro Account.This credentials will be used in the Salesforce Apex Class.

 

 

2) Set up Salesforce:

For Authorization Add https://api-3t.sandbox.com/2.0/ url into Remote Site Setting.

(i).Create a lightning component with a button Paypal Integration, onclick of a button a modal with a payment detail form opens up where the customer needs to fill the payment details. On Submitting the details the amount will be debited from the payee account and will be credited in the paypal account.

 

<aura:component controller="PaypalProcessorLightning" implements="force:appHostable,flexipage:availableForAllPageTypes, flexipage:availableForRecordHome,force:hasRecordId, forceCommunity:availableForAllPageTypes, force:lightningQuickAction" access="global" >
    <aura:attribute name="inp1" type="string" default="aslam"/>
    <aura:attribute name="inp2" type="string" default="bari"/>
    <aura:attribute name="inp3" type="string" default="US"/>
    <aura:attribute name="inp4" type="string" default="44"/>
    <aura:attribute name="inp5" type="string" default="433"/>
    <aura:attribute name="inp6" type="string" default="ajm"/>
    <aura:attribute name="inp7" type="string" default="CA"/>
    <aura:attribute name="inp8" type="string" default="4534"/>
    <aura:attribute name="inp9" type="string" default="4028398122647025"/>
    <aura:attribute name="inp10" type="string" default="Visa"/>
    <aura:attribute name="inp11" type="string" default=""/>
    <aura:attribute name="inp12" type="string" default="01"/>
    <aura:attribute name="inp13" type="string" default="2020"/>
    <aura:attribute name="inp14" type="string" default="abuy_1294681533_per@gmail.com"/>
    <aura:attribute name="inp15" type="string" default="100"/>
    <lightning:button aura:id="show" label="Paypal Integration" class="slds-button slds-button--brand buttontype" onclick="{!c.showModal}" />    
    <div aria-hidden="false" aura:id="popUpId" role="dialog" class="slds-modal slds-fade-in-open hideContent" style="padding-top:7rem">
        <div class="slds-modal__container">
            <div class="slds-modal__header">
                <div class="slds-button slds-button--icon-inverse slds-modal__close" onclick="{!c.hidePopup}">
                    <lightning:icon iconName="utility:close" size="medium" alternativeText="Indicates approval"/>
                    <span class="slds-assistive-text">Close</span>
                </div>
                <h2 style="font-weight:bolder;font-size:1rem">Complete Your Payment Details</h2>
            </div>
            <div class="slds-modal__content " style="padding:40px">
                <div class="row">
                    <h2 class="header"></h2>

                    <lightning:input  type="text" name="input1" label="First Name" value="{!v.inp1}" />
                    <lightning:input type="text" name="input2" label="Last Name" value="{!v.inp2}"/>
                    <lightning:input type="text" name="input3" label="Country" value="{!v.inp3}"/>
                    <lightning:input type="text" name="input4" label="Shipping Address1" value="{!v.inp4}"/>
                    <lightning:input type="text" name="input5" label="Shipping Address2" value="{!v.inp5}"/>
                    <lightning:input type="text" name="input6" label="Shipping City" value="{!v.inp6}"/>
                    <lightning:input type="text" name="input7" label="Shipping State" value="{!v.inp7}"/>
                    <lightning:input type="text" name="input8" label="Zip Code" value="{!v.inp8}"/>
                    <lightning:input type="text" name="input9" label="Card Number" value="{!v.inp9}"/>
                    <lightning:input type="text" name="input10" label="Card Type" value="{!v.inp10}"/>
                    <lightning:input type="text" name="input11" label="CVV" value="{!v.inp11}"/>
                    <lightning:input type="text" name="input12" label="Expiry Month" value="{!v.inp12}"/>
                    <lightning:input type="text" name="input13" label="Expiry Year" value="{!v.inp13}"/>
                    <lightning:input type="text" name="input14" label="Payer" value="{!v.inp14}"/>
                    <lightning:input type="text" name="input15" label="Amount" value="{!v.inp15}"/>
                </div>
            </div>
            <div class="slds-modal__footer" style="padding-top: 20px">
                <lightning:button variant="brand" label="Submit" title="Brand action" onclick="{! c.handleClick }" />
                <lightning:button aura:id="Cancel" label="Cancel" class="slds-button slds-button--brand buttontype" onclick="{!c.hidePopup}" />
            </div>
        </div>
    </div>
    <div class="slds-backdrop slds-backdrop--open hideContent" aura:id="popUpBackgroundId"></div>
</aura:component>

 

({ 
    showModal : function(component, event, helper) {
    $A.util.removeClass(component.find('popUpId'), 'hideContent');
    $A.util.removeClass(component.find('popUpBackgroundId'), 'hideContent');
},
  
  hidePopup : function(component){
      $A.util.addClass(component.find('popUpId'), 'hideContent');
      $A.util.addClass(component.find('popUpBackgroundId'), 'hideContent');
  },
  handleClick : function(component, event, helper) {
      var Firstname=component.get("v.inp1");
      var Lastname=component.get("v.inp2");
      var Country=component.get("v.inp3");
      var Address1=component.get("v.inp4");
      var Address2=component.get("v.inp5");
      var City=component.get("v.inp6");
      var State=component.get("v.inp7");
      var Zipcode=component.get("v.inp8");
      var Cardno=component.get("v.inp9");
      var Cardtype=component.get("v.inp10");
      var Cvv=component.get("v.inp11");
      var Expirymonth=component.get("v.inp12");
      var Expiryyear=component.get("v.inp13");
      var Payer=component.get("v.inp14");
      var Amount=component.get("v.inp15");
      var action = component.get("c.doDirectPayment");
        action.setParams({
            'fname':Firstname,
            'lastname':Lastname,
            'contry':Country,
            'add1':Address1,
            'add2':Address2,
            'shippingcity':City,
            'shippingstate':State,
            'zip':Zipcode,
            'cardnumber':Cardno,
            'cardtype':Cardtype,
            'cvvno':Cvv,
            'expmonth':Expirymonth,
            'expyear':Expiryyear,
            'pay':Payer,
            'amt':Amount
            
        });
        
        action.setCallback(this, function(a) {
            var state = a.getState();
            if (state === "SUCCESS") {
                alert(a.getReturnValue());
                
            }
        });
        
        $A.enqueueAction(action);
   
    }
 })
Paypal Integration Button on Lightning Component:

 

 

 

 

 

3) Run and Test

You can test the payment process by doing a sample payment providing payer bank details.Onclick of submit apex class will be called which will process the payment.

Log into your Paypal Account and check the balance from the Funding tab of Business Pro Account , it might be increased.

 

You will also be receiving a notification that the payment is completed successfully.

 

 

 

]]>
https://absyz.com/paypal-integration-with-salesforce/feed/ 0
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
Return Requested Data from Salesforce Multiple Data Sources using MuleSoft https://absyz.com/return-requested-data-from-salesforce-multiple-data-sources-using-mulesoft/ https://absyz.com/return-requested-data-from-salesforce-multiple-data-sources-using-mulesoft/#respond Wed, 27 Mar 2019 07:49:09 +0000 http://blogs.absyz.com/?p=9750

This blog walks you through the Integration between Salesforce and  Mulesoft Anypoint Studio. Consider a scenario that returns requested records from multiple Salesforce orgs. Consider Account object  with an External ID field  named as Account Code which  allows alphanumeric inputs. This flow will receive the Account Code as a JSON input via a HTTP listener and it will search for the Account Code from two Salesforce Orgs and return the Account and its related opportunity information as a response to the HTTP request.

Response Criteria:

  • If there is no record in Org 1 with the matching Account Code, then there should be an Error JSON returned to the user.
  • If there is no record in Org 2 with a matching Account Code, then the response should return with blank values in the JSON fields.
  • If there is record in both the Org’s with a matching Account Code, then the response should return combined records from both Org’s as a single JSON

Required Softwares:

  1. Anypoint Studio (version: 7.3.2)
  2. Postman

Mule Flow:

  1. In Anypoint Studio, Go to file -> select new Mule project -> Name the project.
  2. Now from Mule palette drag and drop the Listener followed by Set Variable component. So this is our main flow.
  3. In order to create seperate flows Fetch_From_org1 and Fetch_From_org2, drag and drop the Query Salesforce connector to the canvas away from the mainflow. This will automatically create a seperate flow.

Capture

flow1.PNG

flow3

So there are 2 flows named Fetch_From_org1 and Fetch_From_org2 other than the main flow. Fetch_From_org1 handles salesforce org1 and Fetch_From_org2  handles salesforce org2.

Fetch_From_org1 Process:

Use the Salesforce Query connector and fetch the Account and its related opportunity records with the matching Account code sent from the Postman http request. Add Transform Message Component to transform the query results to desired JSON format. Finally set the result payload to a variable named ‘org1_payload’. (In mule we can use the variable content through out the flow.)

Fetch_From_org2 Process:

Similarly query and transform the results of second org to required JSON format and set the result payload to another variable named ‘org2_payload’.

Main Flow:

Now the main flow starts with the listener followed by Set Variable component which stores the Account Code send in the request.

Postman Request:

Postman Request

Using Flow Reference component we can switch to another flow that exists in the same project. So refer these two flows in the main flow with the help of Flow Reference. Add the choice component to check the conditions(Choice component is similar to  if and else conditional statement). Here we have three conditions to check.

  • First check if the payload of org1,  stored in org1_payload variable is empty, then set another variable with error message. Now set the payload with that error message variable and use Transform Message component to transform the error message to JSON format.
  • Check if the payload of org2,  stored in org2_payload variable is empty if so then set another variable to null. Now set the payload with that null variable and use Transform Message component to transform the error message to JSON format.
  • This is default block where records exists  in both the orgs. Use Transform Message component to combine the payload from both  orgs to JSON format.

Code:

code1code2code3code4code5

Output for 3 conditions:

]]>
https://absyz.com/return-requested-data-from-salesforce-multiple-data-sources-using-mulesoft/feed/ 0
Continuous Integration in Salesforce using Jenkins and Bitbucket https://absyz.com/continuous-integration-in-salesforce-using-jenkins-and-bitbucket/ https://absyz.com/continuous-integration-in-salesforce-using-jenkins-and-bitbucket/#respond Fri, 08 Mar 2019 06:46:47 +0000 http://blogs.absyz.com/?p=9744

This blog takes you up through the advancement in continuous integration in Salesforce. I will walk through the approach of deploying only the changed element from bit bucket to destination org. The flow starts from polling the Bit bucket repository from Jenkins. If there is any change or new commit happens to the master branch of repository then Jenkins will take the changes from repository and deploy them to the org whose credentials are configured in Salesforce Migration Assistant.

Bitbucket Configuration:

Create a repository in bitbucket. Whenever there is any change in org, commit them to master branch of repository from eclipse with the help of EGit plugin.

bit2

With the help of Puttygen generate SSH key for authentication. Once the key is generated upload the public key by adding SSH key in  bitbucket settings.

bit1

Installation of Jenkins:

By default there is no support for GIT in Jenkins. So go to manage plugins and install the GIT plugin from the available plugins.

jen2

 

Create a new project in Jenkins and provide the bitbucket repository link in the  Source Code Management. Click on Add to create a credential. Use the private key of SSH key generated in puttygen which is stored with extension .ppk in local system.

jen

Either we can run the build manually or we can poll the bitbucket from Build Triggers in Jenkins.

So, in the example I am polling my bit bucket repository for every 5 minutes using Jenkins. So, whenever any commit happens in repository the changes will be deployed to the Salesforce org. For this, install additional plugin called ‘Salesforce Migration Assistant’ in Jenkins.

Steps to install the plugin:

  1. Go to Manage Plugins from Manage Jenkins.
  2. Go to the available tab and search for Salesforce Migration Assistant.
  3. Install the plugin.
  4. Configure the project in Jenkins.(Refer the below images)

So when any new commit happens in my master branch that change will be picked up by Jenkins after the polling time and deployed to the org whose credentials are mentioned in Salesforce Migration Assistant.

 

 

 

]]>
https://absyz.com/continuous-integration-in-salesforce-using-jenkins-and-bitbucket/feed/ 0
How to use external Id to Upsert data in salesforce using Talend https://absyz.com/how-to-use-external-id-to-upsert-data-in-salesforce-using-talend/ https://absyz.com/how-to-use-external-id-to-upsert-data-in-salesforce-using-talend/#respond Fri, 04 Jan 2019 12:35:53 +0000 http://blogs.absyz.com/?p=9697

Please find below links for the installation and introduction about Talend. https://blogs.absyz.com/2018/10/16/introduction-to-talend-integration-tool/ https://blogs.absyz.com/2018/10/17/how-to-export-data-from-salesforce-using-talend/

 

What is an external Id?

External Id is a very interesting feature given by Salesforce. It is very helpful when we are importing data from external system without duplicates. It references an ID (record Identifier) from external system. Only 3 types of fields are allowed to be used as an external Id.

They are

  • Email
  • Text
  • Number

Benefits of using External Id field:

 

  1. We can directly upsert data using external field. (Upsert is combination of insert and update, if the record already exists in the system it will update else it will insert a new record)
  2. We can create parent child record without querying for parent record Id
  3. We can use external Id fields in SOQL

How to make a field as an external Id?

While creating a field you will probably see the option to make a field external Id.

externalimage

 

How to upsert data with external Id in Talend?

Let see how we can upsert contacts by populating account lookup value using external id in talend.

I have created external id fields in contact and account.

External id field in contact: External_Number__c

External id field in Account: Account_Number_external__c

1.Create a new job in talend

job_Creation

2. Drag and drop tFileOutputDelimited from palette to workspace. Choose the file name and separator.

fileoutputdelimited

3. Drop and drop tMap from pallet to workspace. Add an output table and add columns in it. Make sure you are adding the API names from salesforce.

Tmap

4. Drag & drop tSalesforceOutput from pallet. Give your credential like username, password & security token. Select module as contact as we are doing the dml on contacts. Select output action as upsert, then you will find an option to select external key choose external key from the list.

SFOutput

5. Go to advanced settings you will see Relationship mapping for Upsert

lookupUpsert

Description for each column:

Column name of talend schema: select the column name where parent external key was copied.

Lookup field Name: API name of account lookup field from contact objects

Lookup relationship field name: relationship name for standard fields it is same lookup field. For custom fields append __r .

Module name: The parent object name

External id name: external id field from parent object. Here it is from account.

6. Save the changes and run the job.

The overall job looks like this : 

overallJob

 Results in Salesforce: 

result_sf

 

]]>
https://absyz.com/how-to-use-external-id-to-upsert-data-in-salesforce-using-talend/feed/ 0
Salesforce Integration with WordPress https://absyz.com/salesforce-integration-with-wordpress/ https://absyz.com/salesforce-integration-with-wordpress/#comments Mon, 22 Oct 2018 10:07:41 +0000 http://blogs.absyz.com/?p=9385

This post will help you to integrate Salesforce with WordPress and access the blogs in Salesforce from WordPress. Here we are getting the blog from a linked WordPress account and displaying it in a lightning modal popup in Salesforce.

Steps to be implemented:

1. Create an app in WordPress application manager [create App]. Redirect URL for this application will be the lightning component application URL which was created to run the whole process. After the application is created we can get the OAuth information which includes client id and client secret.

Below images will show how to create Application in wordpress.

2. Add the following endpoints in remote site settings in salesforce org.

  • https://public-api.wordpress.com/oauth2/authorize
  • https://public-api.wordpress.com/oauth2/token

remotesetting

3.  For better understanding I have a lightning component with three buttons which will authorize, get the access token and get the blogs from the wordpress.

Lightning Component:

[sourcecode language=”java”]
<aura:component controller=”accesstoken” implements=”force:appHostable, flexipage:availableForAllPageTypes, flexipage:availableForRecordHome, force:hasRecordId, forceCommunity:availableForAllPageTypes, force:lightningQuickAction” access=”global” >
<aura:attribute name=”url” type=”String” />
<aura:attribute name=”accesstoken” type=”String” />
<aura:attribute name=”content” type=”string” />
<aura:attribute name=”code” type=”string” />
<aura:handler name=”init” value=”{!this}” action=”{!c.doInit}”/>
<lightning:layout verticalAlign=”center” horizontalAlign=”center” >
<lightning:layoutitem padding=”around-small” >
<lightning:layout verticalAlign=”center” horizontalAlign=”center”>
<lightning:button label=”Authorize”
variant=”brand”
class=”slds-button slds-show”
onclick=”{!c.Authorize}”/>

<lightning:button label=”Request AccessToken”
variant=”brand”
class=”slds-button slds-show”
onclick=”{!c.GetAccess}”/>

<lightning:button label=”Get Blog”
variant=”brand”
class=”slds-button slds-show”
onclick=”{!c.send}”/>
</lightning:layout>
</lightning:layoutitem>
</lightning:layout>

<div class=”slds-hide” aura:id=”conmodal” style=”height: 1800px;”>
<section role=”dialog” tabindex=”-1″ aria-labelledby=”modal-heading-01″ aria-modal=”true” aria-describedby=”modal-content-id-1″ class=”slds-modal slds-fade-in-open”>
<div class=”slds-modal__container”>
<header class=”slds-modal__header” style=”background: #05668D;”>
<h2 id=”modal-heading-01″ class=”slds-text-heading_medium slds-hyphenate” style=”color:white;”><b>Blog</b></h2>
</header>
<div class=”slds-modal__content slds-p-around_medium” aura:id=”modal-content-id-1″>

<div class=”slds-container–center slds-container–small slds-m-top–small”>
<aura:unescapedHtml value=”{!v.content}”/>
</div>

</div>

<footer class=”slds-modal__footer slds-show” aura:id=”footer1″>

<button class=”slds-button button1″ aura:id=”button-modal-1″ style=”background: #05668D;color:white;width:130px;” onclick=”{!c.hideModal}”>
Close
</button>

</footer>
</div>
</section>
<div class=”slds-backdrop slds-backdrop_open”></div>
</div>

</aura:component>
[/sourcecode]

Below image is our lightning app with the three buttons.

cmp

4. On click of Authorize button we are hitting the wordpress endpoint for authorization.

Client side controller:

[sourcecode language=”java”]
Authorize: function(component, event, helper){
window.location.replace(‘https://public-api.wordpress.com/oauth2/authorize?’+’client_id=$clientid& amp; amp; redirect_uri=$redirecturl& amp; amp; response_type=code&amp;amp;scope=global’);

}
[/sourcecode]

 

auth

After approving we will be redirected to our lightning application. Now we need the Access Token to make API calls. For getting the access token we need the authorization code which we got in the redirected page URL.

5. Now click on the Request Access Token button.

Client side Controller:

[sourcecode language=”java”]
GetAccess: function(component, event, helper){
var action=component.get(“c.getaccess”);
action.setParams({‘code’:component.get(“v.code”)});
action.setCallback(this,function(response){
var state=response.getState();
if(state===’SUCCESS’)
{
var result=response.getReturnValue();
component.set(“v.accesstoken”,result);
}

});
$A.enqueueAction(action);

}
[/sourcecode]

Apex code:

[sourcecode language=”java”]
public static string getaccess(string code)
{
string clientid=$CLIENTID;
String redirect_uri = $APPURL;
String endPoint = ‘ https://public-api.wordpress.com/oauth2/token’;
string clientSecret=$CLIENTSECRET;
String requestTokenBody = ‘client_id=’+clientid+’&redirect_uri=’+redirect_uri+’&client_secret=’+
clientSecret+’&code=’+code+
‘&grant_type=authorization_code’;
Http http = new Http();
httpRequest httpReq = new httpRequest();
httpReq.setEndPoint(endPoint);
httpReq.setBody(requestTokenBody);
httpReq.setMethod(‘POST’);
HttpResponse response = new HttpResponse();
response = http.send(httpReq);
Map TokenInfo = (Map)JSON.deserializeUntyped(response.getBody());
string access=String.valueOf(TokenInfo.get(‘access_token’));
return access;
}
[/sourcecode]

6. Now in response we will get the access token. With the help of the access token we will get the blog details.

[sourcecode language=”java”]
send : function(component, event, helper) {

var action=component.get(“c.getBlogs”);
var access=component.get(“v.accesstoken”);
var url=”https://public-api.wordpress.com/rest/v1.1/me/posts”;
action.setParams({‘url’:url,’access’:access});
action.setCallback(this,function(response){
var state=response.getState();
if(state===’SUCCESS’)
{
var result=response.getReturnValue();
component.set(“v.content”,result);

}

});
$A.enqueueAction(action);

}
[/sourcecode]

The above example illustrate how to get the blog details. we are displaying the blog in the modal popup on click of Get Blog button.

[sourcecode language=”java”]
@auraenabled
public static string getBlogs(string url,string access)
{
Http http = new Http();
httpRequest httpReq = new httpRequest();
httpReq.setHeader(‘Authorization’,’Bearer ‘+access);
httpReq.setEndPoint(url);
httpReq.setMethod(‘GET’);
HttpResponse response = new HttpResponse();
response = http.send(httpReq);
Map lisdata=(Map)JSON.deserializeUntyped(String.valueOf(response.getBody()));
list values=(list)lisdata.get(‘posts’);
map smap=(Map)values[0];
string result=string.valueof(smap.get(‘content’));
return result;
}
[/sourcecode]

Displaying blog in Modal popup:

blogcontent

 

 

 

]]>
https://absyz.com/salesforce-integration-with-wordpress/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