0

I want to pass my lightning:outputField value to aura controller on hover the field. I'm not able to find a way to do it. Below is the code.

<aura:iteration items="{!v.completeList}" var="field">
<lightning:outputField fieldName="{!field.fieldAPIName}" aura:id = "{!field.fieldAPIName}" variant = 'label-hidden' onmouseover="{!c.handleHover}" onmouseout="{!c.handleHoverOut}"/>
</aura:iteration>

Please let me know how to get the value from html to js in aura component.

1 Answer 1

0

I would say refer to this post:

How to pass Button Value on mouseover to controller Aura Component

While it does not exactly answer your question, it should lead you on the right path.

in your handleHover controller handler, usually the element / value that is passed to the event handler contains the 'value' attribute you are looking for.

I am more familiar with LWC vs Aura, but you can try the following:

Try to access the value using the event parameter that is passed to your handler.

handleHover: function(component, event, helper){
  var eventTarget = event.target;
  console.log(eventTarget);
  //I am not sure the exact attribute you need to reference, but you can try something like this: 
  var fieldValue = eventTarget.getAttribute('value');

  console.log(fieldValue); //is this your value?
}

due to locker service, you may not be able to access the value directly so you may need to do something like the following:

var fieldValue = event.getSource().get("v.value");

Apologies for not giving you the entire solution, but I am positive, with a bit of research, if you use the above you should be able to access the value in your handler.

When you find out the correct solution, please post it here so others can use this as reference.

2
  • Z33dawg, I checked the aura documentation for outputfield and there is no attribute as "value". so when I tried event.getSource().get("v.value"), it comes undefined.
    – sfdcOwl
    Commented May 12, 2022 at 6:35
  • I've done the above scenario using a workaround. As I'm able to get the field api name in my aura controller, I'm sending it and also the case record id(as this is a custom field used inside the lightning record view form of case object). In my apex controller, I'm able to get the sobject type and its corresponding value and sending it back to aura.
    – sfdcOwl
    Commented May 12, 2022 at 10:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .