• Martin Dernerxn
  • -2 Points
  • Member since 2023

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 10
In superbadge im getting this error even ive tried all the chages still it is showing "Challenge Not yet complete... here's what's wrong:
The 'MaintenanceRequest' trigger did not achieve 100% code coverage via your test methods. Make sure to 'Run All' tests in the Developer Console at least once before attempting to verify this challenge."

this is my code :
trigger MaintenanceRequest on Case (before update, after update) {
    if(Trigger.isUpdate && Trigger.isAfter){
        MaintenanceRequestHelper.updateWorkOrders(Trigger.New, Trigger.OldMap);

public with sharing class MaintenanceRequestHelper {
    public static void updateworkOrders(List<Case> updWorkOrders, Map<Id,Case> nonUpdCaseMap) {
        Set<Id> validIds = new Set<Id>();
        For (Case c : updWorkOrders){
            if (nonUpdCaseMap.get(c.Id).Status != 'Closed' && c.Status == 'Closed'){
                if (c.Type == 'Repair' || c.Type == 'Routine Maintenance'){
        //When an existing maintenance request of type Repair or Routine Maintenance is closed, 
        //create a new maintenance request for a future routine checkup.
        if (!validIds.isEmpty()){
            Map<Id,Case> closedCases = new Map<Id,Case>([SELECT Id, Vehicle__c, Equipment__c, Equipment__r.Maintenance_Cycle__c,
                                                          (SELECT Id,Equipment__c,Quantity__c FROM Equipment_Maintenance_Items__r) 
                                                          FROM Case WHERE Id IN :validIds]);
            Map<Id,Decimal> maintenanceCycles = new Map<ID,Decimal>();
            //calculate the maintenance request due dates by using the maintenance cycle defined on the related equipment records. 
            AggregateResult[] results = [SELECT Maintenance_Request__c, 
                                         FROM Equipment_Maintenance_Item__c 
                                         WHERE Maintenance_Request__c IN :ValidIds GROUP BY Maintenance_Request__c];
            for (AggregateResult ar : results){ 
                maintenanceCycles.put((Id) ar.get('Maintenance_Request__c'), (Decimal) ar.get('cycle'));
            List<Case> newCases = new List<Case>();
            for(Case cc : closedCases.values()){
                Case nc = new Case (
                    ParentId = cc.Id,
                    Status = 'New',
                    Subject = 'Routine Maintenance',
                    Type = 'Routine Maintenance',
                    Vehicle__c = cc.Vehicle__c,
                    Equipment__c =cc.Equipment__c,
                    Origin = 'Web',
                    Date_Reported__c = Date.Today() 
                //If multiple pieces of equipment are used in the maintenance request, 
                //define the due date by applying the shortest maintenance cycle to today’s date.
                //If (maintenanceCycles.containskey(cc.Id)){
                    nc.Date_Due__c = Date.today().addDays((Integer) maintenanceCycles.get(cc.Id));
                //} else {
                //    nc.Date_Due__c = Date.today().addDays((Integer) cc.Equipment__r.maintenance_Cycle__c);
            insert newCases;
            List<Equipment_Maintenance_Item__c> clonedList = new List<Equipment_Maintenance_Item__c>();
            for (Case nc : newCases){
                for (Equipment_Maintenance_Item__c clonedListItem : closedCases.get(nc.ParentId).Equipment_Maintenance_Items__r){
                    Equipment_Maintenance_Item__c item = clonedListItem.clone();
                    item.Maintenance_Request__c = nc.Id;
            insert clonedList;

public with sharing class MaintenanceRequestHelperTest {
    // createVehicle
    private static Vehicle__c createVehicle(){
        Vehicle__c vehicle = new Vehicle__C(name = 'Testing Vehicle');
        return vehicle;
    // createEquipment
    private static Product2 createEquipment(){
        product2 equipment = new product2(name = 'Testing equipment',
                                          lifespan_months__c = 10,
                                          maintenance_cycle__c = 10,
                                          replacement_part__c = true);
        return equipment;
    // createMaintenanceRequest
    private static Case createMaintenanceRequest(id vehicleId, id equipmentId){
        case cse = new case(Type='Repair',
                            Subject='Testing subject',
        return cse;
    // createEquipmentMaintenanceItem
    private static Equipment_Maintenance_Item__c createEquipmentMaintenanceItem(id equipmentId,id requestId){
        Equipment_Maintenance_Item__c equipmentMaintenanceItem = new Equipment_Maintenance_Item__c(
            Equipment__c = equipmentId,
            Maintenance_Request__c = requestId);
        return equipmentMaintenanceItem;
    private static void testPositive(){
        Vehicle__c vehicle = createVehicle();
        insert vehicle;
        id vehicleId = vehicle.Id;
        Product2 equipment = createEquipment();
        insert equipment;
        id equipmentId = equipment.Id;
        case createdCase = createMaintenanceRequest(vehicleId,equipmentId);
        insert createdCase;
        Equipment_Maintenance_Item__c equipmentMaintenanceItem = createEquipmentMaintenanceItem(equipmentId,createdCase.id);
        insert equipmentMaintenanceItem;
        createdCase.status = 'Closed';
        update createdCase;
        Case newCase = [Select id, 
                       from case
                       where status ='New'];
        Equipment_Maintenance_Item__c workPart = [select id
                                                  from Equipment_Maintenance_Item__c
                                                  where Maintenance_Request__c =:newCase.Id];
        list<case> allCase = [select id from case];
        system.assert(allCase.size() == 2);
        system.assert(newCase != null);
        system.assert(newCase.Subject != null);
        system.assertEquals(newCase.Type, 'Routine Maintenance');
        SYSTEM.assertEquals(newCase.Equipment__c, equipmentId);
        SYSTEM.assertEquals(newCase.Vehicle__c, vehicleId);
        SYSTEM.assertEquals(newCase.Date_Reported__c, system.today());
    private static void testNegative(){
        Vehicle__C vehicle = createVehicle();
        insert vehicle;
        id vehicleId = vehicle.Id;
        product2 equipment = createEquipment();
        insert equipment;
        id equipmentId = equipment.Id;
        case createdCase = createMaintenanceRequest(vehicleId,equipmentId);
        insert createdCase;
        Equipment_Maintenance_Item__c workP = createEquipmentMaintenanceItem(equipmentId, createdCase.Id);
        insert workP;
        createdCase.Status = 'Working';
        update createdCase;
        list<case> allCase = [select id from case];
        Equipment_Maintenance_Item__c equipmentMaintenanceItem = [select id 
                                                  from Equipment_Maintenance_Item__c 
                                                  where Maintenance_Request__c = :createdCase.Id];
        system.assert(equipmentMaintenanceItem != null);
        system.assert(allCase.size() == 1);
    private static void testBulk(){
        list<Vehicle__C> vehicleList = new list<Vehicle__C>();
        list<Product2> equipmentList = new list<Product2>();
        list<Equipment_Maintenance_Item__c> equipmentMaintenanceItemList = new list<Equipment_Maintenance_Item__c>();
        list<case> caseList = new list<case>();
        list<id> oldCaseIds = new list<id>();
        for(integer i = 0; i < 300; i++){
        insert vehicleList;
        insert equipmentList;
        for(integer i = 0; i < 300; i++){
            caseList.add(createMaintenanceRequest(vehicleList.get(i).id, equipmentList.get(i).id));
        insert caseList;
        for(integer i = 0; i < 300; i++){
            equipmentMaintenanceItemList.add(createEquipmentMaintenanceItem(equipmentList.get(i).id, caseList.get(i).id));
        insert equipmentMaintenanceItemList;
        for(case cs : caseList){
            cs.Status = 'Closed';
        update caseList;
        list<case> newCase = [select id
                                  from case
                                  where status ='New'];

        list<Equipment_Maintenance_Item__c> workParts = [select id
                                                         from Equipment_Maintenance_Item__c
                                                         where Maintenance_Request__c in: oldCaseIds];
        system.assert(newCase.size() == 300);
        list<case> allCase = [select id from case];
        system.assert(allCase.size() == 600);
I am trying to create a form using LWC to create a new record. I added few lightning-input-fields in the lightning-record-edit-form component. Out of 7 fields I added, the form is displaying only first 3 fields and the next button while the remaining fields are not getting displayed. I checked the FLS of the fields on the custom object. All the fields have edit access. Can anyone let me know what am I missing here?
<lightning-record-edit-form object-api-name="Event__c" density="comfy">
          <lightning-messages> </lightning-messages>
          <div class="stepOne">
              <lightning-input-field field-name="DateReported__c" required="true" class="dateAEReported"></lightning-input-field>
              <lightning-input-field field-name="ReportingMethod__c" onchange={checkSelVal} class="reportingMethod"></lightning-input-field>
              <lightning-input-field field-name="ReportingMethodOther__c" required={makeRequired} class="otherReportingMethod"></lightning-input-field>
              <lightning-input-field field-name="Called_with_intent_to_report__c"></lightning-input-field>
              <lightning-input-field field-name="Reporter_requested_information__c"></lightning-input-field>
              <lightning-input-field field-name="Study_ID__c"></lightning-input-field>
              <lightning-input-field field-name="Partner_reference_number__c"></lightning-input-field>
                  class="slds-m-top_small slds-float_right"
          <div class="stepTwo slds-hide">
              <lightning-input-field field-name="LastName"></lightning-input-field>

Following the above steps, I am keeping on getting this error in running this command, any idea why? I am using free Developer edition online.
sfdx auth:jwt:grant --clientid mQ_ZAy3OwMRG2dGPyIt8KME3N --jwtkeyfile C:\Users\hujir\JWT\server.key --username jirong.hu@playful-bear-6bongz.com  --setdefaultdevhubusername --setalias my-hub-org
Created a new Custom object ,now i want to create this Custom Object as Tab in the App ,but when i create a "Lightning App",can't see the Custom object in Navigation Items,I checked in profiles as well ,i had full access to the custom object as i am salesforce admin

User-added image
Your help is highly appreciated

Hi , 
Thank you in advance.
I want to add custom error message in community login page when deactivated user tried to login he should get "please check your mail "  instead "Your access is disabled. Contact your site administrator." this standard message

User-added image

Please anyone suggest the solution with code in ligntning

The Certificate was uploaded and visible in the “Certificate and Key Management” section.    

Your support or any guidance is greatly appreciated.

Thank you!
User-added image

I'm not able to complete #2 Automate Accounts. It give me the following error.
"Challenge Not yet complete... here's what's wrong:
Please check the configuration of the custom fields on the Account object. The formulas, rollup summaries, etc. did not produce the expected outcome."

Can anyone tell me what went wrong? Thanks.

My Custom Fields configuration are as following:
  • Number of deals (Roll-Up Summary field): Count Opportunity. No filter criteria
  • Number of won deals (Roll-Up Summary field): Count Opportunity with filter criteria as "Stage equals Closed Won"
  • Last won deal date (Roll-Up Summary field): MAX(Opportunity: Close Date) with filter criteria as "Stage equals Closed Won"
  • Deal win % (Formula field): Number_of_won_deals__c / Number_of_deals__c
  • Total amount of won deals (Roll-Up Summary field): SUM(Opportunity: Amount) with filter criteria as "Stage equals Closed Won"
  • Call for Service (Formula field): IF( DATE( YEAR(Last_won_deal_date__c)+2 , MONTH(Last_won_deal_date__c) , DAY(Last_won_deal_date__c) ) <= TODAY(), 'YES', 'NO')
Hello Friends,
I have this  below code.
<apex:page standardController="Account">
    {! Account.Name }
    {! Account.Phone}
I can comment the code by standard way (" <!-- This is commented part --> ") which I can do with few clicks.

Is there a way using the keyboard shortcut to do so? MS Visual Studio has it. May be the Eclipse too, although not sure.

Please help, thanks!

Is there a way to get a list of Account records (parent) with no child records associated (Opportunity)  via SOQL?

I am trying to avoid doinf this in Apex, like getting the AccountId values from Opportunity and then query accounts where id not in this list.


Is it possible to get this list through SQOL?

Here is my query (I need only the accounts that have no associated Opportunity records):


SELECT a.Id, a.Name, (Select id from Opportunities) from Account a order by a.Name




 We need to execute a query on behalf of another user.


Ex: User creates an Action Item record (think of it as question to the field force), the question needs to apply only to Accounts accessible to the user. To do so we have an intermediate object, ActionItemAccount.


ActionItemAccount is refreshed nightly to reflect any changes in the users's access overtime. 

The batch Deletes existing records, and recreates records based on the currently accessible to the user Accounts.

To do so the batch needs to query the Account object (Run As) the Owner of the Action Item.


Hope the above makes sense, can you please share your thoughts on the desired approach,


thank you,


  • August 16, 2010
  • Like
  • 0