• Harvey2016
  • NEWBIE
  • 15 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
 I was working on a practice scenario when if Hello field on Opportunity is empty before inserting and updating. the field should filled with world. Below is my code. Can someone tell me where I did wrong 

 
public class OppHelloWorld
 {
 public void addHelloWorld(List<opportunity> opps)
 {
 for (Opportunity o:opps)
 {
 if (o.Hello__c != 'World')
 {
 o.Hello__c = 'World';
 }
 }
 }
 }
Below is the Trigger Code:
 
trigger HelloWorld on Opportunity (Before Insert, Before update) {

List <Opportunity> Opps = new List<Opportunity>();
OppHelloWorld OHW = New OppHelloWorld();
OHW.addHelloWorld(Opps);
}


 
I am getting this message "This page isn't available in Salesforce Lightning Experience or Salesforce1." when trying to finish this "https://trailhead.salesforce.com/projects/trailhead_on_mars/steps/trailhead_on_mars_step_4" challenge. Can someone tell me why am i getting this error message. thanks!

 
This is my VF Page
<apex:page StandardController="VM_Sales_Order__c" extensions="Reallocation_OrderClass">
    <apex:form >
        <apex:pageMessages id="errorMessage" />
        <apex:pageBlock title="Order Reallocation Page" id="abc">
            <apex:pageBlockButtons >        
                <apex:commandButton value="Save" action="{!updateRec}" / >
                    <apex:commandButton value="Cancel" action="{!cancelRec}" immediate="true"/>
                </apex:pageBlockButtons>
                <apex:pageBlockSection title="Update">
                    <apex:outputField value="{!vmo.Name}"/>
                    <apex:inputField value="{!vmo.Reallocation_Territory__c}" label="Reallocation Territory" >
                        <apex:actionSupport event="onchange" action="{!getTerrDetails}" reRender="abc,vms" status="actnstatus" />
                    </apex:inputField>
                    <apex:outputField value="{!vmo.Sales_Territory__c}"/>
                    <apex:outputField value="{!vmo.Shipping_Address__c}"/>
                    <apex:outputField value="{!vmo.Shipping_Address__r.SoldInCountry__c}"/>
                    
                    <apex:inputField value="{!vmo.VM_SalesDescription__c}" />
                    
                    
                </apex:pageBlockSection>
            </apex:pageBlock>
            <apex:outputPanel >
                <apex:actionstatus id="actnstatus">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb; height: 100%;opacity:0.55;width:100%;">                                                                         
                            <div class="waitingHolder" style="top: 74.2px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Please Wait...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus>
            </apex:outputpanel>
        </apex:form> 
    </apex:page

My extension Class


public class Reallocation_OrderClass {    
    public id vmID;
    public Territory__c Terr{get;set;}
    public VM_Sales_Order__c vmo{get;set;}
    public List<Order_Reallocation__c > ord= new List<Order_Reallocation__c >();    
    public List<Order_Reallocation__c> updateList = new List<Order_Reallocation__c>();
    set<Id> oldTerrId =  New set<Id>();
    set<Id> newTerrId =  New set<Id>();
    set<String> oldTerrDes =  New set<String>();
    set<String> newTerrDes =  New set<String>();
    public Reallocation_OrderClass(ApexPages.StandardController controller) {
        vmo= (VM_Sales_Order__c)controller.getRecord();
        vmID=ApexPages.currentPage().getParameters().get('id');
        vmo =[select  Name,Sales_Territory__c,Reallocation_Territory__c,Shipping_Address__c,Shipping_Address__r.SoldInCountry__c,VM_SalesDescription__c from VM_Sales_Order__c where id=:vmID]; 
        oldTerrId.add(vmo.Reallocation_Territory__c);
        oldTerrDes.add(vmo.VM_SalesDescription__c);
        System.debug('Old vmo Reallocation_Territory'+ vmo.Reallocation_Territory__c);
    }
    public void getTerrDetails()
    {
        
        if(vmo.Reallocation_Territory__c!= Null){
            System.debug('New vmo Reallocation_Territory'+ vmo.Reallocation_Territory__c);
            Terr=[select id,name from Territory__c where id=:vmo.Reallocation_Territory__c];
            vmo.Sales_Territory__c=Terr.name;    
        }                
    }
    public pageReference updateRec(){
        newTerrId.add(vmo.Reallocation_Territory__c); 
        newTerrDes.add(vmo.VM_SalesDescription__c);
        if(vmo.VM_SalesDescription__c==null)
        {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Description field is mandatory to save the record.')); 
        }
        else{
            update vmo;   
            if(oldTerrId!=newTerrId || oldTerrDes!=newTerrDes)                   
            {        
                ord=[select id,VM_Sales_Order__c,SFDC_Order_Id__c,SoldInCountry__c,SoldInTerritory__c,Order_realloc_Description__c from Order_Reallocation__c where 
                     VM_Sales_Order__c =:vmo.id ];    
                
                if(ord.isEmpty())        
                {
                    Order_Reallocation__c   ordRec = new Order_Reallocation__c();
                    ordRec .VM_Sales_Order__c = vmid;
                    ordRec .SFDC_Order_Id__c= vmo.Name;
                    ordRec .SoldInCountry__c= vmo.Shipping_Address__r.SoldInCountry__c;    
                    ordRec .SoldInTerritory__c= vmo.Reallocation_Territory__c;
                    ordRec .Order_realloc_Description__c =vmo.VM_SalesDescription__c;        
                    insert ordRec ; 
                }                              
                else {    
                    for(Order_Reallocation__c  upord :ord)
                    {
                        upord .VM_Sales_Order__c = vmid;
                        upord .SFDC_Order_Id__c= vmo.Name;
                        upord .SoldInCountry__c= vmo.Shipping_Address__r.SoldInCountry__c;    
                        upord .SoldInTerritory__c= vmo.Reallocation_Territory__c;
                        upord .Order_realloc_Description__c =vmo.VM_SalesDescription__c;        
                        update upord;  
                        updateList.add(upord);
                    }  
                    update updateList;
                }
                
                
            }    
            return new pagereference('/'+vmID);
        }
        return null;
    }     
    public pageReference cancelRec(){
        return new pagereference('/'+vmID);
    }
}
 I was working on a practice scenario when if Hello field on Opportunity is empty before inserting and updating. the field should filled with world. Below is my code. Can someone tell me where I did wrong 

 
public class OppHelloWorld
 {
 public void addHelloWorld(List<opportunity> opps)
 {
 for (Opportunity o:opps)
 {
 if (o.Hello__c != 'World')
 {
 o.Hello__c = 'World';
 }
 }
 }
 }
Below is the Trigger Code:
 
trigger HelloWorld on Opportunity (Before Insert, Before update) {

List <Opportunity> Opps = new List<Opportunity>();
OppHelloWorld OHW = New OppHelloWorld();
OHW.addHelloWorld(Opps);
}


 
I am getting this message "This page isn't available in Salesforce Lightning Experience or Salesforce1." when trying to finish this "https://trailhead.salesforce.com/projects/trailhead_on_mars/steps/trailhead_on_mars_step_4" challenge. Can someone tell me why am i getting this error message. thanks!