• Rupeshk67
  • NEWBIE
  • 15 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies
Hi Guys,
i have a rquirement where according to status of child object , toggle should be ON/OFF on parent object.

problem is i have many status values on child object and accordingly it should on/off the toggle.

i am planning to create separate checkboxes for different value . is there any other way to do it ??

Please let me know. Thanks
i have a batch class as below :
-------------------------------------------------------------
public class DM_TechAvailability implements Database.Batchable<sObject> {
    public DM_TechAvailability(){
        
    }
    
    public Database.QueryLocator start (Database.BatchableContext BC){
        string BLANK = '';
        string nulll = NULL;
        
        String query = 'select id, SV_Date_String__c, SV_Date__c from SV_Technician_Availability__c 
        where SV_Date__c  != null and (SV_Date_String__c =: BLANK or SV_Date_String__c =: nulll)';
        
        system.debug('1*'+Database.getQueryLocator(query));
        return Database.getQueryLocator(query);
    }
    public void execute(Database.BatchableContext BC, List<sObject> xTcope){
        List<SV_Technician_Availability__c> taList = new List<SV_Technician_Availability__c>();
        for(sObject eachTcope: xTcope){
            SV_Technician_Availability__c eachTA = (SV_Technician_Availability__c)eachTcope;
            eachTA.SV_Date_String__c = String.ValueOf(eachTA.SV_Date__c);
            taList.add(eachTA);
        }
        Database.update(taList, false);
    }
    public void finish(Database.BatchableContext Bc){
        
    }

}

Test Class which i have written as :
-----------------------------------------------
@isTest
public class Test_DM_TechAvailibility {

    @isTest
    public static void Test_method() {
        
        List<SV_Technician_Availability__c> techAvailabilityList = new List<SV_Technician_Availability__c>();
        for(Integer i=0; i<10; i++) {
            SV_Technician_Availability__c techAv = new SV_Technician_Availability__c();
            techAv.SV_Date_String__c = '';
            techAv.SV_Date__c = System.Today();
            techAvailabilityList.add(techAv);            
        }
        insert techAvailabilityList;
        
        system.debug('2*'+techAvailabilityList);
        
        test.startTest();
            DM_TechAvailability obj = new DM_TechAvailability();
            Database.executeBatch(obj);
        test.stopTest();
    }         
        
}

It covers only 50% and doesn't cover 'Execute' method of apex class.
Can you please help with your inputs how can i increase the percentage?

Thanks in Advance !
Rupesh
Hi ,
I have a requirement where if opportunity owner changed then two field values (stage and Order number) should pass to external system, let say aws.

Please suggest !
Thanks
Hi Guys,
I am trying to write a trigger on below reuirements and stuck at one point(how to add a word in between last name of a contact record once it is created).

Reuirements:
Write a trigger on Account object.
Criteria:- 
  1. Type:- “Customer
  2. Account Name end with “Your Name” . Example , “Telestra Rupesh”
Action on Trigger:-  
On Creation of account record, it should create one associated Contact record whenever above criteria meet.  
Example :- “Telestra Contact Rupesh

Please note: word 'contact' should come in middle of account name


Thanks,
Rupesh
i have a batch class as below :
-------------------------------------------------------------
public class DM_TechAvailability implements Database.Batchable<sObject> {
    public DM_TechAvailability(){
        
    }
    
    public Database.QueryLocator start (Database.BatchableContext BC){
        string BLANK = '';
        string nulll = NULL;
        
        String query = 'select id, SV_Date_String__c, SV_Date__c from SV_Technician_Availability__c 
        where SV_Date__c  != null and (SV_Date_String__c =: BLANK or SV_Date_String__c =: nulll)';
        
        system.debug('1*'+Database.getQueryLocator(query));
        return Database.getQueryLocator(query);
    }
    public void execute(Database.BatchableContext BC, List<sObject> xTcope){
        List<SV_Technician_Availability__c> taList = new List<SV_Technician_Availability__c>();
        for(sObject eachTcope: xTcope){
            SV_Technician_Availability__c eachTA = (SV_Technician_Availability__c)eachTcope;
            eachTA.SV_Date_String__c = String.ValueOf(eachTA.SV_Date__c);
            taList.add(eachTA);
        }
        Database.update(taList, false);
    }
    public void finish(Database.BatchableContext Bc){
        
    }

}

Test Class which i have written as :
-----------------------------------------------
@isTest
public class Test_DM_TechAvailibility {

    @isTest
    public static void Test_method() {
        
        List<SV_Technician_Availability__c> techAvailabilityList = new List<SV_Technician_Availability__c>();
        for(Integer i=0; i<10; i++) {
            SV_Technician_Availability__c techAv = new SV_Technician_Availability__c();
            techAv.SV_Date_String__c = '';
            techAv.SV_Date__c = System.Today();
            techAvailabilityList.add(techAv);            
        }
        insert techAvailabilityList;
        
        system.debug('2*'+techAvailabilityList);
        
        test.startTest();
            DM_TechAvailability obj = new DM_TechAvailability();
            Database.executeBatch(obj);
        test.stopTest();
    }         
        
}

It covers only 50% and doesn't cover 'Execute' method of apex class.
Can you please help with your inputs how can i increase the percentage?

Thanks in Advance !
Rupesh
Hi Guys,
I am trying to write a trigger on below reuirements and stuck at one point(how to add a word in between last name of a contact record once it is created).

Reuirements:
Write a trigger on Account object.
Criteria:- 
  1. Type:- “Customer
  2. Account Name end with “Your Name” . Example , “Telestra Rupesh”
Action on Trigger:-  
On Creation of account record, it should create one associated Contact record whenever above criteria meet.  
Example :- “Telestra Contact Rupesh

Please note: word 'contact' should come in middle of account name


Thanks,
Rupesh
I'm trying to validate the modue "Create Reports and Dashboards for Sales and Marketing Managers -- Group and Categorize Your Data". I keep get the error message "Challenge Not yet complete... here's what's wrong:  The 'Pipeline Matrix Report Current and 2 FY' report does not appear to have the bucket field configured correctly." Has anyone else experienced this? There isn't anything I can find that is wrong with my configuration.
Please help me resolve this challenge:

https://trailhead.salesforce.com/modules/apex_integration_services/units/apex_integration_soap_callouts

The Challenge is as follows:

Generate an Apex class using WSDL2Apex and write a test class.
Generate an Apex class using WSDL2Apex for a SOAP web service, write unit tests that achieve 100% code coverage for the class using a mock response, and run your Apex tests.

Use WSDL2Apex to generate a class called 'ParkService' in public scope using this WSDL file. After you click the 'Parse WSDL' button don't forget to change the name of the Apex Class Name from 'parksServices' to 'ParkService'.
Create a class called 'ParkLocator' that has a 'country' method that uses the 'ParkService' class and returns an array of available park names for a particular country passed to the web service. Possible country names that can be passed to the web service include Germany, India, Japan and United States.
Create a test class named ParkLocatorTest that uses a mock class called ParkServiceMock to mock the callout response.
The unit tests must cover all lines of code included in the ParkLocator class, resulting in 100% code coverage.
Run your test class at least once (via 'Run All' tests the Developer Console) before attempting to verify this challenge.

The error I receive when checking the challencge is:

Challenge Not yet complete... here's what's wrong:
Executing the 'country' method on 'ParkLocator' failed. Make sure the method exists with the name 'country', is public and static, accepts a String and returns an array of Strings from the web service.

Here is the code I am using:
public class ParkLocator {
    public static String[] country(String ctry) {
        ParkService.ParksImplPort prk = 
            new ParkService.ParksImplPort();
        return prk.byCountry(ctry);
    }
}

and
 
@isTest
global class ParkServiceMock 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) {
        // start - specify the response you want to send
        ParkService.byCountryResponse response_x = 
            new ParkService.byCountryResponse();
            
        List<String> myStrings = new List<String> {'Park1','Park2','Park3'};
    
        response_x.return_x = myStrings;
        // end
        response.put('response_x', response_x); 
   }
}

and
 
@isTest
private class ParkLocatorTest  {
    @isTest static void testCallout() {              
        // This causes a fake response to be generated
        Test.setMock(WebServiceMock.class, new ParkServiceMock());
        // Call the method that invokes a callout
        List<String> result = new List<String>();
        List<String> expectedvalue = new List<String>{'Park1','Park2','Park3'};
        
        result = ParkLocator.country('India');
        // Verify that a fake result is returned
        System.assertEquals(expectedvalue, result); 
    }
}

Any help which can be provided is greatly appreciated.  If you could advise me at raadams173@gmail.com if you reply with a solution, I can log in to check it.

Thanks.

Ryan