• Paulo Perez
  • NEWBIE
  • 10 Points
  • Member since 2014
  • Coordinator
  • Tiner

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 14
    Replies
Hello,

Please, I've had trouble in PricebookEntry when I execute test below: 

@isTest 
(seeAllData = true)

private class TestOpportunityLineItem
{
static testMethod void TestProOportunidade()
{

Date closeDt = Date.Today();

date myDate = date.today();

Account a2 = new Account(Name ='Teste');
insert a2;

opportunity oppr = new opportunity(Name='Encomenda teste' ,  AccountId= a2.Id,StageName = 'Fechado', 
                                   CloseDate = closeDt);
insert oppr;

Id pricebookId = Test.getStandardPricebookId();

Product2 prod = new Product2(
     Name = 'Vidro',
     ProductCode = '1108',
     isActive = true
);
insert prod;

PricebookEntry pbEntry = new PricebookEntry(
     Pricebook2Id = pricebookId,
     Product2Id = prod.Id,
     UnitPrice = 200.00,
     //StandardPrice= 100.00,
     //UseStandardPrice = false,
     IsActive = true
);
insert pbEntry;

OpportunityLineItem oli = new OpportunityLineItem(
     OpportunityId = oppr.Id,
     Quantity = 5,
     PricebookEntryId = pbEntry.Id,
     TotalPrice = 1
);
insert oli;
 

}
}
Hello Experts SalesForce,

Below is the test code to standardprice to product2:

@isTest
public class TestaStandardPrice {
static testMethod void testInsertLine() { 
Test.StartTest();
Product2 p = new product2(name='x',isactive=TRUE);
insert p;
System.assertEquals(0.00, [select UnitPrice from PricebookEntry 
where product2id = :p.id].UnitPrice);
Test.StopTest();
}
}

But, show me the fail:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AutoPopulatePricebookEntry: execution of AfterInsert

caused by: System.QueryException: List has no rows for assignment to SObject

Trigger.AutoPopulatePricebookEntry: line 2, column 1: []

 
Hello SalesForce Experts

How can i insert standardprice in pricebookentry object using dataloader?
Is security to download  CTI Toolkit 4.03 installer package on the link https://media.developerforce.com.s3.amazonaws.com/CTI-Toolkit/CTI-4.03/CTI_Toolkit_4_03_setup.exe?


 

hello 
I need assitance, when i run the class sow me the message "Number of SOQL queries: 101 out of 100". Anybody could help me? :(

public class PacoteVitron{

    public static void ContatoTelefone() {
        List<Lead> accList = [Select Id from lead];
        PacoteVitron.Atendimento(accList);  
    }

   
    public static void Atendimento(Lead[] Indicacao) {
        List<Lead> LeadToUpdate = new List<Lead>();     
        for(Lead ll : Indicacao) {
            AggregateResult[] tarefa=[
            Select max(Createddate) ultima from task where Subject ='Ligação Call Center Fastcall' and whoid=:ll.id
            group by whoid
            ];
            if(tarefa.size() > 0){
            if ((datetime)tarefa[0].get('ultima')!=null){
            datetime dt=(datetime)tarefa[0].get('ultima');          
            ll.Data_da_ultima_ligacao__c=date.newinstance(dT.year(), dT.month(), dT.day());        
            LeadToUpdate.add(ll);      }} 
        }
        update LeadToUpdate;
    }
}
Dear 

I need assistane. I dont know more what i can do, show me "Arithmetic expressions must use numeric arguments at line 13 column 29"


public class FrequenciaCompra{
    public static void Frequencia(Account[] Conta) {
        for (Account b :Conta){
            AggregateResult[]  opp =
                [SELECT accountid,count(CloseDate) n
                FROM Opportunity
                WHERE 
                CloseDate>=:b.Primeira_Oportunidade__c and
                CloseDate<=:b.Ultima_Oportunidade__c and
                accountid=:b.id
                group by accountid] ;
            date startDate=b.Ultima_Oportunidade__c;
            b.Frequencia__C=startDate.daysBetween(b.Primeira_Oportunidade__c)/opp[0].get('n');
            b.update;
        }
    }
    
}
How can I adapt my trigger when I have other app install in my salesforce? Below a sample:
CampaignCallDownControllerTest.testNormalFlow(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, </BR></BR></BR><font color="blue">Redirecting in just a second.</font></BR><a href="../apex/SFSSDupeCatcher__SFSSDupeCatcher?dId0=MDBRRTAwMDAwMGE5MUNITUFZ&dId1=MDBRRTAwMDAwMGE5bnk5TUFB&dId2=MDBRRTAwMDAwMGE5bnlBTUFR&dId3=MDBRRTAwMDAwMGE5bnlCTUFR&dId4=MDBRRTAwMDAwMGE5bnlDTUFR&scId=YTFCRTAwMDAwMDd3WDBYTUFV&userAction=NA%3D%3D&sourceFieldLabels=RW1haWw%3D&targetFieldLabels=RW1haWw%3D&oneTimeKey=MTQxNTkxOTM4MTM4NQ%3D%3D">Click here for manual redirect.</a><br/><SCRIPT>window.location = "../apex/SFSSDupeCatcher__SFSSDupeCatcher?dId0=MDBRRTAwMDAwMGE5MUNITUFZ&dId1=MDBRRTAwMDAwMGE5bnk

This message show me when I deployed sandbox to production (I have instaled in production an app called CampaignCallDown).

Thanks
Hello,

Please, I've had trouble in PricebookEntry when I execute test below: 

@isTest 
(seeAllData = true)

private class TestOpportunityLineItem
{
static testMethod void TestProOportunidade()
{

Date closeDt = Date.Today();

date myDate = date.today();

Account a2 = new Account(Name ='Teste');
insert a2;

opportunity oppr = new opportunity(Name='Encomenda teste' ,  AccountId= a2.Id,StageName = 'Fechado', 
                                   CloseDate = closeDt);
insert oppr;

Id pricebookId = Test.getStandardPricebookId();

Product2 prod = new Product2(
     Name = 'Vidro',
     ProductCode = '1108',
     isActive = true
);
insert prod;

PricebookEntry pbEntry = new PricebookEntry(
     Pricebook2Id = pricebookId,
     Product2Id = prod.Id,
     UnitPrice = 200.00,
     //StandardPrice= 100.00,
     //UseStandardPrice = false,
     IsActive = true
);
insert pbEntry;

OpportunityLineItem oli = new OpportunityLineItem(
     OpportunityId = oppr.Id,
     Quantity = 5,
     PricebookEntryId = pbEntry.Id,
     TotalPrice = 1
);
insert oli;
 

}
}
Hello Experts SalesForce,

Below is the test code to standardprice to product2:

@isTest
public class TestaStandardPrice {
static testMethod void testInsertLine() { 
Test.StartTest();
Product2 p = new product2(name='x',isactive=TRUE);
insert p;
System.assertEquals(0.00, [select UnitPrice from PricebookEntry 
where product2id = :p.id].UnitPrice);
Test.StopTest();
}
}

But, show me the fail:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AutoPopulatePricebookEntry: execution of AfterInsert

caused by: System.QueryException: List has no rows for assignment to SObject

Trigger.AutoPopulatePricebookEntry: line 2, column 1: []

 
Hello SalesForce Experts

How can i insert standardprice in pricebookentry object using dataloader?

hello 
I need assitance, when i run the class sow me the message "Number of SOQL queries: 101 out of 100". Anybody could help me? :(

public class PacoteVitron{

    public static void ContatoTelefone() {
        List<Lead> accList = [Select Id from lead];
        PacoteVitron.Atendimento(accList);  
    }

   
    public static void Atendimento(Lead[] Indicacao) {
        List<Lead> LeadToUpdate = new List<Lead>();     
        for(Lead ll : Indicacao) {
            AggregateResult[] tarefa=[
            Select max(Createddate) ultima from task where Subject ='Ligação Call Center Fastcall' and whoid=:ll.id
            group by whoid
            ];
            if(tarefa.size() > 0){
            if ((datetime)tarefa[0].get('ultima')!=null){
            datetime dt=(datetime)tarefa[0].get('ultima');          
            ll.Data_da_ultima_ligacao__c=date.newinstance(dT.year(), dT.month(), dT.day());        
            LeadToUpdate.add(ll);      }} 
        }
        update LeadToUpdate;
    }
}
Dear 

I need assistane. I dont know more what i can do, show me "Arithmetic expressions must use numeric arguments at line 13 column 29"


public class FrequenciaCompra{
    public static void Frequencia(Account[] Conta) {
        for (Account b :Conta){
            AggregateResult[]  opp =
                [SELECT accountid,count(CloseDate) n
                FROM Opportunity
                WHERE 
                CloseDate>=:b.Primeira_Oportunidade__c and
                CloseDate<=:b.Ultima_Oportunidade__c and
                accountid=:b.id
                group by accountid] ;
            date startDate=b.Ultima_Oportunidade__c;
            b.Frequencia__C=startDate.daysBetween(b.Primeira_Oportunidade__c)/opp[0].get('n');
            b.update;
        }
    }
    
}
How can I adapt my trigger when I have other app install in my salesforce? Below a sample:
CampaignCallDownControllerTest.testNormalFlow(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, </BR></BR></BR><font color="blue">Redirecting in just a second.</font></BR><a href="../apex/SFSSDupeCatcher__SFSSDupeCatcher?dId0=MDBRRTAwMDAwMGE5MUNITUFZ&dId1=MDBRRTAwMDAwMGE5bnk5TUFB&dId2=MDBRRTAwMDAwMGE5bnlBTUFR&dId3=MDBRRTAwMDAwMGE5bnlCTUFR&dId4=MDBRRTAwMDAwMGE5bnlDTUFR&scId=YTFCRTAwMDAwMDd3WDBYTUFV&userAction=NA%3D%3D&sourceFieldLabels=RW1haWw%3D&targetFieldLabels=RW1haWw%3D&oneTimeKey=MTQxNTkxOTM4MTM4NQ%3D%3D">Click here for manual redirect.</a><br/><SCRIPT>window.location = "../apex/SFSSDupeCatcher__SFSSDupeCatcher?dId0=MDBRRTAwMDAwMGE5MUNITUFZ&dId1=MDBRRTAwMDAwMGE5bnk

This message show me when I deployed sandbox to production (I have instaled in production an app called CampaignCallDown).

Thanks
Hi all:
   I am using an Integration Tool to upload data into the products2 and pricebookEntry table... Now, I can load data into the product2 table no issues there. But when I try to load the pricebookentry to link back to product2Is and pricebook2Id.. the issue I have having is "[SFDC] No standard price defined for this product    [SFDC] STANDARD_PRICE_NOT_DEFINED"
Ok Now I know that standard price is the default unit price if you go through the excel connector in a Product table...
But how do you fill it through an API when it is not part of the product2 table???
Any help ... Please Advise...
Thanks
Shan