• leonardokipper
  • NEWBIE
  • 30 Points
  • Member since 2019
  • KCS iT


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 11
    Replies

Hi, how can I cover these remaining lines for this class? I'm struggling to understand why it is not covering all.. This is my class and coverage, I have 66% until now.

User-added image
This is my method from the test class which covers 66%.

 

static testMethod void linkTest() {

        
       	SVMXC__Service_Request__c sr = new SVMXC__Service_Request__c();
        sr.SVMXC__Status__c = 'Closed';
        sr.SVMXC__Priority__c = 'Medium';
        sr.Number_of_Open_Admin_Tasks__c = 2;
        sr.SVMXC__Type__c = 'Complaint CCM';
        insert sr;
        
    	List<SVMXC__Service_Request__c> listSr = [Select Id, SVMXC__Status__c, Name from SVMXC__Service_Request__c where Id=: sr.Id ];
    	
    	ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(listSr);
    	setCtr.setSelected(new SVMXC__Service_Request__c[]{sr});
        MassUpdateSimpleControllerServiceRequest controller = new MassUpdateSimpleControllerServiceRequest(setCtr);
		
		// verify following exceptions will not cause exception
		System.assert(controller.step1()!=null);   
        controller.lexstep1();
		System.assert(controller.step2()!=null);
        controller.lexstep2();
        controller.getFieldTypeOptions();
		System.assert(controller.step3()!=null);
        controller.lexstep3();
		System.assert(controller.step4()!=null);
        controller.lexstep4();
		System.assert(controller.step5()!=null);
        controller.lexstep5();
		//System.assert(controller.cancel()!=null);
		
	
    }
HI I'm New to Developing Can you please let me Know how to write Applying Discount on Record using trigger and apex Class. please send me code i'm able to understand or below is my apex class code, please Modify it.
Public Class PenClassdemonstration {

Public Static Void applyDiscountPen (list<pen__c> varpenslistNew) {

for (pen__c varp : varpenslistNew) {

if(varp.penamount__C >= 100) {

varp.penamount__C = varp.penamount__C - 20;

   }
  }
 }
}
Hi. I have a question regarding apex trigger context. Suppose If I want to update account in after update context, and right after updating account, I want to update contact in account trigger only. Now Contact trigger will run. The question is as trigger context is changed from account to contact, will it refresh governor limit as well?

Hai all hope everyone fine.

I need to get the input value of Date field from opportunity object using apex trigger before insert. (No need to insert record).

hope someone will help me. 

Thank You 

Hello,

I have a related list on account object called " Billing Accounts " (zuora__customeraccount__c).

One account record can have multiple billing accounts records.

On the order object, we have a field called "billing instance" (Billing_Account_Instance__c) which is a lookup to the "billing account" (zuora__customeraccount__c) object.

Currently, users have to populate this field once the order is created.

Now what I am trying to solve is if one account has one billing account populate that billing account in that field once the order is created. 

But if multiple billing accounts exist then not do populate anything so our billing team can choose the most appropriate billing instance for that order.

Can I get some guidance on how I can do that, thank you. 
 
I've got a test class that starts:
 
@IsTest
private class WarehouseCalloutServiceTest {
    
    @TestSetup
    public static void setup() {
        List<Product2> existingProducts = [ SELECT Id, StockKeepingUnit FROM Product2 ];
        System.debug('Existing products:');
        for (Product2 product : existingProducts) {
            System.debug('- ' + product);
        }
        
        // Insert equipment
        List<Product2> equipmentList = new List<Product2>();
        // Maintenance cycle changes
        equipmentList.add(new Product2(
            Name = 'Generator 1000 kW',
            Cost__c = 5000,
            Current_Inventory__c = 6,
            StockKeepingUnit  = '100003',
            Lifespan_Months__c = 0,
            Maintenance_Cycle__c = 730,
            Replacement_Part__c = false
        ));
        // No changes
        equipmentList.add(new Product2(
            Name = 'Cooling Fan',
            Cost__c = 300,
            Current_Inventory__c = 183,
            StockKeepingUnit  = '100004',
            Lifespan_Months__c = 0,
            Maintenance_Cycle__c = 0,
            Replacement_Part__c = true
        ));
        // Quantity changes
        equipmentList.add(new Product2(
            Name = 'Fuse 20A',
            Cost__c = 22,
            Current_Inventory__c = 144,
            StockKeepingUnit  = '100005',
            Lifespan_Months__c = 0,
            Maintenance_Cycle__c = 0,
            Replacement_Part__c = true
        ));
        // SKU 100006 doesn't exist yet
        System.debug('Inserting ' + equipmentList);
        insert equipmentList;        
    }

The loop that prints out existing products prints nothing.
However, the insert fails with an error: 
System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, A Equipment with this SKU already exists.: [StockKeepingUnit]

It's true that such a record already exists in my org. However, the tests are supposed to not see that data. So why is this insert failing?
Anytime the owner of the  Parent account is updated/changed, the userId of Child Account's :  Account Team Member should be updated.

Along with the update functionlity , I want when a new child account is created for the parent account automatically AccountTeamMember is inserted with the parent account's owner and TeamMemberRole = Account Manager.

Thanks,
Rajesh Singh
i need to do a project on what concept or thought can i start it out , as i am beginner in this i just need to figure it out that i could sit and complete the project in a day ?
public class WorkBenchControllerClass {
     public String obj;
    public List<String> objFields {get;set;}
    
    public WorkBenchControllerClass() 
    {    
    }
    public String getobj()
    {
        return obj;
    }
     public void setobj(String obj)
    {
        this.obj = obj;
    } 
    
//Fetching Sobjects
public List<SelectOption> getobjectnames()
{
    Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
    System.debug('globaldesc values--> '+schemaMap);
    List<SelectOption> options=new List<SelectOption>();
    options.add(new SelectOption('None','None'));
    for(Schema.SObjectType objType : schemaMap.values())
    {
    options.add(new SelectOption(objType.getDescribe().getName(),objType.getDescribe().getName()));
    }
    return options;
}
 
//Fetching Fields
 public List<SelectOption> fetchFields()
    { 
        List<SelectOption> allfields=new List<SelectOption>();
        List<String> fields = new List<String>();
        Map<String , Schema.SObjectType> globalDescription = Schema.getGlobalDescribe();
        System.debug('Selected Object is ' + obj);
        Schema.sObjectType objType = globalDescription.get(obj); 
        System.debug('Object Type is ' + objType);
        Schema.DescribeSObjectResult r1 = objType.getDescribe(); 
        
        Map<String , Schema.SObjectField> mapFieldList = r1.fields.getMap();  

        for(Schema.SObjectField field : mapFieldList.values())  
        {  
            Schema.DescribeFieldResult fieldResult = field.getDescribe();  
            
            if(fieldResult.isAccessible())  
            {  
                System.debug('Field Name is ' + fieldResult.getName());
                //fields.add(fieldResult.getName());
                allfields.add(new SelectOption(fieldResult.getName(),fieldResult.getName()));
            }  
        }
        return allfields;
             
    }   
}
I Tried PageReference also but its not working because.it should return list of fields.
Please Help Me to fix this error

Hi, how can I cover these remaining lines for this class? I'm struggling to understand why it is not covering all.. This is my class and coverage, I have 66% until now.

User-added image
This is my method from the test class which covers 66%.

 

static testMethod void linkTest() {

        
       	SVMXC__Service_Request__c sr = new SVMXC__Service_Request__c();
        sr.SVMXC__Status__c = 'Closed';
        sr.SVMXC__Priority__c = 'Medium';
        sr.Number_of_Open_Admin_Tasks__c = 2;
        sr.SVMXC__Type__c = 'Complaint CCM';
        insert sr;
        
    	List<SVMXC__Service_Request__c> listSr = [Select Id, SVMXC__Status__c, Name from SVMXC__Service_Request__c where Id=: sr.Id ];
    	
    	ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(listSr);
    	setCtr.setSelected(new SVMXC__Service_Request__c[]{sr});
        MassUpdateSimpleControllerServiceRequest controller = new MassUpdateSimpleControllerServiceRequest(setCtr);
		
		// verify following exceptions will not cause exception
		System.assert(controller.step1()!=null);   
        controller.lexstep1();
		System.assert(controller.step2()!=null);
        controller.lexstep2();
        controller.getFieldTypeOptions();
		System.assert(controller.step3()!=null);
        controller.lexstep3();
		System.assert(controller.step4()!=null);
        controller.lexstep4();
		System.assert(controller.step5()!=null);
        controller.lexstep5();
		//System.assert(controller.cancel()!=null);
		
	
    }
Avoid dupalication Trgigger for Befor insert && Befor Update for email field , but in befor update when you update only email field with again same email  then get error. dont show the error for others field updation.as like phone,title etc.