+ Start a Discussion
Ryan Adams 173Ryan Adams 173 
Please help me resolve this challenge:


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);

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); 

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.


Best Answer chosen by Ryan Adams 173
Amit Singh 1Amit Singh 1
Hello Ryan,

Use below code for ParkLocator class.
public class ParkLocator {
    public static String[] country(String country){
        ParkService.ParksImplPort parks = new ParkService.ParksImplPort();
        String[] parksname = parks.byCountry(country);
        return parksname;
If this not resolves the problem then use a new Developer Org for completing the Challenge.

Let me know if this helps :)

Benjamin VisonBenjamin Vison 
I am trying to setup the OAuth process to get the access_token, specifically in PHP using this example (http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php). However, I don't know how to avoid the "Allow Access" page that shows up, I would like to be autimatically allowed so the application can continue and get the access_token... It would be a pain to have to manually allow access on every system I am planning on implementing this integration.. What am I missing?
Best Answer chosen by Benjamin Vison
Girish P
I dont know much about PHP, i am posting generic CURL statement that will be hlepful to understand.
  • Use Username and passwords to login to saleforce and get the access token, which when appended with REST calls to salesforce will give data back.For this someone has to create an App inside Salesforce whic will provide client secret and ID
curl https://<instance>.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=myclientid" -d "client_secret=myclientsecret" -d "mylogin@salesforce.com" -d "password=mypassword123456"

This will return JSON format data which will contain acceess_token to be used for further calls. and than use REST URL as follows

curl https://instance_name.salesforce.com/services/data/v38.0/ -H "Authorization: Bearer "THIS_IS_THE_ACCESS_TOKEN_RECEIVED_EARLIER>"
note - https://instance_name.salesforce.com/services/data/v38.0/  is the REST endpoint, i you have REST endpoints for salesforce you can replaces it as needed.
Giddamreddi ReddyGiddamreddi Reddy 
Project custom object records should only be seen by the owner of the record and users above the owner on the role hierarchy. However, for some Project records, the Training Coordinator must also have Read Only visibility to the Project record.

Create a custom picklist field on the Project object called “Priority” with the following values: High, Medium, and Low. Then create a criteria-based Sharing Rule for Project records where the Priority = High to share those records with the Training Coordinator role.
Best Answer chosen by Giddamreddi Reddy
Giddamreddi ReddyGiddamreddi Reddy
sonam see
1) u create project obj and API   project__C.
2) choose date type of project...text (not for any number)
3).in this create field priority with API priority__C.
4) in security controlls owd set  public read only..on project obj& also give sharing rule name   as ur wish.(i am given that private)
5) if  all ready exist  Training Coordinator in ur role highrarchey then don.t add..its..if not there add  Training Coordinator.on under ceo role. 
then u got 500 points........ok bye..



The documentation tells me that i can create a task object which is related to an custom object by using the WhatID field. Is i creat a task via DML and link it to my custom object ID the insert will fail because of 'Related To: Opportunity/Account ID: id value of incorrect type: a04A000000Bj8wJIAR'. 


Has someone experience with this and is there a way to do this without any custom objects...?




Best Answer chosen by Admin (Salesforce Developers) 

Check your custom object (Setup > Create > Objects > Edit (Object Name) ) and check the "Allow activities" checkbox. WIthout this box checked, you can't assign a task or event to that type of object.

Su Wang 3Su Wang 3 
Learning Salesforce DX, have downloaded the DreamHouse project from gitHub site, made a new branch of my own.  Then, in the Unit of "Create and Test Our Scratch Org", at the beginning, it says "Enter cat config/project-scratch-def.json" to see some of the options available. When I did this in the command line, I got "cat not recognized as an internal or external command".  Online articles say that "cat" is a Unix code, can't be used in Windows system.  Now, my question is what should I use in Windows?

Best Answer chosen by Su Wang 3
Use windows powershell.  WIndows 7 afterwards, it comes along with the windows.

Hope this helps. Please dont ask me about SFDX bcz i am myself struggling with the sfdx setup. :-P
Suresh MeghnathiSuresh Meghnathi 
How can we display thousands of records on the VF page without using the StandardSetController or Pagination?
Best Answer chosen by Suresh Meghnathi
Ajay K DubediAjay K Dubedi
Hi Suresh,

If your purpose is to display the records only, then you can set the readOnly='true' in apex:page tag. Using this, the SOQL limit will be relaxed from 50000 to 100000.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi
Sajjan T SSajjan T S 
I am trying to write a batch apex to schedule and delete cases that were created before 18 months along with the related files. Can someone help me with formulating the query, please?
Best Answer chosen by Sajjan T S
Sajjan T SSajjan T S
The working batch class code below:

Global class OldCaseDeleter implements Database.Batchable<SObject> {
    Public List<SObject> allRecords;
   Global Database.QueryLocator start(Database.BatchableContext BC) {
       String query = 'SELECT Id FROM Case WHERE CreatedDate = today and Exempt_From_Deletion__c = false';
       System.debug('query -> ' + query);
       return Database.getQueryLocator(query);
   Global void execute(Database.BatchableContext BC, List<SObject> records) {
       List<Case> caseList = (List<Case>)records;
       Set<Id> caseID = new Set<Id>();
       for(Case c: caseList) {
       List<ContentDocumentLink> files = [SELECT ContentDocumentId, LinkedEntityId
                                          From ContentDocumentLink
                                          WHERE LinkedEntityId IN :caseId];
       Set<Id> conId = new Set<Id>();
       for(ContentDocumentLink cd : files) {
       List<ContentDocument> files1 = [SELECT Id, Title
                               FROM ContentDocument
                               WHERE Id IN : conId];
           allRecords = new List<SObject>();
        Delete allrecords;
   Global void finish(Database.BatchableContext BC) {

Best Answer chosen by ashish jadhav 9
Amit Chaudhary 8Amit Chaudhary 8
What is a Record Type?

Allows you to define different sets of picklist values for both standard and custom picklists
Record Types help you implement your custom business processes

Why use Record Types?
To segment picklist values specific to business needs
Examples: segment by division, product line, or region
Easier administration – fewer fields to maintain

Business Process

What is a Business Process?
•Allows you to track separate sales, support, and lead lifecycles across different divisions, groups, or markets
Available Business Processes:

--> Sales Processes - Create different sales processes that include some or all of the picklist values available for the Opportunity Stage field
--> Support Processes - Create different support processes that include some or all of the picklist values available for the Case Status field
--> Lead Processes - Create different lead processes that include some or all of the picklist values available for the Lead Status field
--> Solution Processes - Create different solution processes that include some or all of the picklist values available for the Solution Status field

Please let us know if this will help you

Amit Chaudary
We have apex classes through which we send emails based on user action in force.com sites. It was working great until Friday, But yesterday when one of our customer try to submit application, they were getting error, In debug it says “SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, INVALID_TYPE: sObject type 'SalesforceIqDataSource' is not supported.: []”. I am pretty sure we did not change anything related to apex class, email template, vf page etc.. Does anyone know the reason or best way to fix this?
Best Answer chosen by SandyMeda
Signagelive DevelopmentSignagelive Development
Following on from Andrew's comment about Salesforce whitelisting the SalesforceIqDataSource for the site guest user I put in a ticket with Salesforce Support explaining the situation.

They whitelisted the SalesforceIqDataSource object for the site guest user for our organisation and I can confirm this has resolved the issue for us.

Therefore, for anyone still encountering this issue I was advise that you do the same thing and raise a ticket with Salesforce support.

Thanks everyone for the support on this.
Ram SRam S 
Hi All,
If any one finds difficulties in passing this challenge plz make changes in the VF page:
<apex:outputText value="{!sampleMergeField1}"/> <apex:outputText value="{!HTMLENCODE(sampleMergeField2)}" escape="false"/> <apex:outputText > {!sampleMergeField3} </apex:outputText> <script> document.write('{!JSINHTMLENCODE(sampleMergeField4)}'); </script> {!sampleMergeField5} <script> var x = '{!JSENCODE(sampleMergeField6)}'; </script> <apex:outputLabel value="{!HTMLENCODE(sampleMergeField7)}" escape="false"/>

Best Answer chosen by Ram S
Ram SRam S
<apex:outputText value="{!sampleMergeField1}"/> <apex:outputText value="{!HTMLENCODE(sampleMergeField2)}" escape="false"/> <apex:outputText > {!sampleMergeField3} </apex:outputText> <script> document.write('{!JSINHTMLENCODE(sampleMergeField4)}'); </script> {!sampleMergeField5} <script> var x = '{!JSENCODE(sampleMergeField6)}'; </script> <apex:outputLabel value="{!HTMLENCODE(sampleMergeField7)}" escape="false"/>