+ Start a Discussion
Deepika GulatiDeepika Gulati 

Urgent::Alert Box With 'Yes' and 'No' Button!

Hi,

 

I have a Requirement to implement a code in which we when we enter already existing Reference Number, alert Box pops up with 'Yes' and 'No' button,

If Yes is clicks it overrides the value in on the Task Detail page and closes the VF page.

If No is clicked it remains on the Same Page.

 

 

Currently i am using following VF page code:

 

<apex:page standardController="Task" extensions="ParentChildActivity" action="{!childTaskDetails}"   >
       <apex:form id="form1" >
            <apex:outputPanel id="jspanel">
                <script type="text/javascript">
                      function closeWindow()
                      {
                            if({!error})
                            {
                                opener.location.reload();
                                window.close();
                             }
                             else           
                             {
                                alert('TRN is not Valid!');
                             }
                                          
                      }
               </script>  
          </apex:outputPanel>
         <style  type="text/css">
             .header1{
                 background-color:#DCDBD8;
                 text-align:center;
                 padding:12px;
                     }
         </style>
        
        
     <apex:outputPanel id="pnlAddTRN" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
         <apex:pageBlock id="pb1" >
               <apex:pageBlockSection id="pbs1" collapsible="true" columns="4" title="Add Parent">
                  <apex:outputLabel value="Activity TRN"></apex:outputLabel>
                  <apex:inputText value="{!trn}" required="true"/>
                  <apex:commandButton value="GO" oncomplete="closeWindow()" action="{!searchAndUpdate}"    style="header1"/>
                  <apex:outputLink value="/{!$CurrentPage.parameters.id}"><font color="red" ><b> Cancel </b></font></apex:outputLink>            
               </apex:pageBlockSection>
         </apex:pageBlock>

 <apex:pageBlock id="searchResults" rendered="{!errorAlertC}">
            <apex:pageBlockSection title="Child Activities" rendered="{!errorAlertC}" >
                <apex:dataTable value="{!childTasks}" var="child" border="2px" columnsWidth="10px"  frame="border"  title="Child Activities" headerClass="header1" rendered="{!errorAlertC}" >
                    <apex:column >
                        <apex:facet name="header">
                            Subject
                        </apex:facet>
                        <apex:outputLink value="/{!child.id}" target="_blank">{!child.subject}</apex:outputLink>
                    </apex:column>
           
                    <apex:column >
                        <apex:facet name="header">
                            Related To
                        </apex:facet>
                        <apex:outputField value="{!child.whatId}" style="padding:5px"></apex:outputField>
                    </apex:column>

                   <apex:column >           
                        <apex:facet name="header">
                            Name
                        </apex:facet>
                        <apex:outputField value="{!child.WhoId}" style="padding:5px"></apex:outputField>
                   </apex:column>

                    <apex:column >
                       <apex:facet name="header">
                            Type
                       </apex:facet>
                       <apex:outputText value="{!child.Type}" style="padding:5px"></apex:outputText>
                   </apex:column>


                   <apex:column >
                       <apex:facet name="header">
                            Status
                       </apex:facet>
                       <apex:outputText value="{!child.status}" style="padding:5px"></apex:outputText>
                   </apex:column>

                   <apex:column >
                       <apex:facet name="header">
                            CIDN
                       </apex:facet>
                       <apex:outputText value="{!child.Customer_CIDN__c}" style="padding:5px"></apex:outputText>
                   </apex:column>
           
                   <apex:column >
                       <apex:facet name="header">
                            Activity TRN
                       </apex:facet>
                       <apex:outputText value="{!child.Activity_TRN__c}" ></apex:outputText>
                   </apex:column>

                   <apex:column >
                       <apex:facet name="header">
                            Priority
                       </apex:facet>
                       <apex:outputText value="{!child.Priority}" ></apex:outputText>
                   </apex:column>
                 
                   <apex:column >
                        <apex:facet name="header">
                        Activity Date   
                        </apex:facet>
                        <apex:outputField value="{!child.ActivityDate}" style="padding:5px"></apex:outputField>
                    </apex:column>

 

                   <apex:column >
                        <apex:facet name="header">
                            Assigned To
                        </apex:facet>
                        <apex:outputField value="{!child.ownerId}" style="padding:5px"></apex:outputField>
                    </apex:column>

 

                </apex:dataTable>
           
           </apex:pageBlockSection>
       
        </apex:pageBlock>

</apex:outputpanel>

</apex:form>

</apex:page>

 

 

 

 

I need urgent help in this.


              

 

 

Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below code snippet as reference

 

<apex:page >

<script>

 function cnfrmAction()

{

  var r=confirm('Are you sure you want to Proceed on Action');

   

  if (r==true)

  {

   alert("You pressed OK!");

 

  }

  else

  {

      alert('You Pressed Cancel');

  }

  }

  </script>

  <apex:form >

  <apex:commandButton value="On Click" onclick="cnfrmAction()" reRender="" oncomplete=""/>

  </apex:form>

</apex:page>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

Deepika GulatiDeepika Gulati

Hi,

Thanks a Lot.

As i am new to SFDC can you please help me .

I want to call this function when the value i entered for TRN already exists, otherwise not.

Can i apply javascript on onclick attribute. Can you tell me the syntax for that.

 

Also if the user presses 'OK'.

I need to call the function from the Controller to override the value .

Can i call a Controller function from Javascript.

 

Thanks and Regards