0

I am attempting to extend the functions of our products and show a list on the account page where we can denote what products, services, or reccomendations we've given our clients.

To do this I was creating a visualforce page that would appear to be a related list to our employees with some extended functionality.

The issue is with one of these pieces of extended functionality.

When the employee changes the "Check Back on Date" a pop-up will open asking if they would like to set up a reminder task for the product.

The issue right now is that it's not passing the name of the product.

Visualforce:

<apex:page showHeader="false" sidebar="false" standardController="Account" extensions="AccountProductExtension" action="{!ActionAccountProductRun}">

    <apex:form >
    <apex:pageBlock title="Associated Products and Services">
        <apex:pageBlockButtons location="Top">

        </apex:pageBlockButtons>

        <apex:pageBlockTable value="{!accountProducts}" var="p">
            <apex:column headerValue="Product or Service" value="{!p.name}"/>
            <apex:column title="Type" value="{!p.Type__c}"/>

            <apex:column headerValue="Status">
                <apex:inputField value="{!p.Status__c}"/>
            </apex:column>

            <apex:column headerValue="Date Offered">
                <apex:inputField value="{!p.DateOffered__c}"/>
            </apex:column>

            <apex:column headerValue="Check Back On">
                <apex:inputField value="{!p.CheckBackDate__c}">
                    <apex:actionSupport event="onchange" onsubmit="Confirm();" reRender="out">
                        <apex:param name="cDate" value="{!p.CheckBackDate__c}" assignTo="{!checkBackDate}"/>
                        <apex:param name="cName" value="{!p.Name}" assignTo="{!productName}"/>
                    </apex:actionSupport>
                </apex:inputField>
            </apex:column>

            <apex:column headerValue="Notes">
                <apex:inputField value="{!p.Notes__c}"/>
            </apex:column>
        </apex:pageBlockTable>

    </apex:pageBlock>
        <script>
        window.setTimeout(recursivecall,500);

        function recursivecall()
        {
          window.setTimeout(recursivecall,500);
          autosave();
        }

        function Confirm() {

            if ( confirm("Would you like to set a reminder to check back with the TA of {!Account.Name}?")){
                sendTask();
            }

        }    
        </script>

    <apex:actionFunction name="sendTask" action="{!sendTask}" reRender="out"/>
    <apex:actionFunction name="autosave" action="{!autosave}" reRender="out"/>
    </apex:form>

    <script>
        setFocus = function() { return; }
    </script>
</apex:page>

I couldn't find anything that said setting two param's shouldn't work.

Why will the "p.Name" field not pass into the code?

  • try Remove the action function for confirm, put them under the action function for sendTask. Use the confirm to send the values to the sendTask actionFunction. – Eric Dec 3 '15 at 15:27
  • @Eric there's no actionFunction for confirm, there's actionSupport which needs to trigger the confirmation dialogue when the date is changed. – Cody Beaner Dec 3 '15 at 15:40
  • Actually I do not think you need to params at all. Try removing the params and see if that resolves it. When your action function is called it should send the form data to the controller. Your params are overwriting the values to null as the merge fields are null when the params component is rendered and you are not passing anything to them – Eric Dec 3 '15 at 15:51
  • It's calling Confirm(); which is using the boolean javascript function confirm("String text to display in popup"); And then calling the actionFunction sendTask if it returns true (meaning they clicked okay and not cancel). – Cody Beaner Dec 3 '15 at 15:52
  • Read my last comment...I was not thinking it through. – Eric Dec 3 '15 at 15:52
1

params are use to assign values to controller variables in a javascript like fashion.

i.e.

<actionFunction name="myfunc" action="{!do something}" rerender="msgs">
   <apex:param value="" name="param1" assignTo="{!myVar}"/>
</apex:actionFunction>

<script>
    myFunc('1234');
</script>

This will assign '1234' to the controller property myVar

Remove the params and it should work as you expect

Update

I made a minimalist copy of what you are doing and it worked fine (with the params) so maybe something else is happening.

BUT - You do not need the params at all so remove them. Here is an example that actually works as expected as well:

Class

public class myTestController{

    public Account a {get;set;}

    public myTestController(){
       a = New Account();
    }

    public void debugValues(){

         system.debug(logginglevel.error,a.Name);

    }



}

VF Page

<apex:page controller="myTestController">


<apex:form >

    <apex:inPutField value="{!a.name}">
        <apex:actionSupport event="onchange" onsubmit="Confirm();" rerender="msgs"/>
    </apex:inputField>


<apex:actionFunction name="sendTask" action="{!debugValues}" reRender="out"/>
</apex:form>

<script>

        function Confirm() {

            if ( confirm("Would you like to set a reminder to check back with the TA of {!a.Name}?")){
                sendTask();
            }

        }    
        </script>
</apex:page>

Since p.name is already set in the controller there is no need to pass it or set it, just grab it in the controller

| improve this answer | |
  • The issue is that I need the name value for the product in that row, specifically the one where the date field is being changed. I need that name to passed to the task constructor. So without passing the value of the name in that row, I cannot get that specific name from the list of names. – Cody Beaner Dec 4 '15 at 14:54
0

So I've discovered that even though Name is a text field, it was not passing a text based value with the param.

By using the function {!JSENCODE(p.Name)} I was able to send the proper String value.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.