• Joshua Danis 7
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 3
    Replies
I have created two custom objects we'll call the analysis and component. Components are always children to an analysis; they do not exist alone. Both analyses and components have two record types, we'll call them A and B. An A type analysis cannont have B type components and vice versa. Type A and Type B components are considerably different and as such I've created two different Visualforce pages to create components skipping the need for record type selection and streamlining things etc. I've created a third Visualforce page which is essentially a dummy page that calls an action from its extension. This action redirects to one of the two former pages depending on the parent analysis's record type. This third page I've name 'WizardRedirector' is used to override the standard 'New' button of the components. It should only be accessed from the related list on a preexisting parent analysis. Everything works fine when accessed from there, however I've discovered when I go to the standard edit page of a component and click the 'Save & New' button from the edit page it fails to redirect. 

I understand the immediate reason for failure is a null reference error in the redirect() method, where the variable 'parent' is null. The ultimate reason this is null is because the when I call StandardController.getRecord() it is returning a blank record. When accessed from the parent's related list the record at least has the parent record's ID, but when accessed from the edit page of a component it does not have this. I'm trying understand why this is in particular.

Here is the extensions code: 
Consumable_Analysis_Component__c component;
  Consumable_Analysis__c parent;
  Id parentId;
  Map<Id, RecordTypeInfo> myMap = Schema.SObjectType.Consumable_Analysis__c.getRecordTypeInfosById();

  public RedirectorController(ApexPages.StandardController controller){
     try{
       this.component = (Consumable_Analysis_Component__c)controller.getRecord();
       this.parentId = this.component.Solution_Analysis__c;
       this.parent = [SELECT Id, RecordTypeId FROM Consumable_Analysis__c WHERE Id=:parentId limit 1];
    } catch(System.Exception e){
       ApexPages.addMessages(e);
    } 
  } 
  
  public PageReference redirect(){
   try{
    if(myMap.get(parent.RecordTypeId).getName()=='A'){
       PageReference pref = new PageReference('/apex/AConsumableAnalysisWizard');
       pref.getParameters().putAll(ApexPages.currentPage().getParameters());
       pref.setRedirect(true);
       return pref;
    } else{ 
       PageReference pref = new PageReference('/apex/BConsumableAnalysisWizard');
       pref.getParameters().putAll(ApexPages.currentPage().getParameters());
       pref.setRedirect(true);
       return pref;
    }}catch(System.Exception e){ApexPages.addMessages(e); return null;}
  
  }

 
Hello there,

I'm currently having a styling issue at the the step 3 of the Trailhead Lightning Component Framework Specialist,

here is what it's currently looks like :

User-added image

and what it is supposed to look :

User-added image

This is the BoatTile component code :
 
<aura:component >

    <aura:attribute name="boat" type="Boat__c" />
    <aura:attribute name="selected" type="Boolean" default="false" />
    
    <aura:registerEvent name="BoatSelect" type="c:BoatSelect"/>
    <aura:registerEvent name="BoatSelected" type="c:BoatSelected"/>

        <lightning:button class="{! v.selected == true ? 'tile selected' : 'tile' }" onclick="{!c.onBoatClick}">
            <div style="{!'background-image:url(\'' + v.boat.Picture__c + '\')'}" class="innertile">
                <div class="lower-third">
                    <h1 class="slds-truncate">{!v.boat.Contact__r.Name}</h1>
                </div>
            </div>
        </lightning:button>

</aura:component>

and the associated style :
 
.THIS.tile {
    position:relative;
    display: inline-block;
    width: 100%;
    height: 220px;
    padding: 1px !important;
}

.THIS.innertile {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
}

.THIS.lower-third {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    color: #FFFFFF;
    background-color: rgba(0, 0, 0, .4);
    padding: 6px 8px;
}

.THIS.selected {
    border: 3px solid rgb(0, 112, 210);
}

Any help would be great, I am a bit confused not to have this displayed correctly.

Thanks lot ! 
I have created two custom objects we'll call the analysis and component. Components are always children to an analysis; they do not exist alone. Both analyses and components have two record types, we'll call them A and B. An A type analysis cannont have B type components and vice versa. Type A and Type B components are considerably different and as such I've created two different Visualforce pages to create components skipping the need for record type selection and streamlining things etc. I've created a third Visualforce page which is essentially a dummy page that calls an action from its extension. This action redirects to one of the two former pages depending on the parent analysis's record type. This third page I've name 'WizardRedirector' is used to override the standard 'New' button of the components. It should only be accessed from the related list on a preexisting parent analysis. Everything works fine when accessed from there, however I've discovered when I go to the standard edit page of a component and click the 'Save & New' button from the edit page it fails to redirect. 

I understand the immediate reason for failure is a null reference error in the redirect() method, where the variable 'parent' is null. The ultimate reason this is null is because the when I call StandardController.getRecord() it is returning a blank record. When accessed from the parent's related list the record at least has the parent record's ID, but when accessed from the edit page of a component it does not have this. I'm trying understand why this is in particular.

Here is the extensions code: 
Consumable_Analysis_Component__c component;
  Consumable_Analysis__c parent;
  Id parentId;
  Map<Id, RecordTypeInfo> myMap = Schema.SObjectType.Consumable_Analysis__c.getRecordTypeInfosById();

  public RedirectorController(ApexPages.StandardController controller){
     try{
       this.component = (Consumable_Analysis_Component__c)controller.getRecord();
       this.parentId = this.component.Solution_Analysis__c;
       this.parent = [SELECT Id, RecordTypeId FROM Consumable_Analysis__c WHERE Id=:parentId limit 1];
    } catch(System.Exception e){
       ApexPages.addMessages(e);
    } 
  } 
  
  public PageReference redirect(){
   try{
    if(myMap.get(parent.RecordTypeId).getName()=='A'){
       PageReference pref = new PageReference('/apex/AConsumableAnalysisWizard');
       pref.getParameters().putAll(ApexPages.currentPage().getParameters());
       pref.setRedirect(true);
       return pref;
    } else{ 
       PageReference pref = new PageReference('/apex/BConsumableAnalysisWizard');
       pref.getParameters().putAll(ApexPages.currentPage().getParameters());
       pref.setRedirect(true);
       return pref;
    }}catch(System.Exception e){ApexPages.addMessages(e); return null;}
  
  }

 
Hello there,

I'm currently having a styling issue at the the step 3 of the Trailhead Lightning Component Framework Specialist,

here is what it's currently looks like :

User-added image

and what it is supposed to look :

User-added image

This is the BoatTile component code :
 
<aura:component >

    <aura:attribute name="boat" type="Boat__c" />
    <aura:attribute name="selected" type="Boolean" default="false" />
    
    <aura:registerEvent name="BoatSelect" type="c:BoatSelect"/>
    <aura:registerEvent name="BoatSelected" type="c:BoatSelected"/>

        <lightning:button class="{! v.selected == true ? 'tile selected' : 'tile' }" onclick="{!c.onBoatClick}">
            <div style="{!'background-image:url(\'' + v.boat.Picture__c + '\')'}" class="innertile">
                <div class="lower-third">
                    <h1 class="slds-truncate">{!v.boat.Contact__r.Name}</h1>
                </div>
            </div>
        </lightning:button>

</aura:component>

and the associated style :
 
.THIS.tile {
    position:relative;
    display: inline-block;
    width: 100%;
    height: 220px;
    padding: 1px !important;
}

.THIS.innertile {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
}

.THIS.lower-third {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    color: #FFFFFF;
    background-color: rgba(0, 0, 0, .4);
    padding: 6px 8px;
}

.THIS.selected {
    border: 3px solid rgb(0, 112, 210);
}

Any help would be great, I am a bit confused not to have this displayed correctly.

Thanks lot !