+ Start a Discussion
Kiran Kumar GottulaKiran Kumar Gottula 

URLFOR function in Action methods....

Hi folks,
please help out.

When I click on standard convert button on lead. i want to check the Cancel_Workflow__c check box field and updating it. after that it will navigate to standard lead convert page with auto update the opportunity name with some field in lead record. which is given below. while saving the vf page. i have some error message. am I miss anyhting?

Error : Error: Syntax error. Found '['

FYI:

<apex:page standardController="Lead" > 
<apex:form > 
  <div style="visibility:hidden;"> 
    <apex:inputField value="{!Lead.Cancel_Workflow__c}" id="cancelWorkflow" style="visibility:hidden; "/> 
  </div> 
  <apex:actionFunction name="quickSave" action="{!quickSave}" oncomplete="standardConvert();"/> 
  <apex:actionFunction name="standardConvert" 
    action="{{!URLFOR("/lead/leadconvert.jsp", lead.id, 
    [&sem="1",&noopptt=Lead.FirstName, Lead.LastName - Lead.Departure_City_Leg_1__c-Lead.Arrival_City_Leg_1__c - Lead.Departure_Date_Leg_1__c,&IsReminderSet_fu="0"] , [retURL=$CurrentPage.parameters.retURL], true)}}" />
  <script language="JavaScript"> 
    var previousOnload = window.onload; 
    window.onload = function() { 
      if (previousOnload) previousOnload(); 
      fixLead(); 
    } 
    function fixLead() { 
      var elemCancelWorkflow = document.getElementById('{!$Component.cancelWorkflow}'); 
      elemCancelWorkflow.checked = true; 
      quickSave(); 
    } 
  </script> 
</apex:form> 
</apex:page>



 
Best Answer chosen by Kiran Kumar Gottula
Kiran Kumar GottulaKiran Kumar Gottula
And finally i got results using the following code.

<apex:page standardController="Lead" > 
<apex:form > 
  <div style="visibility:hidden;"> 
    <apex:inputField value="{!Lead.Cancel_Workflow__c}" id="cancelWorkflow" style="visibility:hidden; "/> 
    {!lead.firstname}
    {!lead.LastName }
    {!lead.Departure_City_Leg_1__c}
    {!lead.Arrival_City_Leg_1__c}
    {!lead.Sys_Departure_Date_Leg_1__c}
  </div> 
  <apex:actionFunction name="quickSave" action="{!quickSave}" oncomplete="standardConvert();"/> 
  <apex:actionFunction name="standardConvert" 
    action="{!URLFOR($Action.Lead.Convert, lead.id, [retURL=Lead.Id,sem="1",noopptt = Lead.FirstName + ' '+Lead.LastName +' - '+Lead.Departure_City_Leg_1__c+'-'+Lead.Arrival_City_Leg_1__c+'-'+Lead.Sys_Departure_Date_Leg_1__c,IsReminderSet_fu="0"], false)}" />
  <script language="JavaScript"> 
    var previousOnload = window.onload; 
    window.onload = function() { 
      if (previousOnload) previousOnload(); 
      fixLead(); 
    } 
    function fixLead() { 
      var elemCancelWorkflow = document.getElementById('{!$Component.cancelWorkflow}'); 
      elemCancelWorkflow.checked = true; 
      quickSave(); 
    } 
  </script> 
</apex:form> 
</apex:page>
 

All Answers

Swati GSwati G
How do you want to construct urlfor?
BalajiRanganathanBalajiRanganathan
1) do not use & inside[]
2) do not use "" inside []
3) use [name1=value, name2=value2] format
4) the funntion can take only 4 arguments 

<apex:actionFunction name="standardConvert" 
    action="{!URLFOR("/lead/leadconvert.jsp", lead.id, [sem=1,noopptt=Lead.FirstName, newparam=Lead.LastName - Lead.Departure_City_Leg_1__c-Lead.Arrival_City_Leg_1__c - Lead.Departure_Date_Leg_1__c,IsReminderSet_fu=0,retURL=$CurrentPage.parameters.retURL] , true)}" />

i have added paramname as newparam for Lead.LastName expresion.
Kiran Kumar GottulaKiran Kumar Gottula
And finally i got results using the following code.

<apex:page standardController="Lead" > 
<apex:form > 
  <div style="visibility:hidden;"> 
    <apex:inputField value="{!Lead.Cancel_Workflow__c}" id="cancelWorkflow" style="visibility:hidden; "/> 
    {!lead.firstname}
    {!lead.LastName }
    {!lead.Departure_City_Leg_1__c}
    {!lead.Arrival_City_Leg_1__c}
    {!lead.Sys_Departure_Date_Leg_1__c}
  </div> 
  <apex:actionFunction name="quickSave" action="{!quickSave}" oncomplete="standardConvert();"/> 
  <apex:actionFunction name="standardConvert" 
    action="{!URLFOR($Action.Lead.Convert, lead.id, [retURL=Lead.Id,sem="1",noopptt = Lead.FirstName + ' '+Lead.LastName +' - '+Lead.Departure_City_Leg_1__c+'-'+Lead.Arrival_City_Leg_1__c+'-'+Lead.Sys_Departure_Date_Leg_1__c,IsReminderSet_fu="0"], false)}" />
  <script language="JavaScript"> 
    var previousOnload = window.onload; 
    window.onload = function() { 
      if (previousOnload) previousOnload(); 
      fixLead(); 
    } 
    function fixLead() { 
      var elemCancelWorkflow = document.getElementById('{!$Component.cancelWorkflow}'); 
      elemCancelWorkflow.checked = true; 
      quickSave(); 
    } 
  </script> 
</apex:form> 
</apex:page>
 
This was selected as the best answer