• Gauri Gaikwad 13
  • NEWBIE
  • 50 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
I check my code coverage of trigger is 100%, apex class is 100%, but need to check my trigger fucntion is correct or not.Plz help.
--------------
trigger: 

trigger PenDiscountRangeTrigger on Parker_pen__C(before insert)
{
 PenDiscountRangeClass.ApplyDiscount(trigger.new);
}
------
apex class:
public class PenDiscountRangeClass{
public static void ApplyDiscount(list<Parker_pen__C> VarPenList)
{
for(Parker_pen__C VarP: VarPenList)
{
if (VarP.Price__c>=100)
{
VarP.Price__c = VarP.Price__c- 30;
}

else if (VarP.Price__c<100 && VarP.Price__c>= 70)
{
VarP.Price__c= VarP.Price__c- 20;
}

else if (VarP.Price__c<70 && VarP.Price__c>= 40)
{
VarP.Price__c= VarP.Price__c- 10;
}

else if (VarP.Price__c<40)
{
VarP.Price__c= VarP.Price__c- 5;
}
}
}
}
----
Test class:
@isTest
class PenDiscountRangeClassTest {
@isTest
static void ApplyDiscountA()
{
 //create record
    Parker_pen__C VarP= New Parker_pen__C();
    VarP.Name='Govind';
    VarP.Price__c=101;
    //insert record
    insert VarP;
    
 //trigger called
   //add new box with new value
     Parker_pen__C VarP2= New Parker_pen__C();
    VarP2= [select price__c from Parker_Pen__C where id=: VarP.id];
    
    //check new value is expected value
    system.assertEquals(71, VarP2.Price__C);
}        
    @isTest
static void ApplyDiscountB()
{
    //create record
    Parker_pen__C VarP= New Parker_pen__C();
    VarP.Name='Govind';
    VarP.Price__c=71;
    //insert record
    insert VarP;
    
   //trigger called
   //add new box with new value
     Parker_pen__C VarP2= New Parker_pen__C();
    VarP2= [select price__c from Parker_Pen__C where id=: VarP.id];
    
    //check new value is expected value
    system.assertEquals(51, VarP2.Price__C);
}        
     @isTest
static void ApplyDiscountC()
{
    //create record
    Parker_pen__C VarP= New Parker_pen__C();
    VarP.Name='Govind';
    VarP.Price__c=40;
    //insert record
    insert VarP;
    
   //trigger called
   //add new box with new value
     Parker_pen__C VarP2= New Parker_pen__C();
    VarP2= [select price__c from Parker_Pen__C where id=: VarP.id];
    
    //check new value is expected value
    system.assertEquals(30, VarP2.Price__C);
}        
     @isTest
static void ApplyDiscountD()
{
    //create record
    Parker_pen__C VarP= New Parker_pen__C();
    VarP.Name='Govind';
    VarP.Price__c=30;
    //insert record
    insert VarP;
    
   //trigger called
   //add new box with new value
     Parker_pen__C VarP2= New Parker_pen__C();
    VarP2= [select price__c from Parker_Pen__C where id=: VarP.id];
    
    //check new value is expected value
    system.assertEquals(25, VarP2.Price__C);
}        
}

 
i have deployed on production the functionality to update account field on button click.but client is saying field are not updating. how to debug this? and no error in sandbox.

one more , i have deployed some fields to production and those are not visible to end cliednt on page layout, why it is not visibile?
SOSL query: i want to count number of records of .com in account, leads, opportynity object

FIND {.com}, count()
IN ALL FIELDS
RETURNING Opportunity(AccountId), Lead(company),Account(Name)
 
I am trying to run SOQL query 

code added in query editor
SELECT
            First_Name__c
            Experience__c

FROM
            Indeed_COm_Job_Form__c

WHERE 
            Experience__c >1

and i am getting error as : Invalid query: The query has to start with 'FIND' or 'SELECT'.
but i have used SELECT word at beginning
 
hi, i am trying to add trigger  & apex code i am getting error as (Error: Compile Error: Invalid type: Pen_c at line 3 column 51).


code in apex class----------------------

Public Class PenClassDemonstration{

public static void ApplyDiscountPen (List< Pen_c >VarPensListNew){

For(Pen_c VarP: VarPensListNew){

if(VarP.Price_c>= 100){

VarP.Price_c= VarP.Price_c- 20;

}
}
}
}
 
//declare a list variable
list<integer> VarEmployeeList= New list<integer> ();
//add values
VarEmployeeList.add(123);
VarEmployeeList.add(1234);    
VarEmployeeList.add(1234);

system.debug(VarEmployeeList);

For(VarOneValue: VarEmployeeList)
{
    system.debug(VarOneValue);
}
 
i have deployed on production the functionality to update account field on button click.but client is saying field are not updating. how to debug this? and no error in sandbox.

one more , i have deployed some fields to production and those are not visible to end cliednt on page layout, why it is not visibile?
SOSL query: i want to count number of records of .com in account, leads, opportynity object

FIND {.com}, count()
IN ALL FIELDS
RETURNING Opportunity(AccountId), Lead(company),Account(Name)
 
hi, i am trying to add trigger  & apex code i am getting error as (Error: Compile Error: Invalid type: Pen_c at line 3 column 51).


code in apex class----------------------

Public Class PenClassDemonstration{

public static void ApplyDiscountPen (List< Pen_c >VarPensListNew){

For(Pen_c VarP: VarPensListNew){

if(VarP.Price_c>= 100){

VarP.Price_c= VarP.Price_c- 20;

}
}
}
}