Data Integration Specialist Superbadge

Salesforce Super-Badge Solution



Data Integration Specialist Superbadge || Solutions || Easy Steps||All Challenges (1-10)


                           Data Integration Specialist

 Challenge 1-(Quiz:Credential Security) :- 
  1. Ans:-All of the above.
  2. Ans:-Read the Salesforce Help article for the superbadge,review all relevant Salesforce Help documentation, and then log a case.
  3. Ans:-Submit a case with Trailhead Help with information about the shared solution so the Trailhead credential Security team can  follow up.
  4. Ans:-Sharing Solutions is in violation of the Trailhead Certification  Agreement..
  5. Ans:-All of the above. 
          Now, Check the challenge😃   

Challenge 2-(Configure outbound application and integration Security) :- 


Step-1:-Install the unlocked package with package id: 04t6g000008arl1AAA(For All Users).
Step-2:-Then go to Setup-->Remote Site Settings-->New Remote Site.
                Fill Remote Site Name -->BillingService
                      Remote Site URL-->http://sb-integration-bs.herokuapp.com
                      Active-->Checked (then click on save button).
Step-3:-Setup-->Custom Settings-->Click on Manage(Service Credentials)-->New
             Name-->BillingServiceCredential
             Password-->bsPass1
             Username-->bsUser1(then click on save button).
Step-4:-Setup-->Named Credential-->New Named Credential
             Label-->ProjectService
             Name-->ProjectService
             Url-->https://sb-integration-pms-2.herokuapp.com/projects
             Identity Type-->Named Principal
             Authentication Protocol-->Password Authentication
             Username-->pmsUser1
             Password-->pmsPass1
              Generate Authentication Header-->Checked(then click on save button).
            
                Now, Check the challenge😃

Challenge 3-(Configure inbound Integration Security) :- 


Step-1:-Setup-->App Manager-->New Connected App
Step-2:-Connected App Name-->ProjectService
            API Name-->ProjectService
            Contact Email-->Your Email Id
            Enable OAuth Settings-->Checked
            CallBack URL-->https://sb-integration-pms-2.herokuapp.com/oauth/_callback
            Selected OAuth Scopes-->add both( Full Access and Perform requests at any time).
            Then Save.
Step-3:-After saving, we can see Consumer Key and Consumer Secret ,so copy both of them.
Step-4:-(do this step-4 after few minutes after processing step-2 otherwise we may get error
              as it will take time to impact)
             After few minutes, click on this link 'https://sb-integration-pms-2.herokuapp.com'
              then click on 'log into your DE org'--->Allow Access
             Paste the copied Consumer Key and Consumer Secret---->Submit
            Dont click on 'Test connected App' button before clicking that button, copy the Token  and follow below step.

 Step-5:-In other tab,open Setup-->Custom Settings-->Manage(ServiceTokens)-->New
                                          Name-->ProjectServiceToken
                                          Token-->Paste the copied token in Step-4(then click on save button)
                    After Saving,click on 'Test Connected App' button-->Allow Access(Allow).
                   Finally, if it shows   'Your connected app appears to be functioning properly' then everything went well.
                        Now, Check the challenge😃.
                                           
            

Challenge 4 -(Synchronize Salesforce opportunity data with Square Peg's PMS external system) :- 


Step-1:-Setup-->Object Manager-->Opportunity-->Fields and Relationships-->Type-->New Value-->New Project-->Save

Step-2:-
    Developer Console-->Apex class(ProjectCalloutService):-

public class ProjectCalloutService {
    //method to be invoked by ProcessBuilder apex
    @InvocableMethod
    public static void postOpportunityToPMS(List<Id> oppoIds){
        Opportunity opp = [SELECT Id,Name,Account.Name,CloseDate,Amount FROM Opportunity WHERE Id = :oppoIds[0]];
        String serviceToken = ServiceTokens__c.getValues('ProjectServiceToken').Token__c;
        
        String jsonInput = '{\n' +
            ' "opportunityId" : "'+opp.Id+'",\n'+
            ' "opportunityName" : "'+opp.Name+'",\n'+
            ' "accountName" : "'+opp.Account.Name+'",\n'+
            ' "closeDate" : "'+String.ValueOf(opp.CloseDate).mid(0,10)+'",\n'+   
            ' "amount" : "'+opp.Amount+'"\n}';
            
        System.enqueueJob(new QueueablePMSCall(serviceToken, jsonInput, opp.Id));
    }    
    
    class QueueablePMSCall implements System.Queueable, Database.AllowsCallouts{
        private String serviceToken;
        private String jsonInput;
        private Id oppId;
        
        public QueueablePMSCall(String serviceToken, String jsonInput, Id oppId){
            this.serviceToken = serviceToken;
            this.jsonInput = jsonInput;
            this.oppId = oppId;
        }
        
        public void execute(QueueableContext qc){
            postToPMS(serviceToken, jsonInput, oppId);        
        }
    }
    
    @Future(callout=true)
    private static void postToPMS(String serviceToken, String jsonInput, Id oppoId){
        HTTPRequest req = new HTTPRequest();
        req.setEndPoint('callout:ProjectService');
        req.setMethod('POST');
        req.setHeader('token',serviceToken);
        req.setHeader('Content-Type', 'application/json;charset=UTF-8');
        req.setBody(jsonInput);
        
        HTTP http = new HTTP();
        HTTPResponse res = http.send(req);
        
        Opportunity opp = new Opportunity(Id=oppoId);
        if(res.getStatusCode() == 201){
            opp.StageName = 'Submitted Project';                
            System.debug('Success: ' + res.getStatus());
        }else{
            opp.StageName = 'Resubmit Project';
            System.debug('Failure: ' + res.getStatusCode() + ' ' + res.getStatus());
        }
        update opp;
    }
}    

Step-3:- Setup-->Process Builder-->New
                Process Name-->Anything as you like
                The Process starts when-->A record changes-->Save

 Step-4:-   Add Object as shown below then save


                
Step-5:-Add criteria
                Criteria Name--->Any Name
                Set Conditions
                
  1. Type->equals->picklist->New Project
  2. StageName->IsChanged->Boolean->true
  3. StageName->equals->picklist->Closed Won




       

                             

               



After processing as above,save it.

Step-6:-Immediate Actions-->Action Type-->Apex
                Action Name-->Post Opportunity To PMS


 Click on Save and Activate it.

Now, Check the challenge😃.


Challenge 5 -(Test outbound Apex REST callout logic):- 


Step-1:-Test class-ProjectCalloutServiceMock

@isTest
global class ProjectCalloutServiceMock implements HttpCalloutMock{
   //Implement http mock callout here
   // Implement this interface method
   global HTTPResponse respond(HTTPRequest request){
       // Create a fake response
       HttpResponse response = new HttpResponse();
       response.setHeader('Content-Type', 'application/json');
       response.setStatus('OK');
       response.setStatusCode(201);
              
       return response;
   }
}


Step-2:- Test class(ProjectCalloutServiceMockFailure)

@isTest
global class ProjectCalloutServiceMockFailure implements HttpCalloutMock{
   //Implement http mock callout here
   // Implement this interface method
   global HTTPResponse respond(HTTPRequest request){
       // Create a fake response
       HttpResponse response = new HttpResponse();
       response.setHeader('Content-Type', 'application/json');
       response.setStatus('Bad Response');
       response.setStatusCode(500);
              
       return response;
   }
}


Step-3:-Test Setup(ProjectCalloutServiceTest)

@isTest
private class ProjectCalloutServiceTest {
  //Implement mock callout tests here
   @testSetup static void testSetupdata(){
        //create the opportunity record
        Opportunity opp1 = new Opportunity();
        opp1.Name = 'Test Opp1';
        opp1.Type = 'New Project';
        opp1.Amount = 100;
        opp1.CloseDate = Date.today();
        opp1.StageName = 'Submitted Project';
        insert opp1;
        //create the opportunity record
        Opportunity opp2 = new Opportunity();
        opp2.Name = 'Test Opp2';
        opp2.Type = 'New Project';
        opp2.Amount = 200;
        opp2.CloseDate = Date.today();
        opp2.StageName = 'Resubmit Project';
        insert opp2;
        //create the Custom Settings
        ServiceTokens__c servToken = new ServiceTokens__c();
        servToken.Name = 'ProjectServiceToken';
        servToken.Token__c = 'qwertyuiopnjhgft';
        insert servToken;
    }
  
  @isTest
  static void testSuccessMessage(){
      Opportunity opp = [Select Id, Name FROM Opportunity WHERE Name = 'Test Opp1' Limit 1];
      List<Id> lstOfOppIds = new List<Id>();
      lstOfOppIds.add(opp.Id);
      // Set mock callout class
      Test.setMock(HttpCalloutMock.class, new ProjectCalloutServiceMock());
      // This causes a fake response to be sent
      // from the class that implements HttpCalloutMock. 
      Test.startTest();
          ProjectCalloutService.postOpportunityToPMS(lstOfOppIds);
      Test.stopTest();    
      // Verify that the response received contains fake values        
      opp = [select StageName from Opportunity where id =: opp.Id];
      System.assertEquals('Submitted Project',opp.StageName);     
  }
  
  @isTest
  static void testFailureMessage(){
      Opportunity opp = [Select Id, Name FROM Opportunity WHERE Name = 'Test Opp2' Limit 1];
      List<Id> lstOfOppIds = new List<Id>();
      lstOfOppIds.add(opp.Id);
      // Set mock callout class
      Test.setMock(HttpCalloutMock.class, new ProjectCalloutServiceMockFailure());
      // This causes a fake response to be sent
      // from the class that implements HttpCalloutMock. 
      Test.startTest();
          ProjectCalloutService.postOpportunityToPMS(lstOfOppIds);
      Test.stopTest();    
      // Verify that the response received contains fake values        
      opp = [select StageName from Opportunity where id =: opp.Id];
      System.assertEquals('Resubmit Project',opp.StageName);
  }
}

Now,Run Test

Now, Check the challenge😃.


Challenge 6 -(Synchronize external PMS system project data with Salesforce):- 


Step-1:-Setup-->Object Manager-->Fields and relationships-->New
                Data Type-->Percent-
                Field Label-->Decimal Percent
                Save
Step-2:-Apex Class(ProjectRESTService)

@RestResource(urlMapping = '/project/*')
global with sharing class ProjectRESTService {
    @HttpPost
    global static String postProjectData(String ProjectRef, String ProjectName, String OpportunityId,
                                       Date StartDate, Date EndDate, Double Amount, String Status){
        String retMsg = 'Error';
                
        SavePoint sp1 = Database.setSavePoint();
        try{
            List<Opportunity> lstOfOpps = new List<Opportunity>();
            
            if(OpportunityId != null && OpportunityId.trim().length() > 0){
                Opportunity opp = [SELECT Id, DeliveryInstallationStatus__c, Discount_Percent__c FROM Opportunity WHERE Id = :OpportunityId];
                opp.DeliveryInstallationStatus__c = 'In progress';
                                
                lstOfOpps.add(opp);
            }
            UPDATE lstOfOpps;
            
            List<Project__c> lstOfRrjts = new List<Project__c>();
            
            Project__c prjt = new Project__c();
            prjt.ProjectRef__c = ProjectRef;
            prjt.Name = ProjectName;
            prjt.Opportunity__c = OpportunityId;
            prjt.Start_Date__c = StartDate;
            prjt.End_Date__c = EndDate;
            prjt.Billable_Amount__c = Amount;
            prjt.Status__c = Status;
            
            lstOfRrjts.add(prjt);
            
            UPSERT lstOfRrjts;
            
            retMsg = 'OK';
        }catch(Exception ex){
            Database.rollback(sp1);
            retMsg = ex.getMessage();
        }
        return retMsg;
    }
}

Now, Check the challenge😃.


Challenge 7 -(Test inbound Apex REST service logic):- 


Step-1:- Test Class(ProjectRESTServiceTest)

@isTest
private class ProjectRESTServiceTest {
    @testSetup
    static void loadServiceData(){
        Opportunity opp = new Opportunity();
        opp.Name = 'Test Opportunity';
        opp.DeliveryInstallationStatus__c = 'In progress';
        opp.CloseDate = (Date.today()).addDays(20);
        opp.StageName = 'Submitted Project';
        INSERT opp;
        
        Project__c prjt = new Project__c();
        prjt.ProjectRef__c = 'ProjectRef';
        prjt.Name = 'ProjectName';
        prjt.Opportunity__c = opp.Id;
        prjt.Start_Date__c = Date.today();
        prjt.End_Date__c = (Date.today()).addDays(10);
        prjt.Billable_Amount__c = 1000;
        prjt.Status__c = 'Running';
        INSERT prjt;
    }
    
    @isTest    
    static void testProjectRESTService(){
        Project__c prjt = [SELECT Id, ProjectRef__c, Name, Opportunity__c, Start_Date__c, End_Date__c, Billable_Amount__c, Status__c FROM Project__c LIMIT 1];
        Test.startTest();
        Opportunity opp = [SELECT Id FROM Opportunity LIMIT 1];
        System.assertEquals(1,[SELECT count() FROM Opportunity]);                          
        String returnMessage = ProjectRESTService.postProjectData('ProjectRef', 'ProjectName', String.valueOf(opp.Id),  Date.today(), Date.today(), 1000, 'Running');                          
        Test.stopTest();
    }
}

click on RunTest button.

Now, Check the challenge😃.


Challenge 8 -(Synchronize Salesforce project data with Square Peg's external billing system):- 


Step-1:-

Click on this wsdl link.
After opening,Ctrl+S ,Save with 'BillingServiceProxy' Name with file type XML.

Step-2:-
                Setup-->Apex Classes-->Generate from WSDL
                Add the wsdl file 'BillingServiceProxy'-->Parse WSDL
                Apex Class Name-->BillingServiceProxy
                Click on Generate Apex code.
Step-3:-Setup-->Apex classes-->Delete 'AsyncBillingServiceProxy' class.

Step-4:-Apex class(BillingCalloutService)
    
public class BillingCalloutService {
    @future(callout = true)
    public static void callBillingService(String projectRef, Decimal billingAmount){
        ServiceCredentials__c srvcCrd = ServiceCredentials__c.getValues('BillingServiceCredential');
                
        BillingServiceProxy.project projectInst = new BillingServiceProxy.project();
        projectInst.username = srvcCrd.Username__c;
        projectInst.password = srvcCrd.Password__c;
        projectInst.billAmount = billingAmount;
        
        BillingServiceProxy.InvoicesPortSoap11 invPortSoapInst = new BillingServiceProxy.InvoicesPortSoap11();
        String response = invPortSoapInst.billProject(projectInst);
        
        List<Project__c> lstOfProjects = new List<Project__c>();
        if(response != null && response.equalsIgnoreCase('OK')){
            List<Project__c> lstOfPrjts = [SELECT Status__c FROM Project__c WHERE ProjectRef__c = :projectRef];
            for(Project__c prjt : lstOfPrjts){
                prjt.Status__c = 'Billed';
                
                lstOfProjects.add(prjt);
            }
            
            UPDATE lstOfProjects;
        }
    }
}

Step-5:-Trigger class(ProjectTrigger)

trigger ProjectTrigger on Project__c (after update) {
    if(Trigger.isAfter && Trigger.isUpdate){
        for(Project__c prjt : Trigger.new){
            if(prjt.Status__c != null && prjt.Status__c.equals('Billable')){
                BillingCalloutService.callBillingService(prjt.ProjectRef__c, prjt.Billable_Amount__c);
            }
        }
    }
}

Challenge 9 -(Test outbound Apex SOAP callout logic):- 


Step-1:-Test class(BillingCalloutServiceMock)

@isTest
global class BillingCalloutServiceMock implements WebServiceMock {
   global void doInvoke(Object stub,Object request,Map<String, Object> response,String endpoint,String soapAction,String requestName,String responseNS, String responseName,String responseType){
           BillingServiceProxy.billProjectResponse_element response_x = new BillingServiceProxy.billProjectResponse_element();
           response_x.status = 'OK';
           response.put('response_x', response_x);
    }
}

Step-2:-Apex class(BillingCalloutServiceMockFailure)

global class BillingCalloutServiceMockFailure implements WebServiceMock {
    global void doInvoke(Object stub,Object request,Map<String, Object> response,String endpoint,String soapAction, String requestName, String responseNS,String responseName,String responseType) {
        BillingServiceProxy.billProjectResponse_element response_x = new BillingServiceProxy.billProjectResponse_element();
        response_x.status = 'ERROR';
        response.put('response_x', response_x);
    }
}


Step-3:-Test class(BillingCalloutServiceTest)

@isTest
private class BillingCalloutServiceTest {
  @testSetup static void loadData(){
        
        Opportunity oppo = new Opportunity();
        oppo.Name = 'TestOpp1';
        oppo.CloseDate = Date.today();
        oppo.StageName = 'Prospecting';
        insert oppo;
        
        Project__c proj = new Project__c();
        proj.Name = 'TestProj1';
        proj.Billable_Amount__c = 1000;        
        proj.ProjectRef__c = 'TestRef1';
        proj.Status__c = 'Running';
        proj.Opportunity__c = oppo.Id;
        insert proj;
        
        ServiceCredentials__c servCred = new ServiceCredentials__c();
        servCred.Name = 'BillingServiceCredential';
        servCred.Username__c = 'usr1';
        servCred.Password__c = 'pwd1';
        insert servCred;
    }
    
    @isTest static void testCalloutSuccess(){
        Test.setMock(WebServiceMock.class, new BillingCalloutServiceMock()); 
        List<Project__c> prjt = [SELECT Status__C FROM Project__c WHERE ProjectRef__c = 'TestRef1'];
        System.assertEquals(1, prjt.size());
        Test.startTest(); 
            prjt[0].Status__c = 'Billable';
            update prjt;
        Test.stopTest();
    }
    
    @isTest static void testCalloutFailure(){
        Test.setMock(WebServiceMock.class, new BillingCalloutServiceMockFailure()); 
        List<Project__c> prjt = [SELECT Status__C FROM Project__c WHERE ProjectRef__c = 'TestRef1'];
        System.assertEquals(1, prjt.size());
        Test.startTest(); 
            prjt[0].Status__c = 'Running';
            update prjt;
        Test.stopTest();
    }
}

click on RunTest button.

Now, Check the challenge😃.

Challenge 10 -(Synchronize Salesforce project data with Square Peg's external billing system):- 


Step-1:-Setup-->External Data Sources-->New External Data Source
                
External Data SourceBillingService
NameBillingService
TypeSalesforce Connect OData 2.0
URLhttps://sb-integration-is-2.herokuapp.com/odata
Identity TypeAnonymous
Authentication ProtocolNo Authentication
Save and click on 'Validate and Sync' button.

Step-2:-Setup-->External Object-->invoices-->Custom Fields & Relationships
                click on 'projectRef' field-->edit-->change field type-->Indirect Lookup Relationship
                Related To-->Project-->Next
                Target Field-->ProjectRef__c-->Next-->Save
                
Step-3:- Setup-->Object Manager-->Open 'Project' Object
                Page Layouts-->related list-->drag 'invoices' to related list as shown below.
Add the 3 fields as shown below and save.






Save it.

Now, Check the challenge😃.



Hope. this blog help everyone who  wanted to work with Data Integration Specialist Superbadge.
                                                    Thanking You😀
                                                        Mukesh Kumar.



Comments

  1. Glad to review this. It was very helpful and we can learn easily as it was designed very clearly. I can refer my friends/colleagues also. Please design more blogs like this so that it'll be more helpful to everyone.....

    ReplyDelete
  2. thankyou so much for the solutions!!

    ReplyDelete
  3. ITS is DICOUNT Percent not decimal percent Enjoy😀

    ReplyDelete
  4. challenge 8 [ error in (Project Trigger class) please tell me it shows INVALID PARAMETER ]

    ReplyDelete
    Replies
    1. this the code trigger ProjectTrigger on Project__c (after update) {
      if(Trigger.isAfter && Trigger.isUpdate){
      for(Project__c prjt : Trigger.new){
      if(prjt.Status__c != null && prjt.Status__c.equals('Billable')){
      BillingCalloutService.callBillingService(prjt.ProjectRef__c, prjt.Billable_Amount__c);
      }
      }
      }
      }

      please se and fix the issues it shows a Invalid Parameter Value

      Delete
    2. your code parameters here looks good, Can you also share your BillingCalloutService class to check this method is callBillingService properly written

      Delete
  5. Challenge 6 is not working, tried a lot of times. Showing below error always.
    "Challenge Not yet complete... here's what's wrong:
    The 'ProjectRESTService' Apex REST service does not appear to be working properly. Calling the service either didn't update the opportunity correctly, return the string 'OK', create an associated project correctly or function correctly in general."

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  6. very good explanation thank u so much

    ReplyDelete
  7. Error: Compile Error: Variable does not exist: ServiceTokens__c at line 6 column 31

    the code you post for challenge 4 (projectcalloutservice)

    ReplyDelete
  8. This is really helpful. Thank you so much for this content. do you have created same type of content for Advanced Apex Specialist solution as well. if yes please share

    ReplyDelete
  9. Have solved challenge 1-10 with this guide successfully for data integration specialist superbadge

    ReplyDelete
  10. opp1.Discount_Percent__c =100;

    ReplyDelete
  11. Digital Transformation in India: A Landscape of Growth
    India's business landscape is undergoing a rapid digital transformation. Companies are adopting digital transformation services to optimize operations, enhance customer experience and gain a competitive edge. These services encompass a wide range of solutions ranging from cloud migration and data analytics to mobile app development and automation.

    ReplyDelete
  12. Unlocking Efficiency: The Power of System Integration Services
    System integration services refer to the process of combining various technology systems, software applications, and resources into a cohesive and unified form within an organization. The goal of these services is to streamline business operations, enhance efficiency, and improve communication and collaboration across different departments and systems. System integration involves linking disparate systems together to enable seamless data exchange and workflow automation, ultimately helping businesses leverage technology to achieve their strategic objectives.

    ReplyDelete
  13. System Integration: Building Bridges for Seamless IT Operations
    System integration services, such as IT Matching, connect the various computer programs and databases they use, allowing them to work together. This means information flows easily between them, saving you time and effort.

    ReplyDelete
  14. Unleashing Business Potential: Digital Transformation Services in India
    Digital transformation services in India have emerged as pivotal drivers of organizational growth and innovation in today's rapidly evolving business landscape. With the increasing digitization of industries and the pervasive influence of technology, businesses across India are embracing digital transformation to stay relevant and competitive. These services encompass a wide range of strategies, technologies, and processes aimed at leveraging digital tools to drive organizational change, enhance operational efficiency, and deliver superior customer experiences. From adopting cloud computing and data analytics to embracing artificial intelligence and machine learning, Indian businesses are harnessing the power of digital transformation to innovate, adapt to market dynamics, and gain a competitive edge. With the relentless pace of technological advancement and the growing demand for seamless digital experiences, digital transformation services in India are playing a transformative role in shaping the future of business across the country.

    ReplyDelete
  15. Unlocking Operational Efficiency: The Role of System Integration Services
    System integration services are essential for organizations looking to optimize their IT infrastructure and enhance operational efficiency. These services involve integrating various systems, applications, and technologies to ensure seamless communication and data exchange. Whether it's connecting disparate applications, consolidating data from multiple sources, or integrating IoT devices, system integration enables organizations to streamline workflows and improve decision-making. By leveraging these services, businesses can adapt to changing technology landscapes, enhance collaboration, and drive digital transformation initiatives effectively.

    ReplyDelete
  16. System integration services involve the process of connecting various disparate IT systems and software applications within an organization to ensure seamless communication and data sharing. This involves integrating hardware, software, networking technologies, and other components to create a cohesive and efficient system. System integration aims to streamline operations, improve productivity, enhance data accuracy, and facilitate better decision-making by enabling different systems to work together harmoniously. It often involves tasks such as data migration, application integration, API development, and customization to meet specific business needs. Overall, system integration services play a crucial role in optimizing organizational processes and leveraging technology to achieve strategic goals.

    ReplyDelete

Post a Comment