• Jeff Fontas
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
I am experiencing some really strange behavior that I can't seem to figure out.  I have created a listener javascript function to capture enter key presses, it looks like this:
<script type="text/javascript">
    function submitListener(e){
        var keynum = 0;
        if (window.event){
            keynum = window.event.keyCode;
        }
        else if (e.which){
            keynum = e.which;
        }
        // Here we check whether the Enter button was pressed
        if (keynum == 13){
            apexDoQuery();
        }
    }
</script>

I have designated the function to target this actionFunction:
<apex:actionFunction action="{!saveAndRunQuery}" name="apexDoQuery" reRender="myData"/>

I call the function in this apex:inputText tag:

<label style="margin-right: 50px">Filter by Code Number or Code Title:&nbsp;<apex:inputText value="{!searchString}" onKeyup="submitListener(event)"/></label>

For some reason, whenever I hit enter in the textbox, the popup window I am in simply closes.  I was messing around in Chrome developer tools and set an event breakpoint on window.close(), but all it gave me was this line, which is not really descript:

(function() {with (this[2]) {with (this[1]) {with (this[0]) {return function(event) {window.close()})

Any help would be greatly appreciated.
I am trying to have a JavaScript function executed after the completion of a save method in my Apex controller using an apex:actionStatus tag, but I can't seem to be able to get it to work.  Here is the portion of the code I am working with that isn't working properly:

<apex:page showHeader="false" controller="AddCodesController">
    <script>

    function CloseWindow() {
        console.log('hey');
        window.opener.refreshParent();
        window.close()
    }
    </script>
    <apex:form id="addCodesForm">
        <apex:pageBlock title="Add Related Codes" id="myData">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save & Close" status="closer"/>
                <apex:commandButton value="Cancel" onclick="window.close()"/>   
                <apex:actionStatus startText="(Saving...)" stopText="" onStop="CloseWindow();" id="closer"/>
            </apex:pageBlockButtons>  
       </apex:pageBlock>
    </apex:form>
</apex:page


I put the console.log() in there just to see if it was firing, and I can't get it to show up.  I have searched and looked at probably 5 or 6 different examples and it seems like I have written this properly, but I can't for the life of me figure out what is going wrong.  Any help would be greatly appreciated it.
I have been trying to figure out how best to accomplish a certain functionality I want on a custom object page layout, and I have yet to find the answer.  Basically, I have created a standard object called "Seminar", which has a lookup field for Opportunity.  I also want to display the Account and Opportunity Owner on the Opportunity object on the page layout of the Seminar object.  

So far, I have tried to accomplish this two ways.  First, I tried creating a button on the Opportunity page layout for creating new seminars.  This button prepopulates data from the Opportunity into the fields in the Seminar.  Clicking it would could copy the data as follows:

Opportunity Field            Seminar Field
Opportunity                ->    Opportunity lookup
Opportunity.Account     ->    Account lookup
Opportunity.Owner         ->    User lookup        

After doing this, I discovered I was not happy with the results.  Yes, I minimized data entry (one of my goals) but the fields would not update if the parent fields on the opportunity changed.

Looking around, I discovered that a formula might be the best way to accomplish displaying the fields from Opportunity object on the page layout of the Seminar object:

Opportunity Field            Seminar Field
Opportunity                ->    Opportunity lookup
Opportunity.Account     ->    Formula: HYPERLINK("/" & Opportunity__r.Account.Id, Opportunity__r.Account.Name)
Opportunity.Owner        ->    HYPERLINK("/" & Opportunity__r.OwnerId, Opportunity__r.Owner.FirstName & " " & Opportunity__r.Owner.LastName)

After setting this up, I was still unhappy.  I had three issues with the formula approach:

1. I have to create a hyperlink for the formula fields to link back to the objects for those fields. Not a huge deal but kind of a pain.
2. I can no longer use related list functionality on the account page because it is a formula field and not a lookup.
3. I no longer get the hover tooltip that displays additional information about the related object that I would get from a lookup field when users hover over the link.

Anyway, for a tl;dr, my question is:

Is there any way to display fields that are on a parent/related object in the child page layout such that the child fields automatically populate/update when there are changes to the parent object, while also being able to utilize related lists and the hover tooltip?
I am experiencing some really strange behavior that I can't seem to figure out.  I have created a listener javascript function to capture enter key presses, it looks like this:
<script type="text/javascript">
    function submitListener(e){
        var keynum = 0;
        if (window.event){
            keynum = window.event.keyCode;
        }
        else if (e.which){
            keynum = e.which;
        }
        // Here we check whether the Enter button was pressed
        if (keynum == 13){
            apexDoQuery();
        }
    }
</script>

I have designated the function to target this actionFunction:
<apex:actionFunction action="{!saveAndRunQuery}" name="apexDoQuery" reRender="myData"/>

I call the function in this apex:inputText tag:

<label style="margin-right: 50px">Filter by Code Number or Code Title:&nbsp;<apex:inputText value="{!searchString}" onKeyup="submitListener(event)"/></label>

For some reason, whenever I hit enter in the textbox, the popup window I am in simply closes.  I was messing around in Chrome developer tools and set an event breakpoint on window.close(), but all it gave me was this line, which is not really descript:

(function() {with (this[2]) {with (this[1]) {with (this[0]) {return function(event) {window.close()})

Any help would be greatly appreciated.
I am trying to have a JavaScript function executed after the completion of a save method in my Apex controller using an apex:actionStatus tag, but I can't seem to be able to get it to work.  Here is the portion of the code I am working with that isn't working properly:

<apex:page showHeader="false" controller="AddCodesController">
    <script>

    function CloseWindow() {
        console.log('hey');
        window.opener.refreshParent();
        window.close()
    }
    </script>
    <apex:form id="addCodesForm">
        <apex:pageBlock title="Add Related Codes" id="myData">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save & Close" status="closer"/>
                <apex:commandButton value="Cancel" onclick="window.close()"/>   
                <apex:actionStatus startText="(Saving...)" stopText="" onStop="CloseWindow();" id="closer"/>
            </apex:pageBlockButtons>  
       </apex:pageBlock>
    </apex:form>
</apex:page


I put the console.log() in there just to see if it was firing, and I can't get it to show up.  I have searched and looked at probably 5 or 6 different examples and it seems like I have written this properly, but I can't for the life of me figure out what is going wrong.  Any help would be greatly appreciated it.
I have been trying to figure out how best to accomplish a certain functionality I want on a custom object page layout, and I have yet to find the answer.  Basically, I have created a standard object called "Seminar", which has a lookup field for Opportunity.  I also want to display the Account and Opportunity Owner on the Opportunity object on the page layout of the Seminar object.  

So far, I have tried to accomplish this two ways.  First, I tried creating a button on the Opportunity page layout for creating new seminars.  This button prepopulates data from the Opportunity into the fields in the Seminar.  Clicking it would could copy the data as follows:

Opportunity Field            Seminar Field
Opportunity                ->    Opportunity lookup
Opportunity.Account     ->    Account lookup
Opportunity.Owner         ->    User lookup        

After doing this, I discovered I was not happy with the results.  Yes, I minimized data entry (one of my goals) but the fields would not update if the parent fields on the opportunity changed.

Looking around, I discovered that a formula might be the best way to accomplish displaying the fields from Opportunity object on the page layout of the Seminar object:

Opportunity Field            Seminar Field
Opportunity                ->    Opportunity lookup
Opportunity.Account     ->    Formula: HYPERLINK("/" & Opportunity__r.Account.Id, Opportunity__r.Account.Name)
Opportunity.Owner        ->    HYPERLINK("/" & Opportunity__r.OwnerId, Opportunity__r.Owner.FirstName & " " & Opportunity__r.Owner.LastName)

After setting this up, I was still unhappy.  I had three issues with the formula approach:

1. I have to create a hyperlink for the formula fields to link back to the objects for those fields. Not a huge deal but kind of a pain.
2. I can no longer use related list functionality on the account page because it is a formula field and not a lookup.
3. I no longer get the hover tooltip that displays additional information about the related object that I would get from a lookup field when users hover over the link.

Anyway, for a tl;dr, my question is:

Is there any way to display fields that are on a parent/related object in the child page layout such that the child fields automatically populate/update when there are changes to the parent object, while also being able to utilize related lists and the hover tooltip?