• MAITREYEE DINGARE
  • NEWBIE
  • 25 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hello all,

I am very new to APEX, and I am trying to match the Account Id of one custom object to another customer custom object. I am using this code into Lightning Component, so I have used @AuraEnabled. I am getting variable does not exist error for variable 'besuchsbericht'. Here is my code snippet:
public class PriceBookEntriesFromAccount {
    
    @AuraEnabled
    public Id currentBB{get; set;}
    
    public PriceBookEntriesFromAccount(ApexPages.StandardController controller) 
    {
        currentBB = Apexpages.currentpage().getParameters().get('id');
    }
    
    @AuraEnabled
    public list<Besuchsbericht__c> besuchsbericht = [SELECT Unternehmen__r.Name FROM Besuchsbericht__c WHERE Id =:currentBB];
   
    @AuraEnabled
    public static List<BB_Produkt__c> getPriceBookEntries() {
        List<BB_Produkt__c> bb = 
            [SELECT Name, Id, Produkt__r.Name, Verkostung__c, Kaufinteresse__c, Unternehmen__r.Name 
             FROM BB_Produkt__c 
             WHERE Unternehmen__r.Name = :besuchsbericht];
        //Add isAccessible() check
        return bb;
    }
}
My apologies for some variable names in the German language.
Any help would be appreciated. 

Thank you!
Maitreyee Dingare
Hello All, 

I am very new to the development. I have the following requirement:

Current Scenario:
I have a custom-related list (Promotions) for Accounts and when I create a new record for that related list, it related to the current Account. This is the process that we follow for every single Account to the related list (Promotions).

Requirement:
I need to have a button on the list view page of Accounts. When I select multiple Accounts on the list view and click on that button, I should get the possibility to add those Accounts to the related list (Promotions). I.e. the new related list (Promotions) records should be created for the selected Accounts. 

As I am not a developer, it is difficult to write such a code for me and I did not found any templates which can fulfill this function. 

Any help is appreciated. Thank you in advance.

Thank you!
Maitreyee Dingare
Hello All,
I am new to development. I have written a trigger to add a newly created product into the standard price book. But while deployment to PROD, it is failing because of 0% code coverage.
Could you please help me here?
Following is my trigger:
trigger createPriceBookEntry on Product2 (after insert) {
    
    List<priceBookEntry> priceBookEntryList= new List<priceBookEntry>();
    
    String pricebkId= [SELECT id from Pricebook2 where isStandard=true][0].Id;
    
    for(Product2 prod: trigger.new){      
        priceBookEntry priceBkEntry= new priceBookEntry();
        priceBkEntry.Product2Id= prod.Id;
        priceBkEntry.Pricebook2Id= pricebkId;
        priceBkEntry.IsActive= True;
        priceBkEntry.UnitPrice= 0; // Dummy Value
        priceBkEntry.UseStandardPrice= False;
        priceBkEntry.External_ID__c = prod.MSOFT_Artikelnummer__c;
        //Add more fields as per requirement
        
        priceBookEntryList.add(priceBkEntry);
    }
    
    if(priceBookEntryList.size()>0)
    {
        insert priceBookEntryList;
    }
}
Following is the test class:
@isTest
public class TestQuoteLineItem
{  
    Static testmethod void insertRecord()
   	{
        priceBookEntry priceBkEntry= new priceBookEntry();
       
        priceBkEntry.Pricebook2Id= '01s09000003qN9eAAE';
        priceBkEntry.IsActive= True;
        priceBkEntry.UnitPrice= 0; // Dummy Value
        priceBkEntry.UseStandardPrice= False;
        priceBkEntry.External_ID__c = 'test';
        priceBkEntry.Product2Id = '01t1l000005CY2aAAG';
        //Add more fields as per requirement
            
        insert priceBkEntry;
       
       //system.assertequals(priceBkEntry.Pricebook2Id,priceBkEntry.Pricebook2Id);
       //System.debug('My debug message: ' + priceBkEntry.Product2Id);
   }
}
Thank you so much for your help in advance!
Hello All,
I am new to development. I have written a trigger to add a newly created product into the standard price book. But while deployment to PROD, it is failing because of 0% code coverage.
Could you please help me here?
Following is my trigger:
trigger createPriceBookEntry on Product2 (after insert) {
    
    List<priceBookEntry> priceBookEntryList= new List<priceBookEntry>();
    
    String pricebkId= [SELECT id from Pricebook2 where isStandard=true][0].Id;
    
    for(Product2 prod: trigger.new){      
        priceBookEntry priceBkEntry= new priceBookEntry();
        priceBkEntry.Product2Id= prod.Id;
        priceBkEntry.Pricebook2Id= pricebkId;
        priceBkEntry.IsActive= True;
        priceBkEntry.UnitPrice= 0; // Dummy Value
        priceBkEntry.UseStandardPrice= False;
        priceBkEntry.External_ID__c = prod.MSOFT_Artikelnummer__c;
        //Add more fields as per requirement
        
        priceBookEntryList.add(priceBkEntry);
    }
    
    if(priceBookEntryList.size()>0)
    {
        insert priceBookEntryList;
    }
}
Following is the test class:
@isTest
public class TestQuoteLineItem
{  
    Static testmethod void insertRecord()
   	{
        priceBookEntry priceBkEntry= new priceBookEntry();
       
        priceBkEntry.Pricebook2Id= '01s09000003qN9eAAE';
        priceBkEntry.IsActive= True;
        priceBkEntry.UnitPrice= 0; // Dummy Value
        priceBkEntry.UseStandardPrice= False;
        priceBkEntry.External_ID__c = 'test';
        priceBkEntry.Product2Id = '01t1l000005CY2aAAG';
        //Add more fields as per requirement
            
        insert priceBkEntry;
       
       //system.assertequals(priceBkEntry.Pricebook2Id,priceBkEntry.Pricebook2Id);
       //System.debug('My debug message: ' + priceBkEntry.Product2Id);
   }
}
Thank you so much for your help in advance!
Hello All,
I have written a Trigger on OrderItems (before Insert) and now writing a test class for the same. 
I am getting an error as:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Pricebook Not Set on Order: []

My Trigger:
trigger UnitPrice on OrderItem (before insert) {

    for (OrderItem orderItem: Trigger.new) {
    if(orderItem.UnitPrice == NULL){
            orderItem.UnitPrice= 0; // Dummy Value
            }
    }

}

Test Class:
@isTest(SeeAllData=true)
public class testUnitPrice {
    
    public static testMethod void testorderproduct(){

    // Insert Account

    Account a = new Account();
    a.Name = 'Test Account';
    insert a;

    // Insert Product
    Product2 p = new Product2();
    p.Name = ' Test Product ';
    p.Description='Test Product Entry 1';
    p.productCode = 'ABC';
    p.isActive = true;
    insert p;
    

    Pricebook2  standardPb = [select id, name, isActive from Pricebook2 where IsStandard = true limit 1];
    
    // Insert PricebookEntry

    PricebookEntry standardPrice = new PricebookEntry();
    standardPrice.Pricebook2Id = standardPb.Id;
    standardPrice.Product2Id = p.Id;
    standardPrice.UnitPrice = 1;
    standardPrice.IsActive = true;
    standardPrice.UseStandardPrice = false;
    insert standardPrice ;
    
    // Insert Order
    
    Order o = new Order();
    o.Name = 'Test Order ';
    o.Status = 'Draft';
    o.EffectiveDate = system.today();
    o.EndDate = system.today() + 4;
    o.AccountId = a.id;
    o.Pricebook2Id =  standardPb.Id ;
    insert o;
    
    // Insert Order Item

    OrderItem i = new OrderItem();
    i.OrderId = o.id;
    i.Quantity = 5;
    i.UnitPrice = 0;
    i.Product2id = p.id;
    i.PricebookEntryId=standardPrice.Id;
    insert i;

	}
}

I am very new to programming. Any help would be appreciated.

Thank you!
Maitreyee Dingare​​​​​​​​​​​​​​
Hello all,

I am very new to APEX, and I am trying to match the Account Id of one custom object to another customer custom object. I am using this code into Lightning Component, so I have used @AuraEnabled. I am getting variable does not exist error for variable 'besuchsbericht'. Here is my code snippet:
public class PriceBookEntriesFromAccount {
    
    @AuraEnabled
    public Id currentBB{get; set;}
    
    public PriceBookEntriesFromAccount(ApexPages.StandardController controller) 
    {
        currentBB = Apexpages.currentpage().getParameters().get('id');
    }
    
    @AuraEnabled
    public list<Besuchsbericht__c> besuchsbericht = [SELECT Unternehmen__r.Name FROM Besuchsbericht__c WHERE Id =:currentBB];
   
    @AuraEnabled
    public static List<BB_Produkt__c> getPriceBookEntries() {
        List<BB_Produkt__c> bb = 
            [SELECT Name, Id, Produkt__r.Name, Verkostung__c, Kaufinteresse__c, Unternehmen__r.Name 
             FROM BB_Produkt__c 
             WHERE Unternehmen__r.Name = :besuchsbericht];
        //Add isAccessible() check
        return bb;
    }
}
My apologies for some variable names in the German language.
Any help would be appreciated. 

Thank you!
Maitreyee Dingare
Hello All, 

I am very new to the development. I have the following requirement:

Current Scenario:
I have a custom-related list (Promotions) for Accounts and when I create a new record for that related list, it related to the current Account. This is the process that we follow for every single Account to the related list (Promotions).

Requirement:
I need to have a button on the list view page of Accounts. When I select multiple Accounts on the list view and click on that button, I should get the possibility to add those Accounts to the related list (Promotions). I.e. the new related list (Promotions) records should be created for the selected Accounts. 

As I am not a developer, it is difficult to write such a code for me and I did not found any templates which can fulfill this function. 

Any help is appreciated. Thank you in advance.

Thank you!
Maitreyee Dingare
Hello All,
I am new to development. I have written a trigger to add a newly created product into the standard price book. But while deployment to PROD, it is failing because of 0% code coverage.
Could you please help me here?
Following is my trigger:
trigger createPriceBookEntry on Product2 (after insert) {
    
    List<priceBookEntry> priceBookEntryList= new List<priceBookEntry>();
    
    String pricebkId= [SELECT id from Pricebook2 where isStandard=true][0].Id;
    
    for(Product2 prod: trigger.new){      
        priceBookEntry priceBkEntry= new priceBookEntry();
        priceBkEntry.Product2Id= prod.Id;
        priceBkEntry.Pricebook2Id= pricebkId;
        priceBkEntry.IsActive= True;
        priceBkEntry.UnitPrice= 0; // Dummy Value
        priceBkEntry.UseStandardPrice= False;
        priceBkEntry.External_ID__c = prod.MSOFT_Artikelnummer__c;
        //Add more fields as per requirement
        
        priceBookEntryList.add(priceBkEntry);
    }
    
    if(priceBookEntryList.size()>0)
    {
        insert priceBookEntryList;
    }
}
Following is the test class:
@isTest
public class TestQuoteLineItem
{  
    Static testmethod void insertRecord()
   	{
        priceBookEntry priceBkEntry= new priceBookEntry();
       
        priceBkEntry.Pricebook2Id= '01s09000003qN9eAAE';
        priceBkEntry.IsActive= True;
        priceBkEntry.UnitPrice= 0; // Dummy Value
        priceBkEntry.UseStandardPrice= False;
        priceBkEntry.External_ID__c = 'test';
        priceBkEntry.Product2Id = '01t1l000005CY2aAAG';
        //Add more fields as per requirement
            
        insert priceBkEntry;
       
       //system.assertequals(priceBkEntry.Pricebook2Id,priceBkEntry.Pricebook2Id);
       //System.debug('My debug message: ' + priceBkEntry.Product2Id);
   }
}
Thank you so much for your help in advance!