+ Start a Discussion
Minkesh JAHERALYMinkesh JAHERALY 
Hello,
I tried many times... but receive the same error message : "Challenge Not yet complete... here's what's wrong: 
Formula in custom field 'Account Annual Revenue' is not correct. Check the instructions."
I followed all instructions & get the right results. It's a basic & very simple formula.
Do someone else encounter the same issue ? Any solution ?
Best Answer chosen by Minkesh JAHERALY
Minkesh JAHERALYMinkesh JAHERALY
I created a new Trailhead playground... entered exactly the same formula... and finaly could validated the challenge
EmilienGuichardEmilienGuichard 
Hi all,

I'm stuck in the Apex Integration Services - Apex SOAP Callouts challenge with the following message "The Apex class 'ParkLocator' does not appear to be calling the SOAP endpoint.".

Could you please advise ?
Best Answer chosen by EmilienGuichard
Jeff DouglasJeff Douglas
Try changing line #3 in ParkLocator to: 
ParkService.ParksImplPort park = new ParkService.ParksImplPort();
Sorry... it's case sensitive.  :(

If you had entered ParkService originally it would have generated this code in this manner. Not sure if it didn't overwrite these classes or something.

Jeff Douglas
Trailhead Developer Advocate
Laura Greer 14Laura Greer 14 
Hi,
Th instructions don't make sense to me in Exercise 3 (Example 3: Finding Distinct Objects Using the Power of One) of the Use Formula Fields module - https://trailhead.salesforce.com/en/trails/force_com_admin_intermediate/modules/point_click_business_logic/units/formula_fields?trailmix_creator_id=00550000006HirqAAC&trailmix_id=admin-exam.

It says to create a formula field on the User object for reporting the distinct number of unique users for opportunities. 

It goes on to instruct as folllows...
Create an Opportunities report and drag your Unique Users field onto the report from the left panel. You should see something similar to the following:
User-added image

I don't understand how adding the Unique Users field to the user object would allow me to add that column on an opportunity record. It seems like the two objects would need to be joined. What am I missing?

Thanks,
Laura
Best Answer chosen by Laura Greer 14
Alain CabonAlain Cabon
Hi,

It is not really a formula but a "constant value" (value: 1) and the exercise is still working (I just made a test).

To write this formula, create a custom formula field on the User object. Name it Unique Users, give it a Number return type, and select 0 from the Decimal Places drop-down list. Click Next to open the formula editor. For this formula, you don’t need to insert any fields, operators, or functions. Instead, enter the number 1.

Search the field: unique

User-added image

User-added image


 
SFDC coderSFDC coder 
Hi all,

While exploring the salesforce features i came across supoort process
  1. Support processes are used to add or remove the status values of cases
  2. After a support process has been created its assigned to a record type
Now my confusion  is ,why  are we  using support processes to add/remove the picklist values? as It can also be achieved when creating record types.
Record types allow us to customize the picklist values then why wud we use this solution process feature?

Best Answer chosen by SFDC coder
ShashForceShashForce
Hi,

Support Process is only for the "Status" picklist, as you might know. The picklist values available in the status of a case record type determine a support process. It is only a business relevant feature as the status field is the most process-specific field on a case. The status field cannot be customized on a record type, it can only be customized in a support process.

Thanks,
Shashank
Krista KellyKrista Kelly 
Hello, 

I have a Apex class that select records where a field > 0. It then loops through these leads and creates a record in a custom object (Metrics__c). Based on the date it creates a record with a 0 value or with a value > 0. The class works great (tested in Dev Console as a batch) but I'm going in cirlces trying to get the test class past 61%. Any help would be appreciated!

Apex Class

global class MetricProcessor implements Database.Batchable <SObject>,Schedulable {
//START METHOD
global Database.QueryLocator start(Database.BatchableContext bc){

    
    String Query= 'select Id, Console_Logins__c, Console_Last_Logins_Date_Field__c, EP_Catalog__c, EP_Catalog_Date_Field__c, EP_Designer__c, EP_Designer_Date_Field__c, EP_Discovery__c,EP_Discovery_Date_Field__c From Lead where Console_Logins__c > 0';

    return Database.getQueryLocator(Query);

        }

//EXECUTE METHOD

global void execute(Database.BatchableContext bc, List<Lead> scope){

    for(Lead l: scope){

        IF (l.Console_Last_Logins_Date_Field__c > (system.today() - 1))
   {
        //insert record
         
    Metrics__c met = new Metrics__c(
    
         Lead__c=l.ID,

        Name='ConsoleLogins',

        Metric_Value__c=l.Console_Logins__c,

        Metric_Date__c= system.today());

       
    insert met;

    }
    Else
       {//insert 0 record
         Metrics__c met = new Metrics__c(
    
         Lead__c=l.ID,

        Name='ConsoleLogins',

        Metric_Value__c= 0,

        Metric_Date__c= system.today());
        
         insert met;
    }
            IF (l.EP_Catalog_Date_Field__c > (system.today() - 1))
   {
        //insert record
         
    Metrics__c met = new Metrics__c(
    
         Lead__c=l.ID,

        Name='EPCatalog',

        Metric_Value__c=l.EP_Catalog__c,

        Metric_Date__c= system.today());

       
    insert met;

    }
    Else
       {//insert 0 record
         Metrics__c met = new Metrics__c(
    
         Lead__c=l.ID,

        Name='EPCatalog',

        Metric_Value__c= 0,

        Metric_Date__c= system.today());
        
         insert met;
    }
            IF (l.EP_Designer_Date_Field__c > (system.today() - 1))
   {
        //insert record
         
    Metrics__c met = new Metrics__c(
    
         Lead__c=l.ID,

        Name='EPDesigner',

        Metric_Value__c=l.EP_Designer__c,

        Metric_Date__c= system.today());

       
    insert met;

    }
    Else
       {//insert 0 record
         Metrics__c met = new Metrics__c(
    
         Lead__c=l.ID,

        Name='EPDesigner',

        Metric_Value__c= 0,

        Metric_Date__c= system.today());
        
         insert met;
    }
            IF (l.EP_Discovery_Date_Field__c > (system.today() - 1))
   {
        //insert record
         
    Metrics__c met = new Metrics__c(
    
         Lead__c=l.ID,

        Name='EPDiscovery',

        Metric_Value__c=l.EP_Discovery__c,

        Metric_Date__c= system.today());

       
    insert met;

    }
    Else
       {//insert 0 record
         Metrics__c met = new Metrics__c(
    
         Lead__c=l.ID,

        Name='EPDiscovery',

        Metric_Value__c= 0,

        Metric_Date__c= system.today());
        
         insert met;
    }
    }

    update scope;

}


   

//FINISH METHOD

global void finish(Database.BatchableContext bc){

    Id job= bc.getJobId();

    System.debug(job);

}

 

 global void execute(SchedulableContext SC) {

 MetricProcessor l= new MetricProcessor();

ID batchprocessid = Database.executeBatch(l);

}

}

Test Class

@istest
private class MetricProcessorTest {
    @istest

    static void tetslead(){
        List<Lead> l= new List<Lead>();
        lead l1= new Lead();
        l1.LastName='Chaytor';
        l1.Company='Solace';
        l1.Status='Working';
        l1.Console_Logins_Last_Modified__c = system.now();
        l1.Console_Logins__c = 2;
        l1.EP_Catalog_Last_Modified__c = system.now()-2;
        l1.EP_Catalog__c = 0;
        l1.EP_Designer_Last_Modified__c = system.now()-2;
        l1.EP_Designer__c = 0;
        l1.EP_Discovery_Last_Modified__c = system.now();
        l1.EP_Discovery__c = 1;
        l1.LeadSource='Dreamforce';
        l.add(l1);
        insert l;
        
      List<Metrics__c> m= new List<Metrics__c>();
        Metrics__c m1= new Metrics__c();
        m1.Lead__c = l1.Id;
        m1.Name = 'ConsoleLogins';
        m1.Metric_Value__c = 2;
       // m1.Metric_Date__c = system.today();
        
        m.add(m1);
        insert m;
        
        List<Metrics__c> m2= new List<Metrics__c>();
        Metrics__c m3= new Metrics__c();
        m3.Lead__c = l1.Id;
        m3.Name = 'EPCatalog';
        m3.Metric_Value__c = 0;
        //m3.Metric_Date__c = system.today()-;
        
        m2.add(m3);
        insert m2;
        
        List<Metrics__c> m4= new List<Metrics__c>();
        Metrics__c m5= new Metrics__c();
        m5.Lead__c = l1.Id;
        m5.Name = 'EPDesigner';
        m5.Metric_Value__c = 0;
        //m3.Metric_Date__c = system.today()-;
        
        m4.add(m5);
        insert m4;
        
        List<Metrics__c> m7= new List<Metrics__c>();
        Metrics__c m8= new Metrics__c();
        m8.Lead__c = l1.Id;
        m8.Name = 'EPDiscovery';
        m8.Metric_Value__c = 1;
        //m3.Metric_Date__c = system.today()-;
        
        m7.add(m8);
        insert m7;

        
        
    Test.startTest();
    MetricProcessor lp= new MetricProcessor();
    Id jobid= Database.executeBatch(lp);
        String sch = '0 0 * * * ?';
 
system.schedule('ReassignAccountOwner', sch, lp);

       
     
    
 
    Test.stopTest();

    }

}
Best Answer chosen by Krista Kelly
Andrew GAndrew G
The issue, as is often the case, is building the test data to ensure we get into every branch of the IF ... ELSE ... structure.

First, a tweak to your code, you have a loop where you are inserting the records inside the loop one by one.  This is not good for bulkification, so lets build a list to hold the new records and do the insert outside the loop.
 
global class MetricProcessor implements Database.Batchable <SObject>,Schedulable {
//START METHOD
    global Database.QueryLocator start(Database.BatchableContext bc){
        String Query= 'select Id, Console_Logins__c, Console_Last_Logins_Date_Field__c, EP_Catalog__c, EP_Catalog_Date_Field__c, EP_Designer__c, EP_Designer_Date_Field__c, EP_Discovery__c,EP_Discovery_Date_Field__c From Lead where Console_Logins__c > 0';
        return Database.getQueryLocator(Query);
    }

//EXECUTE METHOD

    global void execute(Database.BatchableContext bc, List<Lead> scope){
        //create a list so we do one insert for all the Metrics records
        List<Metrics__c> newMetrics = new List<Metrics__c>;
        for(Lead l: scope){
            if (l.Console_Last_Logins_Date_Field__c > (System.today() - 1))
            {
                Metrics__c met = new Metrics__c(
                        Lead__c=l.Id,
                        Name='ConsoleLogins',
                        Metric_Value__c=l.Console_Logins__c,
                        Metric_Date__c= System.today());
                newMetrics.add(met) ;
            }
            else
            {//insert 0 record
                Metrics__c met = new Metrics__c(
                        Lead__c=l.Id,
                        Name='ConsoleLogins',
                        Metric_Value__c= 0,
                        Metric_Date__c= System.today());
                newMetrics.add(met) ;
            }
            if (l.EP_Catalog_Date_Field__c > (System.today() - 1))
            {
                //insert record
                Metrics__c met = new Metrics__c(
                        Lead__c=l.Id,
                        Name='EPCatalog',
                        Metric_Value__c=l.EP_Catalog__c,
                        Metric_Date__c= System.today());
                newMetrics.add(met) ;
            }
            else
            {//insert 0 record
                Metrics__c met = new Metrics__c(
                        Lead__c=l.Id,
                        Name='EPCatalog',
                        Metric_Value__c= 0,
                        Metric_Date__c= System.today());
                newMetrics.add(met) ;
            }
            if (l.EP_Designer_Date_Field__c > (System.today() - 1))
            {
                //insert record
                Metrics__c met = new Metrics__c(
                        Lead__c=l.Id,
                        Name='EPDesigner',
                        Metric_Value__c=l.EP_Designer__c,
                        Metric_Date__c= System.today());
                newMetrics.add(met) ;
            }
            else
            {//insert 0 record
                Metrics__c met = new Metrics__c(
                        Lead__c=l.Id,
                        Name='EPDesigner',
                        Metric_Value__c= 0,
                        Metric_Date__c= System.today());
                newMetrics.add(met) ;
            }
            if (l.EP_Discovery_Date_Field__c > (System.today() - 1))
            {
                //insert record
                Metrics__c met = new Metrics__c(
                        Lead__c=l.Id,
                        Name='EPDesigner',     //should this be 'EPDiscovery'
                        Metric_Value__c=l.EP_Discovery__c,
                        Metric_Date__c= System.today());
                newMetrics.add(met) ;
            }
            else
            {//insert 0 record
                Metrics__c met = new Metrics__c(
                        Lead__c=l.Id,
                        Name='EPDiscovery',
                        Metric_Value__c= 0,
                        Metric_Date__c= System.today());
                newMetrics.add(met) ;
            }
        }
        insert newMetrics;
        update scope;
    }

//FINISH METHOD

    global void finish(Database.BatchableContext bc){
        Id job= bc.getJobId();
        System.debug(job);
    }

    global void execute(SchedulableContext SC) {
        MetricProcessor l= new MetricProcessor();
        Id batchprocessid = Database.executeBatch(l);
    }

}

Now when we do our test class lets build more than one test so that we can hit all the branches and do some asserts that have some meaning.
 
@IsTest
private class MetricProcessorTest {
    @IsTest
    static void testInsertMetrics(){
        List<Lead> l= new List<Lead>();
        Lead l1= new Lead();
        l1.LastName='Chaytor';
        l1.Company='Solace';
        l1.Status='Working';
        l1.Console_Logins_Last_Modified__c = System.now();
        l1.Console_Logins__c = 1;
        l1.EP_Catalog_Last_Modified__c = System.now();
        l1.EP_Catalog__c = 2;
        l1.EP_Designer_Last_Modified__c = System.now();
        l1.EP_Designer__c = 3;
        l1.EP_Discovery_Last_Modified__c = System.now();
        l1.EP_Discovery__c = 4;
        l1.LeadSource='Dreamforce';
        l.add(l1);
        insert l;

        Test.startTest();
        MetricProcessor lp= new MetricProcessor();
        Id jobid= Database.executeBatch(lp);
        String sch = '0 0 * * * ?';

        System.schedule('ReassignAccountOwner', sch, lp);

        Test.stopTest();

        List<Metrics__c> newMetrics = new List<Metrics__c>();

        newMetrics = [SELECT Id, Name, Metric_Value__c, Metric_Date__c FROM Metrics WHERE Lead__c = :li.Id  ORDER BY Metric__value__c];

        System.assertEquals(4,newMetrics.size());

        System.assertEquals(1,newMetrics[0].Metric_Value__c);
        System.assertEquals('ConsoleLogins',newMetrics[0].Name);
        System.assertEquals(2,newMetrics[1].Metric_Value__c);
        System.assertEquals('EPCatalog',newMetrics[1].Name);
        System.assertEquals(3,newMetrics[2].Metric_Value__c);
        System.assertEquals('EPDesigner',newMetrics[2].Name);
        System.assertEquals(4,newMetrics[3].Metric_Value__c);
        System.assertEquals('EPDesigner',newMetrics[3].Name);

    }

    @IsTest
    static void testInsertZeroMetrics(){
        List<Lead> l= new List<Lead>();
        Lead l1= new Lead();
        l1.LastName='Chaytor';
        l1.Company='Solace';
        l1.Status='Working';
        l1.Console_Logins_Last_Modified__c = System.now()-2;
        l1.Console_Logins__c = 1;
        l1.EP_Catalog_Last_Modified__c = System.now()-2;
        l1.EP_Catalog__c = 2;
        l1.EP_Designer_Last_Modified__c = System.now()-2;
        l1.EP_Designer__c = 3;
        l1.EP_Discovery_Last_Modified__c = System.now()-2;
        l1.EP_Discovery__c = 4;
        l1.LeadSource='Dreamforce';
        l.add(l1);
        insert l;

        Test.startTest();
        MetricProcessor lp= new MetricProcessor();
        Id jobid= Database.executeBatch(lp);
        String sch = '0 0 * * * ?';

        System.schedule('ReassignAccountOwner', sch, lp);

        Test.stopTest();

        List<Metrics__c> newMetrics = new List<Metrics__c>();

        newMetrics = [SELECT Id, Name, Metric_Value__c, Metric_Date__c FROM Metrics WHERE Lead__c = :li.Id  ORDER BY Name];

        System.assertEquals(4,newMetrics.size());

        System.assertEquals(0,newMetrics[0].Metric_Value__c);
        System.assertEquals('ConsoleLogins',newMetrics[0].Name);
        System.assertEquals(0,newMetrics[1].Metric_Value__c);
        System.assertEquals('EPCatalog',newMetrics[1].Name);
        System.assertEquals(0,newMetrics[2].Metric_Value__c);
        System.assertEquals('EPDesigner',newMetrics[2].Name);
        System.assertEquals(0,newMetrics[3].Metric_Value__c);
        System.assertEquals('EPDiscovery',newMetrics[3].Name);

    }

}

Note that in the first test method we have test data that will fulfill all the IF components of the code.   In the second test , we have data that will drive into each of the ELSE components of the code.


Also note, that when posting code, the code snippet button helps make the code more readable:
User-added image

Regards

Andrew

P.S.  all code is provided uncompiled and As-Is.
 
Daniel PuzaDaniel Puza 
We are developing a custom Lightning component that contains a Canvas App which loads our external site inside of the Lightning component.

Is it possible, and if so what are some recommended ways to communicate between the Lightning component and the loaded Canvas App site? (NOT the parameters passed in to load the canvas app initially.)

For instance, we would like a button in the Lightning component to trigger an action inside the loaded Canvas App.

It seems that various methods of communicating are restricted by Lightning Locker etc.  I found documentation for various methods of event raising and handling but all I've tried have been without success.  It seems possible they're only for communicating from Lightning component to Lightning component, or from canvas app to canvas app (or Visualforce), but not Lightning component to canvas app.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_component.htm
https://developer.salesforce.com/docs/atlas.en-us.platform_connect.meta/platform_connect/canvas_app_events.htm

I was able to send a message from the canvas app to the lightning component using this "non-standard, probably unsupported technique", but not the other way around.
https://salesforce.stackexchange.com/a/161621/49367
Best Answer chosen by Daniel Puza
Daniel PuzaDaniel Puza
Since using events between a Visualforce page and a canvas app (https://developer.salesforce.com/docs/atlas.en-us.platform_connect.meta/platform_connect/canvas_vf_app_resizing.htm) is supported, I wrapped our canvas app in an empty Visualforce page and used this blog article (https://developer.salesforce.com/blogs/developer-relations/2017/01/lightning-visualforce-communication.html) as an example to communicate between the lightning component and the Visualforce page by loading the Visualforce page in an iframe:
<iframe aura:id="vfFrame" src="{!'https://' + v.vfHost + '/apex/myvfpage'}"/>

Then I am able to use postMessage (https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage)/addEventListener (https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) to communicate between the lightning component and the wrapper Visualforce page.  And can use publish (https://developer.salesforce.com/docs/atlas.en-us.platform_connect.meta/platform_connect/canvas_app_vf_publish_code_example.htm)/subscribe (https://developer.salesforce.com/docs/atlas.en-us.platform_connect.meta/platform_connect/canvas_app_vf_subscribe_code_example.htm) to pass the event between Visualforce and the canvas app.

Another approach that works is using SignalR on our external app to trigger the communication.  Had to work through some configuration for CORS, but got a proof of concept working that way too.

Tried to accomplish the same thing with CometD.  I thought it could be a little cleaner than SignalR because it’s built in to Salesforce and there is some Salesforce documentation on it.  However, I haven’t been able to get the CometD approach to work.  The Salesforce side is throwing CORS errors, even though I have the connection included in the Salesforce CORS/CSP whitelist.  I set up the CORS configuration in IIS and got SignalR working, but I don’t know what else I can configure in Salesforce to allow the same thing with CometD and CORS, or if it’s even possible.  According to this (https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/extend_code_cors.htm), only these Salesforce technologies support CORS.
  • Analytics REST API
  • Bulk API
  • Connect REST API
  • Salesforce IoT REST API
  • Lightning Out
  • REST API
  • User Interface API
  • Apex REST
d3developerd3developer 

Okay folks, I know this is a n00b question but I can't remember if or how to initialize a string with a set of arguments.

 

What I want to do is something like this

 

 

List<String> alphabet = { 'a' , 'b' , 'c' ...  };

 

How can I do this?

 

Best Answer chosen by Admin (Salesforce Developers) 
Jeremy.NottinghJeremy.Nottingh

 

List<String> alphabet = new list<String> { 'a' , 'b' , 'c' ...  };

 That should do ya.

 

xpresslanejxpresslanej 

Howdy everyone,

 

Well, I'm a bit stumped. I'm trying to test a web-to-lead form where I preset the record type:

 

 

<input type="hidden" id="recordType" name="recordType" value="012Q00000008ULW">

 

I have the "keep the existing record type" option set under Lead Settings and it is still not working. 

 

Everything else is populating correctly on the lead record in SFDC. 

 

Thoughts?

 

Thanks, 

 

Best Answer chosen by Admin (Salesforce Developers) 
xpresslanejxpresslanej

I figured it out...not intuitive at first, but I can understand the reasoning I suppose based on the order of operations. I checked the profile of the Default Lead Owner and this profile did not have the new lead record type selected under Record Type Settings. Did not think about this at first because a user with this profile should NEVER be assigned this type of lead. However, even though the assignment rules were assigning the leads to the right user (who has a different profile), the record type was not being set. Adding the new record type to the Default Lead Owner's profile fixed this. 

 

Does this mean that, in terms of operations, that the lead owner is first set to the Default Lead Owner and then assignment rules are evaluated & applied? 

 

 

Message Edited by xpresslanej on 05-11-2009 10:21 AM
jhartfieldjhartfield 

I randomly was trying a split today on a '*' field and got the following error:

 

System.StringException: Invalid regex: Dangling meta character '*' near index 0 * ^

 

Out of curiosity, I tried to split on '+' and got the same error.  

 

This is easily reproducible for me by running the following code in the execute anonymous window - can anyone else  confirm?

string sString = 'someStuff'; string[] splitted = sString.split('*');

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

The following allows the text to be split on the '*' character:

 

string sString = 'some*Stuff'; string[] splitted = sString.split('\\*'); system.debug('Splitted = ' + splitted);

 


Itzik Winograd 7Itzik Winograd 7 
Hi
I need to perform an action on a LWC component when the flow navigates to Next/Finish. Since this component is part of a screen, I cant add my own navigation buttons on this component.
So, Is there any way to listen to the flow's native Navigation events?
Or, the only solution is to override the footer and add my own navigation buttons and use c-pubsub to perform an action on the mentioned component?
Thanks in advanced!
 
Best Answer chosen by Itzik Winograd 7
AnudeepAnudeep (Salesforce Developers) 
Hi Itzik, 

You should be able to use the Validate hook to accomplish this (discussed here and here). If you add it to your LWC, you'll get called each time something attempts to transition out of the flow screen. Most components that use this use it to carry out validation and potentially block the transition, but you could use it as a simple notification. I hope this helps

Anudeep