• Hariprasath
  • NEWBIE
  • 0 Points
  • Member since 2018
  • Senior Software Engineer
  • ABSI


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 6
    Replies
Trailblazers, I have a question in the Prediction Builder. I was creating a prediction for a field of an object to get the prediction score. After checking the scorecard I enabled it to start scoring and the prediction scored to the records. Question,
 
1. When I create a new record on that object will the prediction make the score to that record?
      If so how much of time it will take to score to the new record?
      If not what will be the possible way to get the score to the new record?
I have two lightning components and in my Parent Component I have a Data Table to show the records that I query from the Custom settings and in each row, I have Edit and Delete Button. When I click the Edit button there I need to show a Modal Box(Child Component) to edit the custom settings Record? Is there any sample to do it? I am new to lightning and my knowledge of Lightning is the beginner.
Hi i'm lost in a test for a send email, i need to test if the email as sent, how i do that?

Thanks for your attention

Batch Class:
global class EmailCaringSenior implements Schedulable, Database.Batchable<sObject> {
    
    Account estipulante;
    
	global Database.QueryLocator start(Database.BatchableContext BC) {
        try{
        	estipulante = [SELECT Id FROM Account WHERE RecordTypeId IN (SELECT Id FROM RecordType WHERE Name = 'Estipulante' AND SObjectType = 'Account') AND Name = 'Caring Senior'];
        } catch(Exception e) {
             System.debug('The following exception has occurred: ' + e.getMessage());
        }
        return Database.getQueryLocator([SELECT Name, CPF__pc FROM Account WHERE Estipulante__c = :estipulante.Id AND CreatedDate = TODAY]);
	}
    
   	global void execute(Database.BatchableContext BC, List<sObject> scope) {
		List<Account> accounts = (List<Account>) scope;
        String listaPaciente = '';
        Integer contagem = 0;
		for(Account paciente : accounts){
			contagem++;
            listaPaciente +=  contagem + '. ' + paciente.Name + ' (CPF: ' + paciente.CPF__pc + ') <br>';
		}
        
		String dataOntem = DateTime.now().addDays(-1).format('dd-MM-yyyy');
        
		Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        message.toAddresses = new String[] { 'gabrielmocelin@unochapeco.edu.br' };
        message.subject = 'Ace - Novos Pacientes (' + dataOntem +  ')';
        message.setHtmlBody('Olá Gestor, <br> Abaixo uma lista de pacientes carregados no Health Cloud ontem (' + dataOntem + '): <br><br> ' + listaPaciente);
        for(OrgWideEmailAddress owa : [SELECT Id, Address, DisplayName FROM OrgWideEmailAddress]) 
        {
           if(owa.DisplayName.contains('Caring Senior'))
           { 
            message.setOrgWideEmailAddressId(owa.Id); 
           } 
        }
        Messaging.SingleEmailMessage[] messages =   new List<Messaging.SingleEmailMessage> {message};
        Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
        
        if (results[0].success) 
        {
            System.debug('The email was sent successfully.');
        } else 
        {
            System.debug('The email failed to send: ' + results[0].errors[0].message);
        }
    }

	global void execute(SchedulableContext sc) {
		EmailCaringSenior b = new EmailCaringSenior();
		Database.executebatch(b);
	}
	
	global void finish(Database.BatchableContext BC) {
		
	}
}
Test Class:
@isTest
public class Test_EmailCaringSenior {
    
    static testMethod void testInsertDetecta()
    {   
        Integer contasAntes = [SELECT COUNT() FROM Account];
        System.assertEquals(contasAntes, 0);
        
        RecordType estipulanteRecordType = [SELECT Id FROM RecordType WHERE Name = 'Estipulante' AND SObjectType = 'Account'];
        Account estipulante = new Account();
        estipulante.RecordTypeId = estipulanteRecordType.Id;             
        estipulante.Name = 'Caring Senior';
        insert estipulante;
        
        Datetime dataAnteOntem = Datetime.now().addDays(-2);
        Test.setCreatedDate(estipulante.Id, dataAnteOntem);
 
        RecordType personAccountRecordType = [SELECT Id FROM RecordType WHERE Name = 'Paciente' AND SObjectType = 'Account'];
        Account paciente = new Account();
        paciente.RecordType = personAccountRecordType;             
        paciente.FirstName = 'Teste';
        paciente.LastName = 'Sobrenome';
        paciente.CPF__pc = '133.173.513-06';
        paciente.Estipulante__c = estipulante.id;
        insert paciente;
        
        Datetime dataOntem = Datetime.now().addDays(-1);
        Test.setCreatedDate(paciente.Id, dataOntem);

        Test.startTest();
			Account myAccount = [SELECT Id, Name, CreatedDate FROM Account WHERE Name ='Teste Sobrenome' LIMIT 1];
        	System.assertEquals(myAccount.CreatedDate, dataOntem);	
      		
           	Account estipulanteTest = [SELECT Id, CreatedDate FROM Account WHERE Name = 'Caring Senior' AND RecordTypeId = :estipulanteRecordType.Id];
			System.assertEquals(estipulanteTest.Id, estipulante.id);
        	System.assertEquals(estipulanteTest.CreatedDate, dataAnteOntem);
        
            EmailCaringSenior b = new EmailCaringSenior();
			Database.executebatch(b);
        
        Test.stopTest();
    }
}

 
Trailblazers, I have a question in the Prediction Builder. I was creating a prediction for a field of an object to get the prediction score. After checking the scorecard I enabled it to start scoring and the prediction scored to the records. Question,
 
1. When I create a new record on that object will the prediction make the score to that record?
      If so how much of time it will take to score to the new record?
      If not what will be the possible way to get the score to the new record?
Hello,
 I follow the instruction and enable Dev Hub but I am still getting error 
 sfdx force:org:create -f config/project-scratch-def.json -a HelloWorldLightningWebComponent
You do not have access to the [ScratchOrgInfo] object
sfdx force:org:list --all
=== Orgs
     ALIAS   USERNAME                ORG ID              CONNECTED STATUS
───  ──────  ──────────────────────  ──────────────────  ────────────────
(D)  DevHub  dannyxxxxxx@.com           00Df4000004miAiEAI  Connected
I'm stuck on step #2 of Einstein Analytics and Discovery Insights Specialist superbadge.  I'm getting this warning while checking the challenge:
Challenge #2 Not complete
The step "Churn Tenure' is in compact form, so the filter values need to be specifed as a minimum and maximum
The static step that feeds has the following the value:
 
"Tenure_Length": {
                "broadcastFacet": false,
                "label": "Tenure Length",
                "selectMode": "single",
                "type": "staticflex",
                "values": [
                    {
                        "display": "High Risk",
                        "value": "1 to 12 months",
                        "min": 1,
                        "max": 12
                    },
                    ...
                ]
            }


I'm using selection binding for min and max values.  The dashboard is correctly filtering:
User-added image
User-added image
Any ideas? 
I've tried a non-compact form step where I inject a saql fragment into the query, as well as where I inject min/max values using a range filter serialization...All these efforts end in the same challenge failure message.

Any help/suggesitions are welcome!
I have written this class for the Trailhead challenge. I am able to find that the account gets inserted but,still I am unable to complete the challenge.Its showing the error "Executing the 'insertNewAccount' method failed. Either the method does not exist, is not static, or does not insert the proper account." Can anyone please help?

public with sharing class AccountHandler {
    public static ID insertNewAccount(String str){
        try{
            Account acc=new Account(Name='CENA');
            insert acc;      
            return(acc.Id);
            
        }
        catch(DMLException ex){
            system.debug('Error Message thrown::'+ex.getMessage());
            return(null);
            
        }
    }
}