• Trevor Heywood
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 7
    Replies
I have a child object for which a profile cannot see the related list on the parent object layout. I can see the related list when signed in as System Administrator. I have checked:
  • The profile has read access rights to the child and parent objects and to all fields on those objects
  • The parent object layout assigned to the profile is correct (there is only one) and has the related list on it
Can't figure out what's missing. One other thing to say is there is no tab for this child object, by design.
Can anyone help please?
Thanks
Trevor
Hi,

I have done lot of research on this already and tried everything I can think of, but I am up against a brick wall.
I have two triggers with code coverage of less than 30%, which bring down my overall coverage below 75%. I have tested them extensively in terms of actual business process, and they work perfectly.The test classes I've written all complete successfully and cover all the conditions in the triggers that I can see, but still coverage is low. Any help would be greatly appreciated! 
The first trigger shows a coverage of 0%. It fires after update on a custom object Client_AHT__c. It checks if a particular picklist value has changed (B_C_Status__c) and if it has, it updates a date field (B_C_StsDte__c):
trigger B_TRG_C_Update on Client_AHT__c (after Update) {

    set<Id> CliIds = new Set <ID>();
   
    for (Client_AHT__c NewCli: Trigger.new) {
        Client_AHT__c oldCli = Trigger.oldMap.get(NewCli.ID);
        
        if (NewCli.B_C_Status__c != oldCli.B_C_Status__c) {

            CliIds.add(NewCli.ID);

            Map<ID, Client_AHT__c> CliToUpdate = new Map<ID, Client_AHT__c> (
            [select Id, B_C_Status__c, B_C_StsDte__c from Client_AHT__c where ID in :CliIds]);

            List<Client_AHT__c> CliUpd = new List<Client_AHT__c>{};
 
            for (Client_AHT__c Cli : CliToUpdate.values()) {
                Cli.B_C_StsDte__c = System.Now();

                update Cli;

                CliUpd.add(Cli);
            }

            if (CliUpd != null && !CliUpd.isEmpty()) {
                Database.update(CliUpd);
            }
        
        }
    }
}
Here is the test class. It has two methods: the first updates a particular client record with a change to B_C_Status__c, and the second updates the record without a change to the field:
@isTest 

private class TST_UpdClient {
 
    static testMethod void UpdRecA() {

        set<Id> CliIds1 = new Set <ID>();

        CliIds1.add('a0N11000002UnIU');
//        CliIds1.add('a0bb000000OB96CAAT');

        Map<ID, Client_AHT__c> CliToUpdate1 = new Map<ID, Client_AHT__c> (
        [select Id, B_C_Status__c, B_C_StsDte__c from Client_AHT__c where ID in :CliIds1]);

        List<Client_AHT__c> CliUpd1 = new List<Client_AHT__c>{};
 
        for (Client_AHT__c Cli1 : CliToUpdate1.values()) {
            Cli1.B_C_Status__c = 'Work complete';

            update Cli1;
            CliUpd1.add(Cli1);
        }

        if (CliUpd1 != null && !CliUpd1.isEmpty()) {
            Database.update(CliUpd1);
        }

    }

    static testMethod void UpdRecB() {

        set<Id> CliIds2 = new Set <ID>();

        CliIds2.add('a0N11000002UnIU');
//        CliIds.add('a0bb000000OB96CAAT');

        Map<ID, Client_AHT__c> CliToUpdate2 = new Map<ID, Client_AHT__c> (
        [select Id, B_C_Status__c, B_C_StsDte__c from Client_AHT__c where ID in :CliIds2]);

        List<Client_AHT__c> CliUpd2 = new List<Client_AHT__c>{};
 
        for (Client_AHT__c Cli2 : CliToUpdate2.values()) {
            Cli2.B_C_Status__c = 'Ongoing';

            update Cli2;
            CliUpd2.add(Cli2);
        }

        if (CliUpd2 != null && !CliUpd2.isEmpty()) {
            Database.update(CliUpd2);
        }

    }

}
P.S. I realise that hard-coding record IDs is not best practice, however it should still work for this purpose (and does in other tests I have written).

Many thanks

Trevor




 
I have a child object for which a profile cannot see the related list on the parent object layout. I can see the related list when signed in as System Administrator. I have checked:
  • The profile has read access rights to the child and parent objects and to all fields on those objects
  • The parent object layout assigned to the profile is correct (there is only one) and has the related list on it
Can't figure out what's missing. One other thing to say is there is no tab for this child object, by design.
Can anyone help please?
Thanks
Trevor
Hi,

I have done lot of research on this already and tried everything I can think of, but I am up against a brick wall.
I have two triggers with code coverage of less than 30%, which bring down my overall coverage below 75%. I have tested them extensively in terms of actual business process, and they work perfectly.The test classes I've written all complete successfully and cover all the conditions in the triggers that I can see, but still coverage is low. Any help would be greatly appreciated! 
The first trigger shows a coverage of 0%. It fires after update on a custom object Client_AHT__c. It checks if a particular picklist value has changed (B_C_Status__c) and if it has, it updates a date field (B_C_StsDte__c):
trigger B_TRG_C_Update on Client_AHT__c (after Update) {

    set<Id> CliIds = new Set <ID>();
   
    for (Client_AHT__c NewCli: Trigger.new) {
        Client_AHT__c oldCli = Trigger.oldMap.get(NewCli.ID);
        
        if (NewCli.B_C_Status__c != oldCli.B_C_Status__c) {

            CliIds.add(NewCli.ID);

            Map<ID, Client_AHT__c> CliToUpdate = new Map<ID, Client_AHT__c> (
            [select Id, B_C_Status__c, B_C_StsDte__c from Client_AHT__c where ID in :CliIds]);

            List<Client_AHT__c> CliUpd = new List<Client_AHT__c>{};
 
            for (Client_AHT__c Cli : CliToUpdate.values()) {
                Cli.B_C_StsDte__c = System.Now();

                update Cli;

                CliUpd.add(Cli);
            }

            if (CliUpd != null && !CliUpd.isEmpty()) {
                Database.update(CliUpd);
            }
        
        }
    }
}
Here is the test class. It has two methods: the first updates a particular client record with a change to B_C_Status__c, and the second updates the record without a change to the field:
@isTest 

private class TST_UpdClient {
 
    static testMethod void UpdRecA() {

        set<Id> CliIds1 = new Set <ID>();

        CliIds1.add('a0N11000002UnIU');
//        CliIds1.add('a0bb000000OB96CAAT');

        Map<ID, Client_AHT__c> CliToUpdate1 = new Map<ID, Client_AHT__c> (
        [select Id, B_C_Status__c, B_C_StsDte__c from Client_AHT__c where ID in :CliIds1]);

        List<Client_AHT__c> CliUpd1 = new List<Client_AHT__c>{};
 
        for (Client_AHT__c Cli1 : CliToUpdate1.values()) {
            Cli1.B_C_Status__c = 'Work complete';

            update Cli1;
            CliUpd1.add(Cli1);
        }

        if (CliUpd1 != null && !CliUpd1.isEmpty()) {
            Database.update(CliUpd1);
        }

    }

    static testMethod void UpdRecB() {

        set<Id> CliIds2 = new Set <ID>();

        CliIds2.add('a0N11000002UnIU');
//        CliIds.add('a0bb000000OB96CAAT');

        Map<ID, Client_AHT__c> CliToUpdate2 = new Map<ID, Client_AHT__c> (
        [select Id, B_C_Status__c, B_C_StsDte__c from Client_AHT__c where ID in :CliIds2]);

        List<Client_AHT__c> CliUpd2 = new List<Client_AHT__c>{};
 
        for (Client_AHT__c Cli2 : CliToUpdate2.values()) {
            Cli2.B_C_Status__c = 'Ongoing';

            update Cli2;
            CliUpd2.add(Cli2);
        }

        if (CliUpd2 != null && !CliUpd2.isEmpty()) {
            Database.update(CliUpd2);
        }

    }

}
P.S. I realise that hard-coding record IDs is not best practice, however it should still work for this purpose (and does in other tests I have written).

Many thanks

Trevor




 

Is there a way to change the Finish button default on a VWF run from a custom button URL that's not referencing a VFP?  Basically I have a simple flow that starts with a button click from a detail page, which opens a new browser window and shows some data along with the standard VWF Finish button. 

 

What I'd like is for finish to close the window, not restart the workflow.