• Gage Staruch 9
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 7
    Replies

Hi guys!

I am getting the below error on this test. class:

Error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []

 

Code:

@isTest
private class ActiveAccountTest{
    static testmethod void validateActiveAccount()
    {
        Account acc = new Account();
        acc.name= 'test';
        insert acc;
        
        Product2 newProd = new Product2 (Name = 'Test Product', ProductLine__c ='Test Product Line');
		insert newProd;
        
        Opportunity oppObj = new Opportunity(Name = 'TestOpp',AccountID = acc.Id,Amount = 2000,CloseDate=Date.today(),StageName='A - Purchase / Close Won', MarketingGeneratedType__c = 'Sales');
		insert oppObj;    
        
    	Pricebook2 customPB = new Pricebook2(Name='Test Product', isActive=true);
        insert customPB;
        
        PriceBookEntry pbEntry = new PriceBookEntry(UnitPrice = 100.00, PriceBook2Id = customPB.Id, Product2Id = newProd.Id, IsActive = true, UseStandardPrice = false);
		insert pbEntry ;

		OpportunityLineItem oppLine = new OpportunityLineItem(pricebookentryid=pbEntry.Id,TotalPrice=2000,Quantity = 1,OpportunityID = oppObj.Id);
		insert oppLine;
        
        Test.startTest();
            Account acct4 = [Select custombox__c from Account limit 1];
        Test.stopTest();
         }
}
Can anyone help with this? Any hints would be appreciated! 

I need some help writing a test class. I keep encountering errors with my existing class and would appreciate a fresh view. 

I basically need this re-written:

@isTest
private class ActiveAccountTest{
    static testmethod void validateActiveAccount()
    {
        // Create your test data
        Account acc = new Account();
        acc.name= 'test';
        insert acc;     
        
        Opportunity oppObj = new Opportunity(Name = 'TestOpp',AccountID = acc.Id,Amount = 2000,CloseDate=Date.today(),StageName='A - Purchase / Close Won', MarketingGeneratedType__c = 'Sales');
		insert oppObj;

		Product2 newProd = new Product2 (Name = 'Product 1', ProductLine__c ='Custom Products');
		insert newProd;

		PriceBookEntry pbEntry = new PriceBookEntry(
    	UnitPrice = 1,
    	PriceBook2Id = [SELECT Product2.Id, Product2.Name FROM PriceBookEntry WHERE Pricebook2Id IN (SELECT Id FROM PriceBook2 WHERE Name = 'Custom Products') LIMIT 1].Id,
    	Product2Id = newProd.Id,
   		IsActive = true);

		insert pbEntry ;

		OpportunityLineItem oppLine = new OpportunityLineItem(pricebookentryid=pbEntry.Id,TotalPrice=2000,Quantity = 1,OpportunityID = oppObj.Id);
		insert oppLine;
        
        Test.startTest();
            Account acct4 = [Select Custom_Checkbox_1 from Account limit 1];
        Test.stopTest();
         }
}

The issue here is that I need to reference a custom Pricebook ID. This code fails my code coverage tests and has this error:

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

I'm not quite sure what I'm doing wrong. Any help is appreciated!

I keep getting this error: System.QueryException: List has no rows for assignment to SObject

 

My trigger:
 

trigger ActiveAccount on Account (before insert, before update, after insert) {
    for(account a: trigger.new)
    {
        if (a.Active_Orchestrate_Platform__c == True || a.cb1 == True || a.cb2 == True || a.cb3 == True || a.cb4 == True || a.cb5 == True)
        {
   a.cb6 = True;
        }
    }
}

My test Class:

 

@isTest
private class ActiveAccountTest{
    static testmethod void validateActiveAccount()
    {
        // Create your test data
        Account acc = new Account();
        acc.name= 'test';
        insert acc;     
        
        Opportunity oppObj = new Opportunity(Name = 'TestOpp',AccountID = acc.Id,Amount = 2000,CloseDate=Date.today(),StageName='A - Purchase / Close Won', MarketingGeneratedType__c = 'Sales');
		insert oppObj;

		Product2 newProd = new Product2 (Name = 'Product ABC', ProductLine__c ='ABC Products');
		insert newProd;

        ID lstpbe = [SELECT Product2.Id, Product2.Name
                               FROM PriceBookEntry 
                               WHERE Pricebook2Id IN (SELECT Id 
                                                      FROM PriceBook2 
                                                      WHERE Name = 'ABC Products')].id;
		PriceBookEntry pbEntry = new PriceBookEntry(
    	UnitPrice = 1,
    	Product2Id = lstpbe,
   		IsActive = true);

		insert pbEntry ;

		OpportunityLineItem oppLine = new OpportunityLineItem(pricebookentryid=pbEntry.Id,TotalPrice=2000,Quantity = 1,OpportunityID = oppObj.Id);
		insert oppLine;
        
        Test.startTest();
            Account acct4 = [Select cb6 from Account limit 1];
        Test.stopTest();
         }
}
Hi everyone!

I am trying to build a trigger that automatically updates a field on the opportunity with a list of all the opportunity products. This is what I have so far, but it doesn't seem to be working :/ 
 
trigger OpportunityProducts on Opportunity (after update, after insert, before update) {
    for (Opportunity O: Trigger.new)
    {
        List<Opportunity> opps = new list<Opportunity>([Select Id, (Select Id, name From OpportunityLineItems) From Opportunity]);
        If (O.Name != null ) 
        String OppString = String.join(opps, '');{
        String OppString = O.Products_Listed__c;{
    }	
}
    }
}



Any help is appreciated!
We have about 5 checkboxes on our Account that indicate current customer products. I'm trying to create a "live" VF page on the Account record that has a chart with those checkbox values. Whats the best way to do that?

Essentially, building a 360 degree view of what the customer has based on those fields. 

Any help is appreciated!

Hey everyone,

I'm trying to write a trigger where if any of the follwing checkboxes are checked off:

Active_1__c 
Active_2__c 
Active_3__c
Active_4__c 
Active_5__c 
Active_6__c 

It marks a separate checkboxed called 

Active_main__c

and if all the checkboxes are unchecked, so is Active_main__c.

 

Can someone help with this? I'm new to the developer space.

Hey everyone!

I'm trying to wrap my head around this apex class.

We've been trying to figure out what exactly is causing some tasks to auto-complete. I believe its this class, but not entirely sure as I havent worked with the database.batchable method. 

Could someone help me understand what this class does?

 

global class TaskRelatedToAssignerBatch implements Database.Batchable<sObject> {
    
    global Database.Querylocator start (Database.BatchableContext BC) {
		Date today = System.today();
        Date yesterday = today.addDays(-1);
        return Database.getQueryLocator('SELECT Id, WhoId, WhatId, CreatedDate FROM Task WHERE ((Status = \'Completed\' AND Subject LIKE \'Email:%\') OR RecordTypeId = \'0125A000000tbd5\') AND (WhatId = null OR WhatId_String__c LIKE \'001%\') AND WhoId != null AND CreatedDate >= :yesterday');
   }
    
    global void execute (Database.BatchableContext BC, List<sobject> scope) {
        TaskUtils.relateTasksToOpportunityOrAccount(scope);
    }
    
    global void finish(Database.BatchableContext BC) {}

}

Thank you!
Hello! I'm a newbie developer. I need to create a POST request to a specified URL that triggers from our process builder through an Apex class. Ideally, the body would be something like:
 
{
  "FName": "Jeff",
  "LName": "Test",
  "Email1": "Jeff@test.com",
  "Title": "Test",
  "Phone1": "2244363251",
  "Company": "Test",
  "Country": "US",
}
I've never done a POST request, so I am pretty lost. 

ANY help would be awesome! Even a basic template to get me started. 

Thanks all!


 
I am trying to put in a query for a value that is entered in a field on the visual force page. When the submit button is selected it will go through and query the contact data and match the email address on that to the text field that we have created on the vf page. Once it has found a match it will update the contact id on the case record and insert the data. 
 
public class attachController
{
    public case objcase{get;set;}
    public Attachment myAttachment{get;set;}
    public string fileName{get;set;}
    public Blob fileBody{get;set;}
    
    RecordType recordId = [SELECT Id FROM RecordType WHERE DeveloperName = 'Product_Case'];
    Id recId = (recordId != null) ? recordId.Id : null;
    
    Group queueId = [select Id from Group where Type = 'Queue' AND DeveloperNAME = 'Product_Support_Case_Queue' LIMIT 1];
    Id ownerId = (queueId != null) ? queueId.Id : null;
    
    Contact emailContact = [SELECT Id, Email FROM Contact WHERE Email = objcase.email__c LIMIT 1]
        id conId = (emailContact != null) ? emailContact.Id : null;
    
    
    public attachController(Apexpages.standardcontroller controller)
    {
        objcase = (Case)controller.getRecord();
        myAttachment = new Attachment();
    }
    public PageReference submit(){
        if (fileName != null){
            objcase.RecordTypeId = recId;
            objcase.ownerId = ownerId;
            objcase.ContactId = conId;
            insert objcase;
            
            myAttachment = new Attachment();
            Integer i=0;
            myAttachment .clear();
            myAttachment.Body = fileBody;
            myAttachment.Name = fileName ;
            myAttachment.ParentId = objcase.id;            
            insert myAttachment;
        } else {
            objcase.RecordTypeId = recId;
            objcase.ownerId = ownerId;
            insert objcase;
            
        }             
        pagereference pr = Page.thankYouForSubmittingYourProductCase;                          
        pr.setRedirect(true);
        return pr;
    }
}

 

I need some help writing a test class. I keep encountering errors with my existing class and would appreciate a fresh view. 

I basically need this re-written:

@isTest
private class ActiveAccountTest{
    static testmethod void validateActiveAccount()
    {
        // Create your test data
        Account acc = new Account();
        acc.name= 'test';
        insert acc;     
        
        Opportunity oppObj = new Opportunity(Name = 'TestOpp',AccountID = acc.Id,Amount = 2000,CloseDate=Date.today(),StageName='A - Purchase / Close Won', MarketingGeneratedType__c = 'Sales');
		insert oppObj;

		Product2 newProd = new Product2 (Name = 'Product 1', ProductLine__c ='Custom Products');
		insert newProd;

		PriceBookEntry pbEntry = new PriceBookEntry(
    	UnitPrice = 1,
    	PriceBook2Id = [SELECT Product2.Id, Product2.Name FROM PriceBookEntry WHERE Pricebook2Id IN (SELECT Id FROM PriceBook2 WHERE Name = 'Custom Products') LIMIT 1].Id,
    	Product2Id = newProd.Id,
   		IsActive = true);

		insert pbEntry ;

		OpportunityLineItem oppLine = new OpportunityLineItem(pricebookentryid=pbEntry.Id,TotalPrice=2000,Quantity = 1,OpportunityID = oppObj.Id);
		insert oppLine;
        
        Test.startTest();
            Account acct4 = [Select Custom_Checkbox_1 from Account limit 1];
        Test.stopTest();
         }
}

The issue here is that I need to reference a custom Pricebook ID. This code fails my code coverage tests and has this error:

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

I'm not quite sure what I'm doing wrong. Any help is appreciated!

I keep getting this error: System.QueryException: List has no rows for assignment to SObject

 

My trigger:
 

trigger ActiveAccount on Account (before insert, before update, after insert) {
    for(account a: trigger.new)
    {
        if (a.Active_Orchestrate_Platform__c == True || a.cb1 == True || a.cb2 == True || a.cb3 == True || a.cb4 == True || a.cb5 == True)
        {
   a.cb6 = True;
        }
    }
}

My test Class:

 

@isTest
private class ActiveAccountTest{
    static testmethod void validateActiveAccount()
    {
        // Create your test data
        Account acc = new Account();
        acc.name= 'test';
        insert acc;     
        
        Opportunity oppObj = new Opportunity(Name = 'TestOpp',AccountID = acc.Id,Amount = 2000,CloseDate=Date.today(),StageName='A - Purchase / Close Won', MarketingGeneratedType__c = 'Sales');
		insert oppObj;

		Product2 newProd = new Product2 (Name = 'Product ABC', ProductLine__c ='ABC Products');
		insert newProd;

        ID lstpbe = [SELECT Product2.Id, Product2.Name
                               FROM PriceBookEntry 
                               WHERE Pricebook2Id IN (SELECT Id 
                                                      FROM PriceBook2 
                                                      WHERE Name = 'ABC Products')].id;
		PriceBookEntry pbEntry = new PriceBookEntry(
    	UnitPrice = 1,
    	Product2Id = lstpbe,
   		IsActive = true);

		insert pbEntry ;

		OpportunityLineItem oppLine = new OpportunityLineItem(pricebookentryid=pbEntry.Id,TotalPrice=2000,Quantity = 1,OpportunityID = oppObj.Id);
		insert oppLine;
        
        Test.startTest();
            Account acct4 = [Select cb6 from Account limit 1];
        Test.stopTest();
         }
}
Under Support, Ways to Give, and Annual Fund Giving, that content needs to be changed. If possible, 2017-18 needs to be changed to 2019-20, the word Candidates needs to be removed from the third bullet, and after the 11th bullet the word Chamber should be changed to Mosaic.
On our homepage, the slide that says Gift of Music Jazz Swing and Rock needs to be reversed with the slide that says Make a Impact Today.