• Akanksha Gupta 58
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
Hi,

I have a URL "https://gidev-groupinsurance.cs61.force.com/MemberPortal/s/caseclaimstatus?id=5004C0000033pqlQAA" . I want to use the "id" parameter in my lightning JS controller. How to do that?
I have two record types available in Case object - New and Review. Now, I need a button in the lightning detail page of the "New" record type which redirects to a detail page where the record type is "Review" and rest of the field values are same. How to achieve this?
Hi, 
I have a requirement where I need to query all the fields of Case object along with all the fields of the Child objects of Case. How do I built a query for the same. Right now I am able to query only the fields of Case object. I am not sure how to design an inner query using dynamic apex.
This is my code snippet
public class TEL_CaseController
{
    public List<Case> caseList{get;set;}
    public List<SObjectType> childList{get;set;}	
    public String query{get;set;}
    public List<String> listFields{get;set;}
    String allFields = '';
    public TEL_CaseController ()
    {
        String SobjectApiName = 'Case';
        
        /*********************************************/
        childList = new List<SObjectType>();
        Schema.SObjectType convertType = Schema.getGlobalDescribe().get(SobjectApiName);
        Schema.DescribeSObjectResult obj = convertType.getDescribe();
        for (Schema.ChildRelationship cr: obj.getChildRelationships()) 
        {
            system.debug('Child Object Name:'+cr.getChildSObject());
            childList.add(cr.getChildSObject());
        }
        
        /*********************************************/
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
        Set<string> mapset = fieldMap.keyset();
        caseList = new List<Case>();
        listFields = new List<String>();
        FOR ( String str:mapset )
        {
            
            allFields += str +', '; 
            listFields.add(str);
        }
        allFields = allFields.removeEnd(', ');
        
        query = 'SELECT ' + allFields + ' FROM ' + SobjectApiName + ' where id = \''+apexPages.currentPage().getParameters().get('id')+'\' ';
        caseList = Database.query(query);
    }
}

 
I have 2 lightning components:
The first one is a table which has 4 columns and we can add or delete rows. 
The second one is a report which displays data from one of the coloumns.
How do I achieve this? Do I need to fire an event on the save method?

Here's my first component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="LC57_AiPotenitalRevenueClass">
    
    <aura:attribute name="showHidePlayer" type="boolean" default="false" description="To Toggle the table" /> 
    <aura:attribute name="qualificationList" type="APR_AccountPotentialRevenue__c[]" description="To hold the data list" />
    <aura:attribute name="editMode" type="Boolean"  description="To enable Edit Mode"/>
    <aura:attribute name="lockQualificationItem" type="Boolean" description="To toggle the delete and edit Button" default="false"/>
    <aura:attribute name="recordId" type="String" description="Fetch the Current page Id" />
    <aura:attribute name="scope" type="String" description="Selected scope value"/>
    <aura:attribute name="fieldLabelsMap" type="Object" description="Keeps labels of column headers"/>
    <aura:attribute name="service" type="APR_AccountPotentialRevenue__c" default="{'sobjectType': 'APR_AccountPotentialRevenue__c',
                                                                                  'Service__c': '',                                                                  
                                                                                  }"/>
    <aura:attribute name="Brandlist" type="String[]" description="Display User Brand value"/>
    <aura:attribute name="newCriterion" type="APR_AccountPotentialRevenue__c" description="New criterion definition attribute"/>
    <!--<aura:registerEvent name="navigate" type="c:loadChart"/>-->
    <!-- HELPER ATTRIBUTES -->
    <aura:attribute name="reInitialize" type="Boolean" description="Helper to reinitialize lookup component" default="false"/>
    
    <!-- HANDLERS -->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>  
    
    <div class="slds-page-header">
        <div onclick="{!c.toggle}">         
            <aura:if isTrue="{!v.showHidePlayer == False}">
                <lightning:icon iconName="utility:right" size="small" />
            </aura:if>
            <aura:if isTrue="{!v.showHidePlayer}">
                <lightning:icon iconName="utility:down" size="small" />  
            </aura:if>            
        </div> 
        <div  class="slds-text-heading--label align">
            Dépense client
        </div> 
        
    </div>
    
    
    
    
    <div aura:id="text">
        
        <div class="slds-scrollable">
            <table class="slds-table slds-table_bordered table-condensed slds-table_cell-buffer"> 
                <thead >
                    <tr class="slds-text-title_caps">
                        <th class="thead"  scope="col">
                            <div class="slds-truncate">{!v.fieldLabelsMap.Brand__c}</div>
                        </th>
                        <th class="thead"  scope="col">
                            <div class="slds-truncate" title="Competitor Name">{!v.fieldLabelsMap.Service__c}</div>
                        </th>
                        <th class="thead"  scope="col">
                            <div class="slds-truncate" title="Competitor Name">{!v.fieldLabelsMap.Turnover__c}</div>
                        </th>
                        <th class="thead" scope="col">
                            <div class="slds-truncate" title="Action">{!v.fieldLabelsMap.Comments__c}</div>
                        </th>
                        <th class="thead" scope="col">
                            <div class="slds-truncate" title="Action">{!$Label.c.PIS_Modified_by_Date}</div>
                        </th>
                    </tr>
                </thead> 
                <tbody>
                    <tr> 
                        <td>
                            <ui:inputSelect disabled="true" class="slds-select" aura:id="brand" >
                                <aura:iteration items="{!v.Brandlist}" var="brand">
                                    <ui:inputSelectOption value="{!v.newCriterion.Chosen_Brand__c}" text="{!brand}" label="{!brand}"/>
                                </aura:iteration>
                            </ui:inputSelect>
                        </td>
                        <td>
                            <ui:inputselect class="slds-input" aura:id="ChooseBrand"  value="{!v.newCriterion.Service__c}"  required="true"/> 
                        </td>
                        <td>
                            <ui:inputText class="slds-input" value="{!v.newCriterion.Turnover__c}"  />
                        </td>
                        <td>
                            <ui:inputText class="slds-input slds-cell-wrap" value="{!v.newCriterion.Comments__c}"/>
                        </td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>
                            
                            <button type="button" class="slds-button slds-button--icon-border-filled"
                                    onclick="{!c.save}" >
                                <lightning:icon iconName="utility:check" size="small" class="fillGreenIcon"/>
                            </button>
                            <button type="button" class="slds-button slds-button--icon-border-filled"
                                    onclick="{!c.cancel}">
                                <lightning:icon iconName="utility:undo" size="small" class="fillGreenIcon"/>
                            </button>
                            
                        </td>
                    </tr>
                    
                    <aura:if isTrue="{!v.qualificationList.length > 0}">
                        <aura:iteration aura:id="trial" items="{!v.qualificationList}" var="item" indexVar="i">
                            <tr id="{!i}" data-index="{!i}">
                                
                                <td class="slds-cell-wrap">
                                    <div>
                                        <ui:outputRichText class="slds-input"  value="{!item.profileofInterestRecord.Brand_Logo__c}"/>  
                                    </div>    
                                </td>     
                                <td class="slds-cell-wrap">
                                    <ui:OutputText class="slds-input"  value="{!item.profileofInterestRecord.Service__c}"/>  
                                </td> 
                                <td class="slds-cell-wrap">
                                    <ui:outputText class="slds-input" aura:id="levels" value="{!item.profileofInterestRecord.Turnover__c  }" />
                                </td>
                                <td class="slds-cell-wrap">
                                    <ui:outputText class="slds-input" aura:id="levels" value="{!item.profileofInterestRecord.Comments__c  }" />
                                </td>
                                <td  colspan="2">
                                    <div>
                                        <lightning:icon iconName="action:add_contact" size="xx-small" alternativeText="Indicates approval"/>                                           
                                        <ui:outputText aura:id="levels" value="{!item.profileofInterestRecord.LastModifiedBy.Name}"/>
                                        <ui:OutputDate aura:id="levels" value="{!item.profileofInterestRecord.LastModifiedDate }"/>                                           
                                    </div>
                                    
                                </td>   
                                <td>
                                </td>
                                <td>
                                    <button aura:id="editButton" type="button"
                                            class="slds-button slds-button--icon-border-filled"
                                            onclick="{!c.editCriterion}"
                                            >
                                        <lightning:icon iconName="utility:edit" size="small" class="fillGreenIcon"/>
                                    </button>
                                    <button aura:id="deleteButton" type="button"
                                            class="slds-button slds-button--icon-border-filled" 
                                            onclick="{!c.deleteCriterion}" >
                                        <lightning:icon iconName="utility:delete" size="small" class="fillRedIcon"/>
                                    </button>
                                </td> 
                                
                            </tr>
                       </aura:iteration>    
                    </aura:if> 
                </tbody>
            </table>   
        </div>      
        
    </div>       
    
</aura:component>

And the second component is:
<aura:component controller="LC58_AiIndicatorsClass" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <ltng:require scripts="{!$Resource.ChartJS}" afterScriptsLoaded="{!c.scriptsLoaded}"/>
    <aura:attribute name="revenue" type="double"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="clist" type="List" access="GLOBAL"/> 
    <div class="icon-style slds-align--absolute-center">
        <lightning:formattedNumber value="{!v.revenue}" style="currency" currencyCode="USD"/>    
    </div>
    <div class="icon-style1">
        <canvas id="myChart" height="200"></canvas>
    </div>   
</aura:component>

 
Hi, 
I have a requirement where I need to query all the fields of Case object along with all the fields of the Child objects of Case. How do I built a query for the same. Right now I am able to query only the fields of Case object. I am not sure how to design an inner query using dynamic apex.
This is my code snippet
public class TEL_CaseController
{
    public List<Case> caseList{get;set;}
    public List<SObjectType> childList{get;set;}	
    public String query{get;set;}
    public List<String> listFields{get;set;}
    String allFields = '';
    public TEL_CaseController ()
    {
        String SobjectApiName = 'Case';
        
        /*********************************************/
        childList = new List<SObjectType>();
        Schema.SObjectType convertType = Schema.getGlobalDescribe().get(SobjectApiName);
        Schema.DescribeSObjectResult obj = convertType.getDescribe();
        for (Schema.ChildRelationship cr: obj.getChildRelationships()) 
        {
            system.debug('Child Object Name:'+cr.getChildSObject());
            childList.add(cr.getChildSObject());
        }
        
        /*********************************************/
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
        Set<string> mapset = fieldMap.keyset();
        caseList = new List<Case>();
        listFields = new List<String>();
        FOR ( String str:mapset )
        {
            
            allFields += str +', '; 
            listFields.add(str);
        }
        allFields = allFields.removeEnd(', ');
        
        query = 'SELECT ' + allFields + ' FROM ' + SobjectApiName + ' where id = \''+apexPages.currentPage().getParameters().get('id')+'\' ';
        caseList = Database.query(query);
    }
}