+ Start a Discussion
winniechae1winniechae1 
Hi, I'm confused about features to extend record access beyond the organization-wide defaults. the features are sharing rules & public groups. right? 
I think the features are sharing rules and manual sharing rules..
Ammar P 9Ammar P 9 
Apex class code:
public with sharing class TrackOrderController {
    public string ordernum {get; set;}
    public date orderDate {get; set;}
    public List<Order> Order {get; set;}
    public List<OrderItem> status {get; set;}
    public List<string> vrs {public get; private set;}
    public List<string> pro {public get; private set;} 
    public List<integer> index {public get; private set;}
    
    public PageReference findOrder()
    {
        try{
      
        Order = [SELECT id FROM Order where PoNumber=:ordernum and PoDate =: orderdate ];
        status = [SELECT Product_name__c,Vehicle_Request_Status1__c FROM OrderItem WHERE OrderId =: Order[0].Id];
        system.debug('size-->'+status.size());
        vrs = new List<String>();
        index = new List<integer>();   
        for(integer i=0; i<status.size(); i++){
            index.add(i);
            if(status[i].Vehicle_Request_Status1__c != null){
            vrs.add(status[i].Vehicle_Request_Status1__c);
            }else{
                vrs.add('Null');
            }
        }
           
        system.debug(status);
        system.debug('vrs list--->'+vrs);
        system.debug('index list--->'+index);
        pro = new List<string>();
        for(integer i=0; i<status.size(); i++){
             pro.add(status[i].Product_name__c);
        }

        system.debug('pro list--->'+pro);
        return null;
        }
        catch(Exception ex){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please check purchase number and date')); return null; }
    }
    public PageReference reset() {
        PageReference newpage = new PageReference(System.currentPageReference().getURL());
    newpage.setRedirect(true);
    return newpage;
    }
}


Test class:
@isTest(SeeAllData=true)
public class TrackOrderControllerTest {
    
static testMethod void findOrder(){
  
      Account acc = New Account();
        acc.name = 'test';
        acc.CR_Number__c = '1234567890';
        acc.CustomerName__c = 'test acc';
        acc.CR_Date_English__c = Date.newInstance(2016, 12, 9);
        acc.CR_Capital__c = 12426;
        acc.Current_Revenue__c = 1233;
        acc.Special_Admin_Rate__c = 123456;
        acc.Security_Type__c = 'ghayth';
        acc.ID_Issuer__c = 'asdasd';
        acc.CR_City__c = 'asdasd';
        acc.Workforce__c = 'sdadad';
        acc.In_Business__c = 'sdasdasdas';
        acc.Nationality_of_Business__c = 'India';
        acc.Arabic_Date__c = Date.newInstance(2016, 10, 7);
        acc.Company_Establishment__c = 'sdads';
        acc.Bank2__c = 'sdfdsf';
        acc.City_Region__c = 'sadf';
        insert acc;  
        
        Product2 newProduct = new Product2();
        newProduct.name = 'abc';
        newProduct.Varient__c = 'asd';
        newProduct.Make__c = 'AMI';
        newProduct.Model__c = 'SEMI TRAILER';
        newProduct.ModelYear__c = 2018;
        newProduct.Fuel_Type__c = 'Petrol';
        newProduct.Transmission__c = 'Powershift';
        newProduct.Internal_Purchase_Price__c = 25;
        newProduct.Registration_Fee__c = 25;
        Insert newProduct;
        
         Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
        insert customPB;
        
        PricebookEntry customPrice = new PricebookEntry(
            Pricebook2Id = customPB.Id, Product2Id =newProduct.Id,
            UnitPrice = 12000, IsActive = true);
        insert customPrice;
        
    Order ord = new Order ();
    ord.AccountId =acc.Id;
        ord.PoNumber='PO67543';
        ord.PoDate = Date.newInstance(2016, 10, 5);
        ord.Status ='Draft';
        ord.EffectiveDate= system.today();
        ord.Pricebook2Id = customPB.Id;
    insert ord;
    
    OrderItem orditem = new OrderItem();
    orditem.OrderId = ord.Id;
        Orditem.Vehicle_Request_Status1__c ='PO Approved';
        orditem.PricebookEntryId =customPrice.Id;
        orditem.UnitPrice= 678;
        orditem.Quantity= 7;
    insert orditem;
        
      
    /*  list<OrderItem>status=new List<OrderItem>();
        list<integer>index=new List<integer>();
        status = [SELECT Product_name__c,Vehicle_Request_Status1__c FROM OrderItem WHERE OrderId =: ord.Id];
    for(integer i=0; i<status.size(); i++){
            index.add(i);
        } */
         PageReference testPage = Page.TrackOrder;
         Test.setCurrentPage(testPage);
         testPage.getParameters().put('Id', String.valueOf(ord.Id));
    Test.StartTest(); 
      ApexPages.StandardController sc = new ApexPages.StandardController(ord);
            TrackOrderController  testord = new TrackOrderController();
      testord.findOrder();
      testord.reset ();

    Test.StopTest();
        
  }
}
Ammar P 9Ammar P 9 
Apex Trigger:
trigger ContactTrigger on Contact (before insert,after insert) {
if(Trigger.isInsert && Trigger.isAfter){
        ContactTriggerHelper.UpdateOpportunity(Trigger.New);
    }
}
Maok kinesleMaok kinesle 
Original code:
public class MessageAlert {
    @auraenabled
    public static Boolean getmessages(String recordId){
        Boolean checkExpDate = False;
        List<LVSCR_c> contactList = new List<LVSCR_c>();
        Set<String> newSet = new Set<String>();
        //     Set<String> existingSet = new Set<String>();
        for ( LVSCR__c lvs : contactList ) {
            system.debug(lvs);
            if ( lvs.Contact__c != null ) {
                newSet.add(lvs.Contact__c);
            }
        }
        system.debug('newset--->>'+newSet);
        
        List <LVSCR_c> soql = new List<LVSCR_c>();
        soql = [SELECT Id,Contact_c FROM LVSCRc WHERE Id =: recordId AND Contact_c IN: newSet];
        system.debug('soql--->'+soql);
        if(soql.size()>0){
                //checkExpDate = True;
        }
        else{
                checkExpDate = False;
        }
        return checkExpDate;
    }
}

I hav tried but Its not covering the whole code.
apex test class:

@isTest
private class MessageAlertTest{
        @isTest
        static boolean getmessages(){
            List<LVSCR_c> conlist = new List<LVSCR_c>();
            Boolean checkExpDate = False;

            Lvscr_c lvscrcObj = new Lvscr_c ();
            lvscrcObj.Id='0012600001Ck4AEAA';
            lvscrcObj.Contact__c = '0012600001Ck4AEAA'; 
            lvscrcObj.Delivery_Type__c ='Original'; 
            lvscrcObj.LAFS__c = '122255'; 
            lvscrcObj.Tamm_Authorisation__c ='Yes';
            conlist.add(lvscrcObj);
            update conlist; 
            return checkExpDate;
      
         
    }

    @isTest static void testMethod1() {
        // code_block    
    }

    @isTest static void testMethod2() {
        // code_block    
    }
}
Anuj Gupta 106Anuj Gupta 106 
Hi everyone, I am having this error when doing the project "Customize the User Interface for a Recruiting App > Create a Customer Candidate Record Page":

There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id:QLDFDJNI
Fritzgerald CajaFritzgerald Caja 
Hi everyone, I am having this error when doing the project "Customize the User Interface for a Recruiting App > Create a Customer Candidate Record Page":

There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: TTNMBDZD
Best Answer chosen by Fritzgerald Caja
Fritzgerald CajaFritzgerald Caja
These are what I have tried:
  • Created a new playground with the installed package Recruiting App on 'Build a Data Model
    for a Recruiting App' project
  • Created another playground without the installed packaged where I manually created the candidate object then went to create a new Compact Layout
  • Created a new DE org with the installed package Recruiting App on 'Build a Data Model
    for a Recruiting App' project
  • Created another DE org without the installed packaged where I manually created the candidate object then went to create a new Compact Layout
Out of all the ideas I've thought, I managed to verify the step by logging out and logging back in to my Trailhead account.

What exactly happened was I called it a day last night on finding a solution, which Salesforce automatically logged me out when I came back this morning. I logged in and tried to verify using the original playground I used then it went through.

I hope this is helpful.
Denys FedyshynDenys Fedyshyn 

Hello, community!

I'll almost complete customization superbadge but faced a problem. 

"There was an unhandled exception. Please reference ID: UOBMOJCB. Error: Restforce::ErrorCode::MalformedQuery. Message: MALFORMED_QUERY: When retrieving results with Metadata or FullName fields, the query qualificatio​ns must specify no more than one row for retrieval. Result size: 2"

Can anyone suggest what should I do?
Thanks in advance!

Suma AithalSuma Aithal 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: PNIUJWUX. 
Please help me with this error!!!
Ammar P 9Ammar P 9 
Apex Class:
public class Activelineitem {
    @AuraEnabled
    Public static void ActiveProduct(String oppId, String ProductId, Integer leasePeriod, Integer productQuantity, Decimal AdminSlab, OpportunityLineItem oli, List<OpportunityLineItem> oliList){
        List<OpportunityLineItem> updateOpplineItem = new List<OpportunityLineItem>();
        system.debug('leasePeriod from main class--->>'+leasePeriod);
        List<Opportunity> opplst = [Select AccountId from opportunity where id =: oppId];
        List<Special_Pricing__c> spclList = [Select id,name,Valid_thru__c,AccountLookup__c,Opportunity_Product__r.Product2Id,Approval_status__c
                                             From Special_Pricing__c where AccountLookup__c =: opplst[0].AccountId LIMIT 100];
        system.debug('spclList--->>>>'+spclList);
        //Check for valid special pricing record
        List<Special_Pricing__c> specialPricingRec = new List<Special_Pricing__c>();
        for(Special_Pricing__c spcl : spclList){
            if(spcl.Opportunity_Product__r.Product2Id == ProductId && spcl.Approval_status__c=='Approved by CFO'){
               
                if(spcl.Valid_thru__c == null){
                    specialPricingRec.add(spcl);
                    system.debug('Active product-->'+spcl.Name);
                }
            }
        }
        system.debug('specialPricingRec-->'+specialPricingRec);
        List<Special_Pricing_Set__c> spSetList = new List<Special_Pricing_Set__c>();
        if(specialPricingRec.size() > 0){
            spSetList = [Select id, name,Is_Activecorrect__c From Special_Pricing_Set__c Where Special_Pricing__c=:specialPricingRec[0].id AND Is_Activecorrect__c=:True];
        }
         system.debug('spSetList-->'+spSetList);
        if(spSetList.size() > 0){
            String BreakEvenRecordId = fetchSPBreakEvenDetails(ProductId,AdminSlab,leasePeriod,spSetList[0].id);
            system.debug('BreakEvenRecordId--->>'+BreakEvenRecordId);
            if(!String.isEmpty(BreakEvenRecordId)){
                if(leasePeriod == 1){
                    oli.SP_Break_Even_Ist_year__c = BreakEvenRecordId;
                    oli.SP_Break_Even_2nd_year__c = NULL;
                    oli.SP_Break_Even_3rd_year__c = NULL;
                    oli.SP_Break_Even_4th_year__c = NULL;
                    oli.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(leasePeriod == 2){
                    oli.SP_Break_Even_Ist_year__c = NULL;
                    oli.SP_Break_Even_2nd_year__c = BreakEvenRecordId;
                    oli.SP_Break_Even_3rd_year__c = NULL;
                    oli.SP_Break_Even_4th_year__c = NULL;
                    oli.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(leasePeriod == 3){
                    oli.SP_Break_Even_Ist_year__c = NULL;
                    oli.SP_Break_Even_2nd_year__c = NULL;
                    oli.SP_Break_Even_3rd_year__c = BreakEvenRecordId;
                    oli.SP_Break_Even_4th_year__c = NULL;
                    oli.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(leasePeriod == 4){
                    oli.SP_Break_Even_Ist_year__c = NULL;
                    oli.SP_Break_Even_2nd_year__c = NULL;
                    oli.SP_Break_Even_3rd_year__c = NULL;
                    oli.SP_Break_Even_4th_year__c = BreakEvenRecordId;
                    oli.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(leasePeriod == 5){
                    oli.SP_Break_Even_Ist_year__c = NULL;
                    oli.SP_Break_Even_2nd_year__c = NULL;
                    oli.SP_Break_Even_3rd_year__c = NULL;
                    oli.SP_Break_Even_4th_year__c = NULL;
                    oli.SP_Break_Even_5th_year__c = BreakEvenRecordId;
                   
                }
                oli.Special_Pricing_Applied__c = true;
                updateOpplineItem.add(oli);
                update oli;
                OpportunityLineItemHelper1.insertOpportunityLineItem(updateOpplineItem);
            }
           
        }
       
        //Update Accessories
        Map<String, Special_Pricing_Tier_Set__c> oliSpMap = new Map<String, Special_Pricing_Tier_Set__c>();
        Id recordTypeId = Schema.SObjectType.Special_Pricing_Tier_set__c.getRecordTypeInfosByName().get('Accessories').getRecordTypeId();
        //system.debug('oliList -->>'+oliList);
        if(oliList.size() > 0 && spSetList.size() > 0){
            for(OpportunityLineItem oliItem : oliList){
                Special_Pricing_Tier_Set__c spt = new Special_Pricing_Tier_Set__c();
                spt.RecordTypeId = recordTypeId;
                spt.Product__c = ProductId;
                spt.Special_Pricing_Set__c = spSetList[0].id;
                spt.One_year__c = TRUE;
                spt.Two_year__c = TRUE;
                spt.Three_year__c = TRUE;
                spt.Four_year__c = TRUE;
                spt.Five_year__c = TRUE;
                spt.Accessories_Name__c = oliItem.Accessories__r.Accessories_Name__c;
                spt.Cost_per_month__c = oliItem.Accessories__r.Cost_per_month__c;
                spt.Monthly_Charge__c = oliItem.Accessories__r.Monthly_Charge__c;
                oliSpMap.put(oliItem.Id, spt);
            }
            system.debug('oliSpMap -->>'+oliSpMap);
            try{
                insert oliSpMap.values();
            }
            catch(Exception e){
                system.debug('Exception--->>'+e.getMessage());
            }
            //system.debug('oliSpMap===>>'+oliSpMap);
            Map<String,OpportunityLineItem> oliMap = new Map<String,OpportunityLineItem>();
            for(OpportunityLineItem oliItem : [Select Id, Name,Break_Even_1st_year__c,Break_Even_2nd_year__c,Break_Even_3rd_year__c,
                                               Break_Even_4th_year__c,Break_Even_5th_year__c,Accessories__c,Lease_Period__c
                                               From OpportunityLineItem Where Id IN:oliSpMap.keySet()]){
                                                   oliMap.put(oliItem.Id, oliItem);
                                               }
            List<OpportunityLineItem> updateOli = new List<OpportunityLineItem>();
            for(String oliVal : oliSpMap.keySet()){
                OpportunityLineItem oliUpdate = new OpportunityLineItem();
                oliUpdate = oliMap.get(oliVal);
                oliUpdate.Accessories_Sp__c = oliSpMap.get(oliVal).Id;
               
                // add lease amount
                if(oliUpdate.Lease_Period__c == '1'){                    
                    oliUpdate.SP_Break_Even_Ist_year__c = oliSpMap.get(oliVal).Id;
                    oliUpdate.SP_Break_Even_2nd_year__c = NULL;
                    oliUpdate.SP_Break_Even_3rd_year__c = NULL;
                    oliUpdate.SP_Break_Even_4th_year__c = NULL;
                    oliUpdate.SP_Break_Even_5th_year__c = NULL;                    
                   
                }
                if(oliUpdate.Lease_Period__c == '2'){
                    oliUpdate.SP_Break_Even_Ist_year__c = NULL;
                    oliUpdate.SP_Break_Even_2nd_year__c = NULL;
                    oliUpdate.SP_Break_Even_3rd_year__c = oliSpMap.get(oliVal).Id;
                    oliUpdate.SP_Break_Even_4th_year__c = NULL;
                    oliUpdate.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(oliUpdate.Lease_Period__c == '3'){
                    oliUpdate.SP_Break_Even_Ist_year__c = NULL;
                    oliUpdate.SP_Break_Even_2nd_year__c = NULL;
                    oliUpdate.SP_Break_Even_3rd_year__c = oliSpMap.get(oliVal).Id;
                    oliUpdate.SP_Break_Even_4th_year__c = NULL;
                    oliUpdate.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(oliUpdate.Lease_Period__c == '4'){
                    oliUpdate.SP_Break_Even_Ist_year__c = NULL;
                    oliUpdate.SP_Break_Even_2nd_year__c = NULL;
                    oliUpdate.SP_Break_Even_3rd_year__c = NULL;
                    oliUpdate.SP_Break_Even_4th_year__c = oliSpMap.get(oliVal).Id;
                    oliUpdate.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(oliUpdate.Lease_Period__c == '5'){
                    oliUpdate.SP_Break_Even_Ist_year__c = NULL;
                    oliUpdate.SP_Break_Even_2nd_year__c = NULL;
                    oliUpdate.SP_Break_Even_3rd_year__c = NULL;
                    oliUpdate.SP_Break_Even_4th_year__c = NULL;
                    oliUpdate.SP_Break_Even_5th_year__c = oliSpMap.get(oliVal).Id;
                   
                }
                oliUpdate.Special_Pricing_Applied__c = true;
                updateOli.add(oliUpdate);
            }
            try{
                update updateOli;
            }
            catch(Exception e){
                system.debug('Exception -->>'+e.getMessage());
            }
            OpportunityLineItemHelper1.insertOpportunityLineItem(updateOli);
        }
    }
   
   
    @AuraEnabled
    Public static String fetchSPBreakEvenDetails(String ProductId, Decimal AdminSlab, Integer leasePeriod, String spSetId){
        system.debug('ProductId-->>'+ProductId);
        system.debug('AdminSlab-->>'+AdminSlab);
        system.debug('leasePeriod-->>'+leasePeriod);
        system.debug('spSetId-->>'+spSetId);
        if(leasePeriod == 1){
            List<Special_Pricing_Tier_Set__c> spriceTierSetList = new List<Special_Pricing_Tier_Set__c>();
            spriceTierSetList = [Select Id, Name From Special_Pricing_Tier_Set__c Where Special_Pricing_Set__r.Special_Pricing__r.Opportunity_Product__r.Product2Id =:ProductId AND Special_Pricing_Set__c=:spSetId
                                 AND One_year__c=TRUE AND Two_year__c=FALSE AND Three_year__c=FALSE AND Four_year__c=FALSE
                                 AND Five_year__c=FALSE LIMIT 1];
            if(spriceTierSetList.size() >0 ){
                return spriceTierSetList[0].id;
            }
            else{
                return '';
            }
        }
        else if(leasePeriod == 2){
            List<Special_Pricing_Tier_Set__c> spriceTierSetList = new List<Special_Pricing_Tier_Set__c>();
            spriceTierSetList = [Select Id, Name From Special_Pricing_Tier_Set__c Where Special_Pricing_Set__r.Special_Pricing__r.Opportunity_Product__r.Product2Id =:ProductId AND Special_Pricing_Set__c=:spSetId AND One_year__c=TRUE AND
                                 Two_year__c=TRUE AND Three_year__c=FALSE AND Four_Year__c=FALSE AND Five_year__c=FALSE LIMIT 1];
           
            if(spriceTierSetList.size() >0 ){
                return spriceTierSetList[0].id;
            }
            else{
                return '';
            }
        }
        else if(leasePeriod == 3){
            List<Special_Pricing_Tier_Set__c> spriceTierSetList = new List<Special_Pricing_Tier_Set__c>();
            spriceTierSetList = [Select Id, Name From Special_Pricing_Tier_Set__c Where Special_Pricing_Set__r.Special_Pricing__r.Opportunity_Product__r.Product2Id =:ProductId AND Special_Pricing_Set__c=:spSetId AND One_year__c=TRUE AND
                                 Two_year__c=TRUE AND Three_year__c=TRUE AND Four_Year__c=FALSE AND Five_Year__c=FALSE LIMIT 1];
           
            if(spriceTierSetList.size() >0 ){
                return spriceTierSetList[0].id;
            }
            else{
                return '';
            }
        }
        else if(leasePeriod == 4){
            List<Special_Pricing_Tier_Set__c> spriceTierSetList = new List<Special_Pricing_Tier_Set__c>();
            spriceTierSetList = [Select Id, Name From Special_Pricing_Tier_Set__c Where Special_Pricing_Set__r.Special_Pricing__r.Opportunity_Product__r.Product2Id =:ProductId AND Special_Pricing_Set__c=:spSetId AND One_year__c=TRUE AND
                                 Two_year__c=TRUE AND Three_year__c=TRUE AND Four_Year__c=TRUE AND Five_Year__c=FALSE LIMIT 1];
           
            if(spriceTierSetList.size() >0 ){
                return spriceTierSetList[0].id;
            }
            else{
                return '';
            }
        }
        else if(leasePeriod == 5){
            List<Special_Pricing_Tier_Set__c> spriceTierSetList = new List<Special_Pricing_Tier_Set__c>();
            spriceTierSetList = [Select Id, Name From Special_Pricing_Tier_Set__c Where Special_Pricing_Set__r.Special_Pricing__r.Opportunity_Product__r.Product2Id =:ProductId AND Special_Pricing_Set__c=:spSetId AND One_year__c=TRUE AND
                                 Two_year__c=TRUE AND Three_year__c=TRUE AND Four_Year__c=TRUE AND Five_Year__c=TRUE LIMIT 1];
           
            if(spriceTierSetList.size() >0 ){
                return spriceTierSetList[0].id;
            }
            else{
                return '';
            }
        }
        else{
            return '';
        }
    }
}