• Olavo Zapata
  • NEWBIE
  • 30 Points
  • Member since 2018


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 7
    Questions
  • 24
    Replies
Hello guys,

I'm facing a pretty weird problem in the Apex behavior that needs to bring me users with events occupying their calendar.

Contextualizing:
We have a code that distributes the qualified opportunities for the sales rep (SREPs) from an event which the schedule was defined by the client.
The Code searches for the time which the client chose for who SREPs are available to call him.

Since we could not find "available" in the calendar, we searched through all the "Open" Events at that time and then took out the sales rep who were busy.

Resulting in the list of sellers without event.

The problem:
The result of the described operation sometimes brings me sreps who are busy at the moment, which causes discomfort to the customer.

We try to debug in different ways to understand why this happens, but when we run the same query anywhere else shows the busy srep, but in the APEX execution shows as a free srep to call.

We have also created an "Apex Debug log" object where it logs code execution steps for us to know how it was at the time of the opportunity distribution and we can't explain why it happens.
Can it be by routing being in short time slots and the apex using some cash?

Has anyone seen anything like this and could it help?

The code is extensive, but the event call is as follows:
public Map<Id,Event> hasActivityforUser(List<Id> userids,Datetime starttime, Datetime endtime){

		Map<Id,Event> calendar = new Map<Id,Event>();

		List<Event> events =[
						SELECT
							ID,
							WhoId,
							OwnerId
						FROM
							Event
						WHERE
							(OwnerId IN :userids
						AND
							((StartDateTime <=:starttime
						AND
							EndDateTime	>=:starttime)	
						OR
							(StartDateTime <=:endtime
						AND
							EndDateTime	>=:endtime))
						AND 
							status__c = 'Aberta')
		];
		for (Event ev : events) {
		   calendar.put(ev.OwnerId,ev);
		}
		
		return calendar;
	}
Map<Id,Event> calendar =  EventDAO.getInstance().hasActivityforUser(ids,evt.StartDateTime,evt.EndDateTime);

        for(Id id : ids){
            if(calendar.isEmpty() || !calendar.containsKey(id)){
               evt.OwnerId = id;
               return;
            }
        }

Advice for this situation will be great help as well.
Thanks,
Hello guys,

I'm having a hard time with a test to upload a trigger to Production.
Trigger is an autonumber that is executed only when active accounts in the second month receive a trigger to route new user.
Trigger:
trigger AutonumberOnlyISOnb on JBCXM__CustomerInfo__c (before insert, before update){
    list<JBCXM__CustomerInfo__c> l= [SELECT Id,Name,IS_Autonumber__c FROM JBCXM__CustomerInfo__c WHERE IS_Autonumber__c !=:null ORDER BY IS_Autonumber__c DESC LIMIT 1];
    decimal maxacc = l[0].IS_Autonumber__c;
    
    List<JBCXM__CustomerInfo__c> LiList = new List<JBCXM__CustomerInfo__c>();
    for(JBCXM__CustomerInfo__c li:trigger.new) {
        if((li.JBCXM__Status__c == 'a0U1a000000H1GiEAK') &&
            (li.JBCXM__CustomerLifetimeInMonths__c == 2) &&
            (li.RR_Rotear_Adopter__c == true) &&
            (li.IS_Autonumber__c == null)
            ) {
            li.IS_Autonumber__c = Integer.valueOf(maxacc)+1;
        }
        LiList.add(li);
    }
}
The trigger is working perfectly as I expected.
However, due to my low maturity in APEX I couldn't code the test.
Test:
@isTest(OnInstall=true)
private class TestRoterAdopter {
    public static List<JBCXM__CustomerInfo__c> customers;
    static void init(){
	    customers = new List<JBCXM__CustomerInfo__c>();
		customers.add(new JBCXM__CustomerInfo__c(
            JBCXM__Account__c = '0011a00000rDPkpAAG',
            JBCXM__Status__c = 'a0U1a000000H1GiEAK',
			IS_Autonumber__c = 1,
            JBCXM__OriginalContractDate__c = date.newInstance(2018, 05, 20)         
        )); // date with workaround to get lifetime = 2 should be OCD - 2 months.
    }
     
     /** Test with an existing account **/
    static testMethod void TestRoterAdoptertoTrue() {
    init();
    Test.startTest();
	customers.add(new JBCXM__CustomerInfo__c(
            JBCXM__Account__c = '0011a00000rDPkpAAG',
            JBCXM__Status__c = 'a0U1a000000H1GiEAK',
            JBCXM__OriginalContractDate__c = date.newInstance(2018, 05, 20)          
        ));
	    insert customers; 
		
        List<JBCXM__CustomerInfo__c> customerList =
        [SELECT Id,Name,IS_Autonumber__c FROM JBCXM__CustomerInfo__c WHERE 
        IS_Autonumber__c =:null AND 
        JBCXM__Status__c = 'a0U1a000000H1GiEAK' AND
        JBCXM__CustomerLifetimeInMonths__c = 2 AND
        RR_Rotear_Adopter__c = false
        LIMIT 1
        ];
        customerList[0].RR_Rotear_Adopter__c = true; //new value
        
        Test.startTest();
        update customerList[0]; //modificando um registro
        // Verification
        System.assertNotEquals(customerList[0].IS_Autonumber__c, null);
    Test.stopTest();
    }
}

I'm afraid if anyone could help me with this test.
Error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AutonumberOnlyISOnb: execution of BeforeInsert
caused by: System.ListException: List index out of bounds: 0
Trigger.AutonumberOnlyISOnb: line 3, column 1: []

Class.TestRoterAdopter.TestRoterAdoptertoTrue: line 23, column 1
Thanks
Hello guys,

I would like your help in another case related to Apex.
I'm having a trigger in production that gets an API integration.

Basically, the Trigger finds the Account ID based on the External ID that comes from the integration.
The trigger is working "well" but every day I get an error email saying that an error occurred with null values.

I understand that the error is because some External ID coming from the API not found an Account.
But the behavior I expect in such cases is that the code accepted and go to the next record without returning an error.

I just can not do that on the trigger.
The last time I changed it. It registered all External IDs even without finding Account. (and it's not what I want)
Could someone help me?

Trigger:
trigger UpdateAccountId2 on nKPI__c (before update, before insert) {

    Map<String, nKPI__c> tintgreMap = new Map<String, nKPI__c>();
    
    for(nKPI__c ti : trigger.new) {
        
        if(trigger.isInsert || (trigger.isUpdate && ti.RDStationID__c != trigger.oldMap.get(ti.Id).rdstationid__c)) {
            tintgreMap.put(ti.rdstationid__c, ti);
        }
    }

    if(tintgreMap == null) return;
    
    Map<String, Contract> accountMap = new Map<String, Contract>();
    for (Contract account : [Select AccountId,externalCode__c FROM Contract WHERE Product_Group__c = 'RD Station' AND externalCode__c = :tintgreMap.KeySet()]) {
        accountMap.put(account.externalCode__c, account);
    }
    
    if(accountMap == null) return;
    
    for(nKPI__c tiRecord : tintgreMap.Values()) {
        
        tiRecord.Account__c = accountMap.get(tiRecord.rdstationid__c).AccountId;
        
    }

}
Error msg:
Apex script unhandled trigger exception by user/organization: 0051a000000ZQgs/00D1a000000I0UO
UpdateAccountId2: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.UpdateAccountId2: line 23, column 1
Thanks
Hi all,

I'm trying to create a trigger to generate an autonumber that will only count in specific use cases on Customer Object.
For example, when the client has Active Status and has a project end date.

However, with the code I wrote this giving me an error when I'm trying to update or insert any information to the Customer.
Trigger.
trigger AutonumberOnlyISOnb on JBCXM__CustomerInfo__c (after insert, after update) {
    list<JBCXM__CustomerInfo__c> l= [SELECT Id,Name,IS_Autonumber__c FROM JBCXM__CustomerInfo__c where IS_Autonumber__c !=:null order by IS_Autonumber__c desc limit 1];
    decimal maxacc = l[0].IS_Autonumber__c;
    
   for(JBCXM__CustomerInfo__c li:trigger.new) {
       if(li.JBCXM__Status__c == 'a0U1a000000H1GiEAK' &&
           li.Onboarding_End_Date__c != null
       )
    {
     li.IS_Autonumber__c = Integer.valueOf(maxacc)+1;
    }       
    }       
}
Error
Error:Apex trigger AutonumberOnlyISOnb caused an unexpected exception, contact your administrator: AutonumberOnlyISOnb: execution of AfterUpdate caused by: System.FinalException: Record is read-only: ()
Do you know what could be?

Thanks
 

Hi all,
I'm having a hard time running an Apex Test for a trigger that I'm trying to use.
The trigger basically matches the External ID of a Custom Object with the same External ID from Contract ID, to bring me the Account ID in the Custom Object.

What Test needs to do is test this trigger, so I can put it into production. But is giving me the following error:
System.DmlException: Insert failed. First exception on row 0; first error: FAILED_ACTIVATION, Choose a valid contract status and save your changes. Ask your admin for details.: [Status]
Class.UpdateAccountId2.testWithExistingAccount: line 31, column 1

The trigger and the Test are the following:
/** # New Version of nKPI Trigger **/
trigger UpdateAccountId2 on nKPI__c (before update, before insert) {

    Map<String, nKPI__c> tintgreMap = new Map<String, nKPI__c>();
    
    for(nKPI__c ti : trigger.new) {
        
        if(trigger.isInsert || (trigger.isUpdate && ti.RDStationID__c != trigger.oldMap.get(ti.Id).rdstationid__c)) {
            tintgreMap.put(ti.rdstationid__c, ti);
        }
    }

    if(tintgreMap == null) return;
    
    Map<String, Contract> accountMap = new Map<String, Contract>();
    for (Contract account : [Select AccountId,externalCode__c FROM Contract WHERE Product_Group__c = 'RD Station' AND externalCode__c = :tintgreMap.KeySet()]) {
        accountMap.put(account.externalCode__c, account);
    }
    
    if(accountMap == null) return;
    
    for(nKPI__c tiRecord : tintgreMap.Values()) {
        
        tiRecord.Account__c = accountMap.get(tiRecord.rdstationid__c).AccountId;
        
    }

}
--------------------------------------------------- TEST

@isTest(OnInstall=true)
private class UpdateAccountId2 {

    public static List<Contract> contractsList;
    public static List<nKPI__c> kpiList;
    public static String rdstation_id_account1;

    static void init(){
    contractsList = new List<Contract>();
    kpiList = new List<nKPI__c>();

    rdstation_id_account1 = '100';

    kpiList.add(new nKPI__c(
                    rdstationid__c = rdstation_id_account1
    ));
    }

    /** Test with an existing account **/
    static testMethod void testWithExistingAccount() {
    init();
    Test.startTest();

    contractsList.add(new Contract(
        Name = 'Test',
        internalid__c = '1000001',
        Status = '0 - Trial',
        externalCode__c = rdstation_id_account1
    ));
    insert contractsList;
    insert kpiList;
    
    kpiList = [
        SELECT Id, Account__c
        FROM nKPI__c
        WHERE Id = :kpiList[0].Id
    ];

    // Verification
    System.assertEquals(kpiList[0].Account__c, contractsList[0].Id);
    Test.stopTest();
    }
}

Anyone could identify what the error could be? I'm a beginner on this apex things.
Thanks.
 
Hi guys,

I need help to deploy an apex trigger I saw that is very common to receive an error about coverage in production.
And I read many posts related to that but I couldn't fix it.

I completely new in apex triggers and deployment. I have a trigger that is working in sandbox and we make a test class to test it.

Code:
@isTest(OnInstall=true)
private class UpdateAccountId2 {

    public static List<Account> accountsList;
    public static List<nKPI__c> kpiList;
    public static String rdstation_id_account1;

    static void init(){
    accountsList = new List<Account>();
    kpiList = new List<nKPI__c>();

    rdstation_id_account1 = '100';

    kpiList.add(new nKPI__c(
                    rdstationid__c = rdstation_id_account1
    ));
    }

    /** Test with an existing account **/
    static testMethod void testWithExistingAccount() {
    init();
    Test.startTest();

    accountsList.add(new Account(
        Name = 'Test',
        rdstationid__c = rdstation_id_account1
    ));
    insert accountsList;
    insert kpiList;


    kpiList = [
        SELECT Id, Account__c
        FROM nKPI__c
        WHERE Id = :kpiList[0].Id
    ];

    // Verification
    System.assertEquals(kpiList[0].Account__c, accountsList[0].Id);
    Test.stopTest();
    }
}
It shows me 100% coverage in sandbox when I run.
But in production it is showing me this message:
Your organization's code coverage is 70%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.
UpdateAccountId2
Can anyone help me?
Thanks,


 
Hello guys,

I have a custom object that I need to update it via API with our product's information.
For this, we create an Object ('Tests1intgre') with an External ID ("RDStationID") that the external ID also exists in the Account object.

My question is, how to reference these objects? There is already a Lookup Relationship field of the Account in the Test object.

What I tried was to create a process builder to identify the RD Station ID in the 2 objects and bring me the account into the test object.
However, show me that it isn't possible to register.

Process Builder print 1: http://prntscr.com/jxbqme
Process Builder print 2: http://prntscr.com/jxbq5v

I hope you can help me. Thanks,
Hello guys,

I'm facing a pretty weird problem in the Apex behavior that needs to bring me users with events occupying their calendar.

Contextualizing:
We have a code that distributes the qualified opportunities for the sales rep (SREPs) from an event which the schedule was defined by the client.
The Code searches for the time which the client chose for who SREPs are available to call him.

Since we could not find "available" in the calendar, we searched through all the "Open" Events at that time and then took out the sales rep who were busy.

Resulting in the list of sellers without event.

The problem:
The result of the described operation sometimes brings me sreps who are busy at the moment, which causes discomfort to the customer.

We try to debug in different ways to understand why this happens, but when we run the same query anywhere else shows the busy srep, but in the APEX execution shows as a free srep to call.

We have also created an "Apex Debug log" object where it logs code execution steps for us to know how it was at the time of the opportunity distribution and we can't explain why it happens.
Can it be by routing being in short time slots and the apex using some cash?

Has anyone seen anything like this and could it help?

The code is extensive, but the event call is as follows:
public Map<Id,Event> hasActivityforUser(List<Id> userids,Datetime starttime, Datetime endtime){

		Map<Id,Event> calendar = new Map<Id,Event>();

		List<Event> events =[
						SELECT
							ID,
							WhoId,
							OwnerId
						FROM
							Event
						WHERE
							(OwnerId IN :userids
						AND
							((StartDateTime <=:starttime
						AND
							EndDateTime	>=:starttime)	
						OR
							(StartDateTime <=:endtime
						AND
							EndDateTime	>=:endtime))
						AND 
							status__c = 'Aberta')
		];
		for (Event ev : events) {
		   calendar.put(ev.OwnerId,ev);
		}
		
		return calendar;
	}
Map<Id,Event> calendar =  EventDAO.getInstance().hasActivityforUser(ids,evt.StartDateTime,evt.EndDateTime);

        for(Id id : ids){
            if(calendar.isEmpty() || !calendar.containsKey(id)){
               evt.OwnerId = id;
               return;
            }
        }

Advice for this situation will be great help as well.
Thanks,
Hello guys,

I'm having a hard time with a test to upload a trigger to Production.
Trigger is an autonumber that is executed only when active accounts in the second month receive a trigger to route new user.
Trigger:
trigger AutonumberOnlyISOnb on JBCXM__CustomerInfo__c (before insert, before update){
    list<JBCXM__CustomerInfo__c> l= [SELECT Id,Name,IS_Autonumber__c FROM JBCXM__CustomerInfo__c WHERE IS_Autonumber__c !=:null ORDER BY IS_Autonumber__c DESC LIMIT 1];
    decimal maxacc = l[0].IS_Autonumber__c;
    
    List<JBCXM__CustomerInfo__c> LiList = new List<JBCXM__CustomerInfo__c>();
    for(JBCXM__CustomerInfo__c li:trigger.new) {
        if((li.JBCXM__Status__c == 'a0U1a000000H1GiEAK') &&
            (li.JBCXM__CustomerLifetimeInMonths__c == 2) &&
            (li.RR_Rotear_Adopter__c == true) &&
            (li.IS_Autonumber__c == null)
            ) {
            li.IS_Autonumber__c = Integer.valueOf(maxacc)+1;
        }
        LiList.add(li);
    }
}
The trigger is working perfectly as I expected.
However, due to my low maturity in APEX I couldn't code the test.
Test:
@isTest(OnInstall=true)
private class TestRoterAdopter {
    public static List<JBCXM__CustomerInfo__c> customers;
    static void init(){
	    customers = new List<JBCXM__CustomerInfo__c>();
		customers.add(new JBCXM__CustomerInfo__c(
            JBCXM__Account__c = '0011a00000rDPkpAAG',
            JBCXM__Status__c = 'a0U1a000000H1GiEAK',
			IS_Autonumber__c = 1,
            JBCXM__OriginalContractDate__c = date.newInstance(2018, 05, 20)         
        )); // date with workaround to get lifetime = 2 should be OCD - 2 months.
    }
     
     /** Test with an existing account **/
    static testMethod void TestRoterAdoptertoTrue() {
    init();
    Test.startTest();
	customers.add(new JBCXM__CustomerInfo__c(
            JBCXM__Account__c = '0011a00000rDPkpAAG',
            JBCXM__Status__c = 'a0U1a000000H1GiEAK',
            JBCXM__OriginalContractDate__c = date.newInstance(2018, 05, 20)          
        ));
	    insert customers; 
		
        List<JBCXM__CustomerInfo__c> customerList =
        [SELECT Id,Name,IS_Autonumber__c FROM JBCXM__CustomerInfo__c WHERE 
        IS_Autonumber__c =:null AND 
        JBCXM__Status__c = 'a0U1a000000H1GiEAK' AND
        JBCXM__CustomerLifetimeInMonths__c = 2 AND
        RR_Rotear_Adopter__c = false
        LIMIT 1
        ];
        customerList[0].RR_Rotear_Adopter__c = true; //new value
        
        Test.startTest();
        update customerList[0]; //modificando um registro
        // Verification
        System.assertNotEquals(customerList[0].IS_Autonumber__c, null);
    Test.stopTest();
    }
}

I'm afraid if anyone could help me with this test.
Error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AutonumberOnlyISOnb: execution of BeforeInsert
caused by: System.ListException: List index out of bounds: 0
Trigger.AutonumberOnlyISOnb: line 3, column 1: []

Class.TestRoterAdopter.TestRoterAdoptertoTrue: line 23, column 1
Thanks
Hello guys,

I would like your help in another case related to Apex.
I'm having a trigger in production that gets an API integration.

Basically, the Trigger finds the Account ID based on the External ID that comes from the integration.
The trigger is working "well" but every day I get an error email saying that an error occurred with null values.

I understand that the error is because some External ID coming from the API not found an Account.
But the behavior I expect in such cases is that the code accepted and go to the next record without returning an error.

I just can not do that on the trigger.
The last time I changed it. It registered all External IDs even without finding Account. (and it's not what I want)
Could someone help me?

Trigger:
trigger UpdateAccountId2 on nKPI__c (before update, before insert) {

    Map<String, nKPI__c> tintgreMap = new Map<String, nKPI__c>();
    
    for(nKPI__c ti : trigger.new) {
        
        if(trigger.isInsert || (trigger.isUpdate && ti.RDStationID__c != trigger.oldMap.get(ti.Id).rdstationid__c)) {
            tintgreMap.put(ti.rdstationid__c, ti);
        }
    }

    if(tintgreMap == null) return;
    
    Map<String, Contract> accountMap = new Map<String, Contract>();
    for (Contract account : [Select AccountId,externalCode__c FROM Contract WHERE Product_Group__c = 'RD Station' AND externalCode__c = :tintgreMap.KeySet()]) {
        accountMap.put(account.externalCode__c, account);
    }
    
    if(accountMap == null) return;
    
    for(nKPI__c tiRecord : tintgreMap.Values()) {
        
        tiRecord.Account__c = accountMap.get(tiRecord.rdstationid__c).AccountId;
        
    }

}
Error msg:
Apex script unhandled trigger exception by user/organization: 0051a000000ZQgs/00D1a000000I0UO
UpdateAccountId2: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.UpdateAccountId2: line 23, column 1
Thanks
Hi all,

I'm trying to create a trigger to generate an autonumber that will only count in specific use cases on Customer Object.
For example, when the client has Active Status and has a project end date.

However, with the code I wrote this giving me an error when I'm trying to update or insert any information to the Customer.
Trigger.
trigger AutonumberOnlyISOnb on JBCXM__CustomerInfo__c (after insert, after update) {
    list<JBCXM__CustomerInfo__c> l= [SELECT Id,Name,IS_Autonumber__c FROM JBCXM__CustomerInfo__c where IS_Autonumber__c !=:null order by IS_Autonumber__c desc limit 1];
    decimal maxacc = l[0].IS_Autonumber__c;
    
   for(JBCXM__CustomerInfo__c li:trigger.new) {
       if(li.JBCXM__Status__c == 'a0U1a000000H1GiEAK' &&
           li.Onboarding_End_Date__c != null
       )
    {
     li.IS_Autonumber__c = Integer.valueOf(maxacc)+1;
    }       
    }       
}
Error
Error:Apex trigger AutonumberOnlyISOnb caused an unexpected exception, contact your administrator: AutonumberOnlyISOnb: execution of AfterUpdate caused by: System.FinalException: Record is read-only: ()
Do you know what could be?

Thanks
 

Hi all,
I'm having a hard time running an Apex Test for a trigger that I'm trying to use.
The trigger basically matches the External ID of a Custom Object with the same External ID from Contract ID, to bring me the Account ID in the Custom Object.

What Test needs to do is test this trigger, so I can put it into production. But is giving me the following error:
System.DmlException: Insert failed. First exception on row 0; first error: FAILED_ACTIVATION, Choose a valid contract status and save your changes. Ask your admin for details.: [Status]
Class.UpdateAccountId2.testWithExistingAccount: line 31, column 1

The trigger and the Test are the following:
/** # New Version of nKPI Trigger **/
trigger UpdateAccountId2 on nKPI__c (before update, before insert) {

    Map<String, nKPI__c> tintgreMap = new Map<String, nKPI__c>();
    
    for(nKPI__c ti : trigger.new) {
        
        if(trigger.isInsert || (trigger.isUpdate && ti.RDStationID__c != trigger.oldMap.get(ti.Id).rdstationid__c)) {
            tintgreMap.put(ti.rdstationid__c, ti);
        }
    }

    if(tintgreMap == null) return;
    
    Map<String, Contract> accountMap = new Map<String, Contract>();
    for (Contract account : [Select AccountId,externalCode__c FROM Contract WHERE Product_Group__c = 'RD Station' AND externalCode__c = :tintgreMap.KeySet()]) {
        accountMap.put(account.externalCode__c, account);
    }
    
    if(accountMap == null) return;
    
    for(nKPI__c tiRecord : tintgreMap.Values()) {
        
        tiRecord.Account__c = accountMap.get(tiRecord.rdstationid__c).AccountId;
        
    }

}
--------------------------------------------------- TEST

@isTest(OnInstall=true)
private class UpdateAccountId2 {

    public static List<Contract> contractsList;
    public static List<nKPI__c> kpiList;
    public static String rdstation_id_account1;

    static void init(){
    contractsList = new List<Contract>();
    kpiList = new List<nKPI__c>();

    rdstation_id_account1 = '100';

    kpiList.add(new nKPI__c(
                    rdstationid__c = rdstation_id_account1
    ));
    }

    /** Test with an existing account **/
    static testMethod void testWithExistingAccount() {
    init();
    Test.startTest();

    contractsList.add(new Contract(
        Name = 'Test',
        internalid__c = '1000001',
        Status = '0 - Trial',
        externalCode__c = rdstation_id_account1
    ));
    insert contractsList;
    insert kpiList;
    
    kpiList = [
        SELECT Id, Account__c
        FROM nKPI__c
        WHERE Id = :kpiList[0].Id
    ];

    // Verification
    System.assertEquals(kpiList[0].Account__c, contractsList[0].Id);
    Test.stopTest();
    }
}

Anyone could identify what the error could be? I'm a beginner on this apex things.
Thanks.
 
Hi guys,

I need help to deploy an apex trigger I saw that is very common to receive an error about coverage in production.
And I read many posts related to that but I couldn't fix it.

I completely new in apex triggers and deployment. I have a trigger that is working in sandbox and we make a test class to test it.

Code:
@isTest(OnInstall=true)
private class UpdateAccountId2 {

    public static List<Account> accountsList;
    public static List<nKPI__c> kpiList;
    public static String rdstation_id_account1;

    static void init(){
    accountsList = new List<Account>();
    kpiList = new List<nKPI__c>();

    rdstation_id_account1 = '100';

    kpiList.add(new nKPI__c(
                    rdstationid__c = rdstation_id_account1
    ));
    }

    /** Test with an existing account **/
    static testMethod void testWithExistingAccount() {
    init();
    Test.startTest();

    accountsList.add(new Account(
        Name = 'Test',
        rdstationid__c = rdstation_id_account1
    ));
    insert accountsList;
    insert kpiList;


    kpiList = [
        SELECT Id, Account__c
        FROM nKPI__c
        WHERE Id = :kpiList[0].Id
    ];

    // Verification
    System.assertEquals(kpiList[0].Account__c, accountsList[0].Id);
    Test.stopTest();
    }
}
It shows me 100% coverage in sandbox when I run.
But in production it is showing me this message:
Your organization's code coverage is 70%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.
UpdateAccountId2
Can anyone help me?
Thanks,


 
Hello guys,

I have a custom object that I need to update it via API with our product's information.
For this, we create an Object ('Tests1intgre') with an External ID ("RDStationID") that the external ID also exists in the Account object.

My question is, how to reference these objects? There is already a Lookup Relationship field of the Account in the Test object.

What I tried was to create a process builder to identify the RD Station ID in the 2 objects and bring me the account into the test object.
However, show me that it isn't possible to register.

Process Builder print 1: http://prntscr.com/jxbqme
Process Builder print 2: http://prntscr.com/jxbq5v

I hope you can help me. Thanks,
Hi,

I have the an issue using data loader command line, in my case I have two custom objects A and B and there is a master detail relationship between the two, and object A has an external ID.

I found some documents on line and based on those I have done the following configurations:

In the process-conf file I included:
<entry key="sfdc.externalIdField" value="A__r.External_ID__c"/>

In the mapping file I have this:
Id=Id
A__r.External_ID__c=A__r\:External_ID__c


But I am getting an error the " Field name provided A__r.External_ID__c id is not an external id or indexed field on B" 

It worked using the data loader wizard. Any help I will appreciate it.