0

I am facing this issue where PassValues() function is action function and i am passing some parameters to controller through actionfunction.I dont know whats going wrong the code is not flowing into the method..Even the debug system is not getting printed in logs..

I even saw many similar posts on this forum but didnot find any help..

The controller has many methods but for this vf page pls refer Save method only which is being called through action="{!Save}" ..

    <apex:page sidebar="false" showHeader="false" controller="PolicyHolderDetails">
<script type="text/javascript">
function GetValues(){
var Name=document.getElementById('input-id1').value;
var Phone=document.getElementById('input-id2').value;
var website=document.getElementById('input-id3').value;
var street=document.getElementById('input-id4').value;
var city=document.getElementById('input-id5').value;
var state=document.getElementById('input-id6').value;
var zipcode=document.getElementById('input-id7').value;
var fax=document.getElementById('input-id8').value;
var industry=document.getElementById('input-id9').value;
if(Name=='')
{
//alert('error');
document.getElementById('div1').innerHTML='Please Enter Policy Holder Name';
return false;
}
if(Name!=''){
alert(Name);
 PassValues(Name,Phone,website,street,city,state,zipcode,fax,industry);
alert('Details submitted successfully'); 
}                  
}
</script>
  <apex:slds />
  <apex:form >
 <center> <h1 style="font-size: 20px;">Fill out our form and get benefits..</h1></center>
 <div class="slds-form-element slds-text-title_caps" >
  <label class="slds-form-element__label " for="input-unique-id1">Policy Holder Name</label>
  <div class="slds-form-element__control is-required slds-has-error" id="div1" style="width: 350px;">
    <input type="text" id="input-id1" class="slds-input" required=""/><br/><br/>
  </div>
  <label class="slds-form-element__label" for="input-unique-id2">Phone</label>
  <div class="slds-form-element__control" style="width: 200px;">
    <input type="Number" id="input-id2" class="slds-input" /><br/><br/>
  </div>
  <label class="slds-form-element__label" for="input-unique-id3">Website</label>
  <div class="slds-form-element__control" style="width: 350px;">
    <input type="text" id="input-id3" class="slds-input" /><br/><br/>
  </div>
  <fieldset class="slds-form-element">
      <legend class="slds-form-element__label ">Address</legend>
      <div class="slds-form-element__group">
        <div class="slds-form-element__row">
          <div class="slds-form-element slds-size_1-of-1" style="width: 350px;">
            <label class="slds-form-element__label" for="input-04">Street</label>
            <input type="text" id="input-id4" class="slds-input"/><br/><br/>
          </div>
        </div>
        <div class="slds-form-element__row">
          <div class="slds-form-element slds-size_1-of-2" style="width: 350px;">
            <label class="slds-form-element__label" for="input-05">City</label>
            <input type="text" id="input-id5" class="slds-input"/>
          <!--</div>-->
         <!-- <div class="slds-form-element slds-size_1-of-2" style="width: 350px;">-->
            <label class="slds-form-element__label" for="input-06">State</label>
            <input type="text" id="input-id6" class="slds-input"/><br/><br/>
          </div>
        </div> 
        <div class="slds-form-element__row">
          <div class="slds-form-element slds-size_1-of-2" style="width: 300px;">
            <label class="slds-form-element__label" for="input-07">ZIP Code</label>
            <input type="number" id="input-id7" class="slds-input"/><br/><br/>
          </div>
        </div>
      </div>
    </fieldset>
  <label class="slds-form-element__label" for="input-unique-id8">Fax</label>
  <div class="slds-form-element__control" style="width: 350px;">
    <input type="Number" id="input-id8" class="slds-input"/><br/><br/>
  </div>
   <label class="slds-form-element__label" for="input-unique-id9">Industry</label>
  <div class="slds-form-element__control" style="width: 350px;">
    <input type="text" id="input-id9" class="slds-input" /><br/><br/>
  </div>
  </div>
 <center> <button Class="slds-button slds-button_destructive" id="btn" Onclick="GetValues()">Submit</button></center>
 <apex:actionFunction name="PassValues" action="{!Save}">
 <apex:param name="P1" value=""/>
 <apex:param name="P2" value=""/>
 <apex:param name="P3" value=""/>
 <apex:param name="P4" value=""/>
 <apex:param name="P5" value=""/>
 <apex:param name="P6" value=""/>
 <apex:param name="P7" value=""/>
 <apex:param name="P8" value=""/>
 <apex:param name="P9" value=""/>

</apex:actionFunction>
</apex:form>
</apex:page>

//controller    
Public class PolicyHolderDetails {
    Public string Name{get;set;}
    Public String PhoneNo{get;set;}
    Public string Website{get;set;}
    Public string Street{get;set;}
    Public string City{get;set;}
    Public string State{get;set;}
    Public String Zipcode{get;set;}
    Public string Fax{get;set;}

    Public String Industry{get;set;}
    Public String Insurance1{get;set;}
    Public String Insurance2{get;set;}
    Public String Insurance3{get;set;}
    Public String Insurance4{get;set;}

    Public String Nominee{get;set;}
    Public String PaymentMode{get;set;}
    Public String PaymentOptions{get;set;}
    Public String PolicyCoverage{get;set;}
    Public Date EnrollmentDate{get;set;}
    Public String Tenure{get;set;}

    Public void CheckInsurance(){
     Insurance1=Apexpages.currentPage().getParameters().get('Param1');
     Insurance2=Apexpages.currentPage().getParameters().get('Param2');
     Insurance3=Apexpages.currentPage().getParameters().get('Param3');
     Insurance4=Apexpages.currentPage().getParameters().get('Param4');
        System.debug(LoggingLevel.Info, 'HELLO');
     if(Insurance1=='Health Insurance'){
       system.debug('HIHIH:::::::'+Insurance1);
     system.debug(Insurance1);
       policy__c Pid=[select id from policy__c where Policy_Name__c='Health Insurance'][0];
        Account a=[Select id from Account where name=:Name][0];

      }
      if(Insurance2=='Home Insurance'){
       system.debug('HIHIH:::::::'+Insurance1);
     system.debug(Insurance1);
       policy__c Pid=[select id from policy__c where Policy_Name__c='Health Insurance'][0];
        Account a=[Select id from Account where name=:Name][0];

      }
      if(Insurance3=='Life Insurance'){
       system.debug('HIHIH:::::::'+Insurance1);
     system.debug(Insurance1);
       policy__c Pid=[select id from policy__c where Policy_Name__c='Health Insurance'][0];
        Account a=[Select id from Account where name=:Name][0];

      }
      if(Insurance4=='Automobile Insurance'){
       system.debug('HIHIH:::::::'+Insurance1);
     system.debug(Insurance1);
       policy__c Pid=[select id from policy__c where Policy_Name__c='Health Insurance'][0];
        Account a=[Select id from Account where name=:Name][0];

      }
    }

    Public PageReference Save(){ 
    system.debug('hihi:::'); 
    Name=Apexpages.currentPage().getParameters().get('P1');
    PhoneNo=Apexpages.currentPage().getParameters().get('P2');
    Website=Apexpages.currentPage().getParameters().get('P3');
    Street=Apexpages.currentPage().getParameters().get('P4');
    City=Apexpages.currentPage().getParameters().get('P5');
    State=Apexpages.currentPage().getParameters().get('P6');
    Zipcode=Apexpages.currentPage().getParameters().get('P7');
    Fax=Apexpages.currentPage().getParameters().get('P8');
    Industry=Apexpages.currentPage().getParameters().get('P9');
    Account a=new Account(name=Name,Phone=PhoneNo,Website=Website,BillingStreet=Street,BillingCity=City,
     BillingState=State,Fax=Fax,Industry=Industry,BillingPostalCode=Zipcode);
     system.debug(a);
    insert a;
     system.debug(a);
    return null;
    }

    Public PageReference SaveAgreement() {
    system.debug('HHIIH:::');
      Agreement__c ag=new Agreement__c(Policy__c='a007F0000033ROm',Policy_Holder__c='0017F000007Ndrv',Nominee__c=Nominee,Payment_mode__c=PaymentMode,
      Payment_Options__c=PaymentOptions,Policy_Coverage__c=PolicyCoverage,
        Enrollment_Date__c=EnrollmentDate,Tenure__c=Tenure);
       insert ag; 
            return null;
        }

    }
5

add rerender attribute in your actionFunction, like this rerender='none'. It is a known issue in Salesforce that if you are not using rerender, then your actionFunction may not work properly.

  • Atlast thank you very much Aashish and sfdcfox..It helped..But why we need to proivde rerender?? – Deepak Agarwal Aug 20 '17 at 10:44
  • it is a known salesforce bug. actionSupport and actionFunction, both acts weirdly when rerender is not used with them. Not your fault at all. :) – Ashish Sharma Aug 20 '17 at 10:55
  • Ok!!Thanks very much!!But salesforce has to fix this i wasted almost 2 days on this issue. – Deepak Agarwal Aug 21 '17 at 6:10

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.