• Alex Li 26
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
<apex:actionFunction name="saveJS" action="{!save}">
  <apex:param value="test" name="test"/>
</apex:actionFunction>

<apex:dataTable value="{!list}" var="value">
  <apex:column>
    <apex:inputfile value="{!body}" fileName="{!name}" onchange="saveJS()"/>
  </apex:column>
</apex:dataTable>
In my controller, I have a save() method that is debugging the param "test" that I'm getting with ApexPages.currentPage().getParameters().get('test') but I'm getting null.

I not sure if that the right approach, but what I trying to do is to pass an identifier along with the body of the file that the user can upload so that I can get it back later (since I have several rows and one file can be uploaded for each row).
I'm guessing that apex:param does not work in this case because inputFile is refreshing the whole page

Any idea on what's happening exactly or how I can approach this task differently ?

PS : That's not the finish code since I'm not changing the param value yet (to have a unique identifier for each file)
I'm trying to update a input field when the value of an another field changes using javascript.
I need to hold the id of the field to update in a variable because the input to update changes depending on the id passed as parameter but I try to read or write the new value (not in sample code) with the variable I get an error. 
Whereas, when I write fully the id (like "toUpdate1") I have no issue. 
(The code might have a typo but basically when I try to read an input value selected with a variable, it's not working but when the id is fully written, no problemo as expected)
<apex:page id="page">
  <apex:form id="form">
    <apex:inputField id="aField" value="Changing value" onchange="updateInputValue(toUpdate1)"/>
    <apex:inputField id="toUpdate1" value="Initial value"/>

    <apex:inputField id="aField" value="Changing value" onchange="updateInputValue(toUpdate2)"/>
    <apex:inputField id="toUpdate2" value="Initial value"/>

    <apex:inputField id="aField" value="Changing value" onchange="updateInputValue(toUpdate3)"/>
    <apex:inputField id="toUpdate3" value="Initial value"/>
  </apex:form>

  <script>
    function updateInputValue(fieldToUpdate) {
      // Separate { from ! to avoid apex error
      var idFieldToUpdate = "{" + "!$Component.page.form." + fieldToUpdate + "}";

      console.log(document.getElementById(fieldToUpdate).value); // Error cannot read value from "null"

      console.log(document.getElementById("{!$Component.page.form.toUpdate1}").value); // OK
    }
  </script>
</apex:page>

 
sObject customObj = [SELECT field1, field2, (SELECT field3, field4 FROM customDetailsObject__r) FROM customObj WHERE Id = :currentCustomObj t.Id]; 

// Referencing field3 => error : A non foreign key field cannot be referenced in a path expression
System.debug(customObj .customDetailsObject__r.field3);

// Get customDetailsObject.Id and parent Id (customObj.Id)
System.debug(customObj .customDetailsObject__r);
I'm trying to get field of child custom object from custom parent object but I'm sure what I'm doing wrong when trying accessing it. I have used the "Child Relationship Name".

The singular and plural name are the same (no 's' added or whatsoever) so I don't know if that's the issue.