• Tyler Morgan 9
  • NEWBIE
  • 20 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

I am trying to build a basic component which displays the unique values of a field from all opportunities under an open account.

I'm getting the following error: Illegal conversion from List to List

Any help is greatly appreciated. Here's the code:

Class:

public class testclass {
    @AuraEnabled
    public static List<Opportunity> fetchOpp(String key) {
        List<AggregateResult> listOfOpps = [SELECT Consulting_Engineer__c, COUNT(ID) FROM Opportunity WHERE AccountId =:key GROUP BY Consulting_Engineer__c];
        
        return listOfOpps;
    }
}
 



Component:

<aura:component controller= "testclass" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="Opportunities" type="Opportunity[]"/>
    <ul>
        <aura:iteration items="{!v.Opportunities}" var="opportunity">
            <li>{!opportunity.Consulting_Engineer__c}</li>

        </aura:iteration>
    </ul>
</aura:component>

Controller:

({
    doInit: function(component, event, helper) {
        var action = component.get('c.fetchOpp');
        var rid = component.get("v.recordId");
        action.setParams({key : rid});
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set('v.Opportunities', response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    }
})

On our Opportunity page users have a field to choose an Engineer. These engineers are stored on a custom object.

I would like to display a VF component on the sidebar of the Opp page showing the past Engineer records used on Opps across the parent Account. There typically wouldn't be more than 2-4 over the history of the account. It would also be acceptable for this to display on the Account page.

I have some experience with VF, but don't know where to start with this project going across objects.

I'm trying to build two separate components for a home page. The first one will be a Rich Text input for a few assigned users to be able to enter a message on. The second component will be the output. I've built code to do this but I'm getting an error on function post:
Uncaught Action failed: c:parenttest$controller$post [Cannot read property 'setParams' of undefined]

I'm new to coding so I'm probably missing something simple.

Parent component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:registerEvent name="loadMyEvent" type="c:resultTest"/>
    <aura:attribute name="myVal" type="String" />
    <lightning:inputRichText value="{!v.myVal}" placeholder="Type message."/>
    <lightning:button label="Save" onclick="{!c.post}"/>
</aura:component>

Parent JS:
({
    post : function(component, event, helper) {
        var evt = $A.get("e.c:restultTest");
        evt.setParams({ "Pass_Result": component.get("v.myVal")});
        evt.fire();
    }
})

Child component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="Get_Result" type="String" />
    <aura:handler event="c:resultTest" action="{!c.getValueFromApplicationEvent}"/>
    The result is {!v.Get_Result}
</aura:component>

Child JS:
({
    getValueFromApplicationEvent : function(cmp, event) {
        var ShowResultValue = event.getParam("Show_Result");
        // set the handler attributes based on event data
        cmp.set("v.Get_Result", ShowResultValue);
    }
})

Event:
<aura:event type="APPLICATION">
    <aura:attribute name="Pass_Result" type="String"/>
</aura:event>
 

I am trying to build a basic component which displays the unique values of a field from all opportunities under an open account.

I'm getting the following error: Illegal conversion from List to List

Any help is greatly appreciated. Here's the code:

Class:

public class testclass {
    @AuraEnabled
    public static List<Opportunity> fetchOpp(String key) {
        List<AggregateResult> listOfOpps = [SELECT Consulting_Engineer__c, COUNT(ID) FROM Opportunity WHERE AccountId =:key GROUP BY Consulting_Engineer__c];
        
        return listOfOpps;
    }
}
 



Component:

<aura:component controller= "testclass" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="Opportunities" type="Opportunity[]"/>
    <ul>
        <aura:iteration items="{!v.Opportunities}" var="opportunity">
            <li>{!opportunity.Consulting_Engineer__c}</li>

        </aura:iteration>
    </ul>
</aura:component>

Controller:

({
    doInit: function(component, event, helper) {
        var action = component.get('c.fetchOpp');
        var rid = component.get("v.recordId");
        action.setParams({key : rid});
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set('v.Opportunities', response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    }
})

On our Opportunity page users have a field to choose an Engineer. These engineers are stored on a custom object.

I would like to display a VF component on the sidebar of the Opp page showing the past Engineer records used on Opps across the parent Account. There typically wouldn't be more than 2-4 over the history of the account. It would also be acceptable for this to display on the Account page.

I have some experience with VF, but don't know where to start with this project going across objects.

I'm trying to build two separate components for a home page. The first one will be a Rich Text input for a few assigned users to be able to enter a message on. The second component will be the output. I've built code to do this but I'm getting an error on function post:
Uncaught Action failed: c:parenttest$controller$post [Cannot read property 'setParams' of undefined]

I'm new to coding so I'm probably missing something simple.

Parent component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:registerEvent name="loadMyEvent" type="c:resultTest"/>
    <aura:attribute name="myVal" type="String" />
    <lightning:inputRichText value="{!v.myVal}" placeholder="Type message."/>
    <lightning:button label="Save" onclick="{!c.post}"/>
</aura:component>

Parent JS:
({
    post : function(component, event, helper) {
        var evt = $A.get("e.c:restultTest");
        evt.setParams({ "Pass_Result": component.get("v.myVal")});
        evt.fire();
    }
})

Child component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="Get_Result" type="String" />
    <aura:handler event="c:resultTest" action="{!c.getValueFromApplicationEvent}"/>
    The result is {!v.Get_Result}
</aura:component>

Child JS:
({
    getValueFromApplicationEvent : function(cmp, event) {
        var ShowResultValue = event.getParam("Show_Result");
        // set the handler attributes based on event data
        cmp.set("v.Get_Result", ShowResultValue);
    }
})

Event:
<aura:event type="APPLICATION">
    <aura:attribute name="Pass_Result" type="String"/>
</aura:event>