• NehaKS
  • NEWBIE
  • 30 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 20
    Replies

Hi,

 

I have a date input field in a popup window. Issue that i am facing is the date picker is not inligned with the text field. Could any one please address this issue

 

Thanks and Regards,

Neha

<apex:page standardController="Opportunity" showHeader="false" sidebar="false" extensions="testsavenclose" tabStyle="Opportunity">

<apex:form id="form">
<apex:pageBlock id="results" >
<apex:pageMessages id="msg" />

<apex:pageBlockButtons >
<apex:commandbutton action="{!save}" id="savebutton1" value="Save"/>


<apex:commandbutton action="{!cancel}" id="cancelbutton" value="Cancel" onclick="return confirmCancel();" immediate="true"/>
<script language="JavaScript" type="text/javascript">
function confirmCancel()
{
    var isCancel = confirm("Are you sure you wish to cancel?");
    if (isCancel)
    {
    window.top.close();
    return true;
    }
    return false;
}
</script>

</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity Header" collapsible="false" id="pbs1">
<apex:outputField value="{!opp.Name}" id="abc"/>
</apex:pageBlockSection>
<apex:pageBlocksection id="pbs2">
<apex:pageBlock title="Opportunity Line Items" mode="edit" id="pb">
<apex:pageBlockTable value="{!opp.OpportunityLineItems}" var="oppitems" align="center" id="main">
<apex:column value="{!oppitems.PricebookEntry.Name}" />
<apex:column headerValue="Line Description">
<apex:inputField value="{!oppitems.Description}"/>
</apex:column>
<apex:column headerValue="Date" >
<apex:inputField value="{!oppitems.ServiceDate}"/>
</apex:column>
<apex:column headerValue="Quantity">
                                <apex:inputField value="{!oppitems.Quantity}" rendered="{!NOT(oppitems.HasSchedule)}"/>
                                <apex:outputField value="{!oppitems.Quantity}" rendered="{!oppitems.HasSchedule}"/>
                            </apex:column> 

</apex:pageBlockTable>
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Hi,

 

Please find the below code:

 

 Apex Code:

 

public class testsavenclose
{
public Opportunity opp{get;set;}
public testsavenclose(ApexPages.StandardController stdController)
{
 opp = [SELECT Amount, Id, Name,CloseDate,StageName,Account.Name,Probability, (SELECT Quantity,  PricebookEntry.Name, Description, UnitPrice,ServiceDate,HasSchedule,HasRevenueSchedule FROM OpportunityLineItems order by PricebookEntry.Name) FROM Opportunity where id =:ApexPages.currentPage().getParameters().get('id')];
}
public PageReference save()
{
update opp.opportunitylineitems;
return null;
}
public PageReference cancel()
{
return null;
}
}

 Steps to get exception:

 

Edit the Quantity field on opportunity line item page block table. Give value "0.00" in quantity field.Click on save.

It throws following exception.

 

System.DmlException: Update failed. First exception on row 0 with id 00k90000005VlrnAAC; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: Quantity (quantity must be nonzero): [Quantity]

 

how do i handle this exception.

 

 

<apex:page standardController="Account">
<script type="text/javascript">
function test()
{

var accname=document.getElementById("{!$Component.f.pb1.pbs1.a}").value;
alert(accname);
var message=document.getElementById("{!$Component.f.pb1.msg}").value;
alert(message);

}

</script>

<apex:form id="f">
<apex:pageBlock id="pb1">
<apex:pageMessages id="msg" />
<apex:pageBlockSection id="pbs1">
<apex:inputField value="{!account.name}" id="a" />
<apex:inputField value="{!account.industry}"/>
<apex:commandButton action="{!save}" value="Save!"/>
<apex:commandButton onclick="test();" value="test"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 For the above code

I am getting the value of field in account name but i am not able to get the error message displayed in alert

Its giving as "undefined".

 

Could anyone please help me out with this.

Hi,

 

I have a button save and close on popup window. The data is saved in database and the the window closes.

 

But if any error messages occurs it still closes the window.

 

Kindly help me out with this issue

 

 

Hi all,

 

Heres my scenario

I want to edit the opportunity line items for a particular opportunity using vf page. The opportunity line items are displayed in a pageblock block table.

I have 3 button on the page "Save", "Save & Close" and "Cancel"

"Save" button is saving the data in database.

"Save & Close" button is saving the data in database and closing the window.

"Cancel " button will undo the changes if not saved yet.

 

Only save button is functional-- the data is saved in database and if error in entering the date it show apex message.

But the 'save & close' button-- data is not saved in database nor it gives error if date is not entered properly

 

Here goes my code

Apex Class:-

public class ProductScheduler1
{
      public Opportunity opp{get;set;}   
      public ProductScheduler1(ApexPages.StandardController stdController) 
      {
        opp = [SELECT Amount, Id, Name,CloseDate,StageName,Account.Name,Probability, (SELECT Quantity,  PricebookEntry.Name, Description, UnitPrice,ServiceDate FROM OpportunityLineItems order by PricebookEntry.Name) FROM Opportunity where id =:ApexPages.currentPage().getParameters().get('id')];
      }
      public PageReference save() 
      {
        update opp.opportunitylineitems;
        return null;
      }
      public PageReference cancel() 
      {
        return null;    
      }
}

 

Visualforce Page:-

 

<apex:page standardController="Opportunity" showHeader="false" sidebar="false" extensions="ProductScheduler1" tabStyle="Opportunity">
    <apex:form >
    <apex:pageBlock >
        <apex:pageMessages />
        <apex:pageBlockButtons >
            <apex:commandbutton action="{!save}" id="savebutton1" value="Save"/>
            <apex:commandbutton action="{!save}" id="savebutton" oncomplete="javascript&colon;CloseAndRefresh()" value="Save & Close" />
            <script language="JavaScript" type="text/javascript">
            function CloseAndRefresh()
            {
                window.opener.location.href="/{!$CurrentPage.parameters.id}";
                window.top.close();  
            }
            </script>
 
            <apex:commandbutton action="{!cancel}" id="cancelbutton" value="Cancel" oncomplete="return confirmCancel();" immediate="true"/> 
            <script language="JavaScript" type="text/javascript">
            function confirmCancel()
            {
                var isCancel = confirm("Are you sure you wish to cancel?");
                if (isCancel)
                {
                    window.top.close();  
                    return true;
                }
                return false;
            }
            </script>    
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Opportunity Header" collapsible="false">
            <apex:outputField value="{!opp.Name}"/>                    
        </apex:pageBlockSection>
        <apex:pageBlocksection >
            <apex:pageBlock title="Opportunity Line Items" mode="edit" id="pb">
                <apex:pageBlockTable value="{!opp.OpportunityLineItems}" var="oppitems" align="center" id="main">
                    <apex:column value="{!oppitems.PricebookEntry.Name}" /> 
                    <apex:column headerValue="Line Description">
                         <apex:inputField value="{!oppitems.Description}"/>
                    </apex:column>
                    <apex:column headerValue="Date" >
                        <apex:inputField value="{!oppitems.ServiceDate}"/>
                    </apex:column>    
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

 

 

Hi all,

 

I want to show the list of the existing line items for the opportunity i a page block table and have an add button to add more line items.

 

I am getting error when i run this code. Also i am not able to pull the existing line items.

 

public class AddRowsOpli     
{  
    public List<OpportunitylineitemWrapper> wrappers {get; set;}  
    public static Integer toDelIdent {get; set;}  
    public static Integer addCount {get; set;}  
    private Integer nextIdent=0;     
    public AddrowsOpli() 
     {   wrappers=new List<OpportunitylineitemWrapper>();   
         for (Integer idx=0; idx<5; idx++)   
         {    
            wrappers.add(new OpportunitylineitemWrapper(nextIdent++));   
         }  
      }     
      public void delWrapper()  
      {   
           Integer toDelPos=-1;   
           for (Integer idx=0; idx<wrappers.size(); idx++)   
           {    
                if (wrappers[idx].ident==toDelIdent)    
                {    
                     toDelPos=idx;    
                }   
           }       
            if (-1!=toDelPos)   
            {    
              wrappers.remove(toDelPos);   
            }  
       }     
       public void addRows() 
        {   
          for (Integer idx=0; idx<addCount; idx++)   
          {    
               wrappers.add(new OpportunitylineitemWrapper(nextIdent++));   
           }  
        }     
        public PageReference save()  
        {   
               List<Opportunitylineitem> opps=new List<Opportunitylineitem>();   
               for (OpportunitylineitemWrapper wrap : wrappers)   
               {    
                     opps.add(wrap.opp);   
               }       
               insert opps;       
               return new PageReference('/' + Schema.getGlobalDescribe().get('Opportunity').getDescribe().getKeyPrefix() + '/o');  
         }    
         public class OpportunitylineitemWrapper 
         {  
           
          public Opportunitylineitem opp {get; private set;}   
          public Integer ident {get; private set;}       
          public OpportunitylineitemWrapper(Integer inIdent)   
               {    
             ident=inIdent;    
             opp=new Opportunitylineitem(opportunityId=ApexPages.currentPage().getParameters().get('id'));  
/*             OpportunityLineItem i = new OpportunityLineItem();
        i.opportunityId       = o.id;
        i.pricebookentryid    = pbe.id;
        i.quantity            = 1;
        i.unitprice           = 1;
 opp = [SELECT Amount, Id, Name,CloseDate,StageName,Account.Name,Probability, (SELECT Quantity,  PricebookEntry.Name, Description, UnitPrice,ServiceDate FROM OpportunityLineItems) FROM Opportunity where id =:ApexPages.currentPage().getParameters().get('id')];
 o=[SELECT opportunityid,Quantity,  PricebookEntry.Name, Description, UnitPrice,ServiceDate, (Select OpportunityLineItem.PricebookEntry.Product2.Name, Id, OpportunityLineItemId,ScheduleDate,Revenue, Quantity, Description From OpportunityLineItemSchedules) FROM OpportunityLineItem where opportunityid=:ApexPages.currentPage().getParameters().get('id')];      
       
       
        */
 
               } 
           } 
}

 Page code

<apex:page controller="AddRowsOpli" tabstyle="Opportunity">  
<apex:form >    
<apex:pageBlock title="Bulk Opportunitylineitem Create">       
<apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">          
<apex:column headerValue="Ident">             
<apex:outputText value="{!wrapper.ident}"/>          
</apex:column>          
<apex:column headerValue="Name">             
<apex:inputField value="{!wrapper.opp.opportunity.name}"/>          
</apex:column>          
<apex:column headerValue="Quantity">             
<apex:inputField value="{!wrapper.opp.Quantity}"/>          
</apex:column>          
<apex:column headerValue="PricebookEntry">             
<apex:inputField value="{!wrapper.opp.PricebookEntryId}"/>         
</apex:column>         
<apex:column headerValue="UnitPrice">             
<apex:inputField value="{!wrapper.opp.UnitPrice}"/>       
</apex:column>
<apex:column headerValue="ServiceDate">             
<apex:inputField value="{!wrapper.opp.ServiceDate}"/>       
</apex:column>   

<apex:column headerValue="Action">             
<apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">                
<apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>              
</apex:commandButton>          
</apex:column>       
</apex:pageBlockTable>       
<apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable">         
<apex:param name="addCount" value="1" assignTo="{!addCount}"/>        
</apex:commandButton>       
<apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable">          
<apex:param name="addCount" value="5" assignTo="{!addCount}"/>        
</apex:commandButton>       
<apex:commandButton value="Save" action="{!save}"/>   
</apex:pageBlock> 
</apex:form> 
</apex:page>

 

 

 

<style>
#popupcontent{
   position:static;
     display: none;
}
</style>
<script>
        function getData(oid)
        {
            paraFunction(oppid);
        }
     
        function showpopup()
        {
            var popUp = document.getElementById("popupcontent");
            popUp.style.display = "inline";
        }
 </script>

 <apex:actionFunction name="paraFunction" action="{!getOLIS}" rerender="results1" oncomplete="showpopup();">   
         <apex:param id="oppitems" name="oppitems" value="" />
     </apex:actionFunction>
.
<apex:column>
<apex:commandlink value=">>" onmouseover="getData('{!opw.id}');" rerender="results"/>
 </apex:column>


Over Here:-
"results" is an output panel and "results1" is the pageblock.

The pop is shown inline but all the mouseover functionality is working only on one place. i.e on just one column. I need to change position of popup for particular mouse over position.

Hi,

 

I have a date input field in a popup window. Issue that i am facing is the date picker is not inligned with the text field. Could any one please address this issue

 

Thanks and Regards,

Neha

Hi,

 

I have a date input field in a popup window. Issue that i am facing is the date picker is not inligned with the text field. Could any one please address this issue

 

Thanks and Regards,

Neha

Please find my VF code below:

<apex:page controller="ContestDisplayController" id="page" showHeader="false" sidebar="false">
<apex:pageBlock title="Contest Images" id="block">
<apex:repeat value="{!contstPicList}" var="contnt" id="blckTable">
<apex:outputPanel layout="block" style="float:left;height:110px;margin:5px">
<a href="{!contnt.Document_URL__c}" target="_top">
<apex:outputField value="{!contnt.Picture__c}"/>
</a>
</apex:outputPanel>
</apex:repeat>
</apex:pageBlock>

</apex:page>

 

I have an inline style in ouputPanel tag but this is not working in IE browsers. And working in Chrome and Mozilla. 

Can anyone suggest me where I have done wrong?

<apex:page standardController="Opportunity" showHeader="false" sidebar="false" extensions="testsavenclose" tabStyle="Opportunity">

<apex:form id="form">
<apex:pageBlock id="results" >
<apex:pageMessages id="msg" />

<apex:pageBlockButtons >
<apex:commandbutton action="{!save}" id="savebutton1" value="Save"/>


<apex:commandbutton action="{!cancel}" id="cancelbutton" value="Cancel" onclick="return confirmCancel();" immediate="true"/>
<script language="JavaScript" type="text/javascript">
function confirmCancel()
{
    var isCancel = confirm("Are you sure you wish to cancel?");
    if (isCancel)
    {
    window.top.close();
    return true;
    }
    return false;
}
</script>

</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity Header" collapsible="false" id="pbs1">
<apex:outputField value="{!opp.Name}" id="abc"/>
</apex:pageBlockSection>
<apex:pageBlocksection id="pbs2">
<apex:pageBlock title="Opportunity Line Items" mode="edit" id="pb">
<apex:pageBlockTable value="{!opp.OpportunityLineItems}" var="oppitems" align="center" id="main">
<apex:column value="{!oppitems.PricebookEntry.Name}" />
<apex:column headerValue="Line Description">
<apex:inputField value="{!oppitems.Description}"/>
</apex:column>
<apex:column headerValue="Date" >
<apex:inputField value="{!oppitems.ServiceDate}"/>
</apex:column>
<apex:column headerValue="Quantity">
                                <apex:inputField value="{!oppitems.Quantity}" rendered="{!NOT(oppitems.HasSchedule)}"/>
                                <apex:outputField value="{!oppitems.Quantity}" rendered="{!oppitems.HasSchedule}"/>
                            </apex:column> 

</apex:pageBlockTable>
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Hi,

 

Please find the below code:

 

 Apex Code:

 

public class testsavenclose
{
public Opportunity opp{get;set;}
public testsavenclose(ApexPages.StandardController stdController)
{
 opp = [SELECT Amount, Id, Name,CloseDate,StageName,Account.Name,Probability, (SELECT Quantity,  PricebookEntry.Name, Description, UnitPrice,ServiceDate,HasSchedule,HasRevenueSchedule FROM OpportunityLineItems order by PricebookEntry.Name) FROM Opportunity where id =:ApexPages.currentPage().getParameters().get('id')];
}
public PageReference save()
{
update opp.opportunitylineitems;
return null;
}
public PageReference cancel()
{
return null;
}
}

 Steps to get exception:

 

Edit the Quantity field on opportunity line item page block table. Give value "0.00" in quantity field.Click on save.

It throws following exception.

 

System.DmlException: Update failed. First exception on row 0 with id 00k90000005VlrnAAC; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: Quantity (quantity must be nonzero): [Quantity]

 

how do i handle this exception.

 

 

<apex:page standardController="Account">
<script type="text/javascript">
function test()
{

var accname=document.getElementById("{!$Component.f.pb1.pbs1.a}").value;
alert(accname);
var message=document.getElementById("{!$Component.f.pb1.msg}").value;
alert(message);

}

</script>

<apex:form id="f">
<apex:pageBlock id="pb1">
<apex:pageMessages id="msg" />
<apex:pageBlockSection id="pbs1">
<apex:inputField value="{!account.name}" id="a" />
<apex:inputField value="{!account.industry}"/>
<apex:commandButton action="{!save}" value="Save!"/>
<apex:commandButton onclick="test();" value="test"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 For the above code

I am getting the value of field in account name but i am not able to get the error message displayed in alert

Its giving as "undefined".

 

Could anyone please help me out with this.

Hi,

 

I have a button save and close on popup window. The data is saved in database and the the window closes.

 

But if any error messages occurs it still closes the window.

 

Kindly help me out with this issue

 

 

Hi all,

 

Heres my scenario

I want to edit the opportunity line items for a particular opportunity using vf page. The opportunity line items are displayed in a pageblock block table.

I have 3 button on the page "Save", "Save & Close" and "Cancel"

"Save" button is saving the data in database.

"Save & Close" button is saving the data in database and closing the window.

"Cancel " button will undo the changes if not saved yet.

 

Only save button is functional-- the data is saved in database and if error in entering the date it show apex message.

But the 'save & close' button-- data is not saved in database nor it gives error if date is not entered properly

 

Here goes my code

Apex Class:-

public class ProductScheduler1
{
      public Opportunity opp{get;set;}   
      public ProductScheduler1(ApexPages.StandardController stdController) 
      {
        opp = [SELECT Amount, Id, Name,CloseDate,StageName,Account.Name,Probability, (SELECT Quantity,  PricebookEntry.Name, Description, UnitPrice,ServiceDate FROM OpportunityLineItems order by PricebookEntry.Name) FROM Opportunity where id =:ApexPages.currentPage().getParameters().get('id')];
      }
      public PageReference save() 
      {
        update opp.opportunitylineitems;
        return null;
      }
      public PageReference cancel() 
      {
        return null;    
      }
}

 

Visualforce Page:-

 

<apex:page standardController="Opportunity" showHeader="false" sidebar="false" extensions="ProductScheduler1" tabStyle="Opportunity">
    <apex:form >
    <apex:pageBlock >
        <apex:pageMessages />
        <apex:pageBlockButtons >
            <apex:commandbutton action="{!save}" id="savebutton1" value="Save"/>
            <apex:commandbutton action="{!save}" id="savebutton" oncomplete="javascript&colon;CloseAndRefresh()" value="Save & Close" />
            <script language="JavaScript" type="text/javascript">
            function CloseAndRefresh()
            {
                window.opener.location.href="/{!$CurrentPage.parameters.id}";
                window.top.close();  
            }
            </script>
 
            <apex:commandbutton action="{!cancel}" id="cancelbutton" value="Cancel" oncomplete="return confirmCancel();" immediate="true"/> 
            <script language="JavaScript" type="text/javascript">
            function confirmCancel()
            {
                var isCancel = confirm("Are you sure you wish to cancel?");
                if (isCancel)
                {
                    window.top.close();  
                    return true;
                }
                return false;
            }
            </script>    
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Opportunity Header" collapsible="false">
            <apex:outputField value="{!opp.Name}"/>                    
        </apex:pageBlockSection>
        <apex:pageBlocksection >
            <apex:pageBlock title="Opportunity Line Items" mode="edit" id="pb">
                <apex:pageBlockTable value="{!opp.OpportunityLineItems}" var="oppitems" align="center" id="main">
                    <apex:column value="{!oppitems.PricebookEntry.Name}" /> 
                    <apex:column headerValue="Line Description">
                         <apex:inputField value="{!oppitems.Description}"/>
                    </apex:column>
                    <apex:column headerValue="Date" >
                        <apex:inputField value="{!oppitems.ServiceDate}"/>
                    </apex:column>    
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

<style>
#popupcontent{
   position:static;
     display: none;
}
</style>
<script>
        function getData(oid)
        {
            paraFunction(oppid);
        }
     
        function showpopup()
        {
            var popUp = document.getElementById("popupcontent");
            popUp.style.display = "inline";
        }
 </script>

 <apex:actionFunction name="paraFunction" action="{!getOLIS}" rerender="results1" oncomplete="showpopup();">   
         <apex:param id="oppitems" name="oppitems" value="" />
     </apex:actionFunction>
.
<apex:column>
<apex:commandlink value=">>" onmouseover="getData('{!opw.id}');" rerender="results"/>
 </apex:column>


Over Here:-
"results" is an output panel and "results1" is the pageblock.

The pop is shown inline but all the mouseover functionality is working only on one place. i.e on just one column. I need to change position of popup for particular mouse over position.

Hi,

 

I need to write test class for wrapper class coverage.

 

CLASS
----------
public without sharing class OppController {
    
    public OppController() {

    }
private class wrapOpp {
        public Integer index { get; set; }
        public Opportunity opp {get; set;}
        public String error {get; set; } 
        public List<SelectOption> allEquipments {
            get {
                List<SelectOption> Equipments = new List<SelectOption>();
                Equipments = OppUtil.allEquipmentOptions;
                return Equipments;
            }
        }
        
        public List<SelectOption> allNotifyDates {
            get {
                List<SelectOption> NotifyDates = new List<SelectOption>();
                if(opp.Property__c != null) {
                    NotifyDates = OppUtil.allNotifyDateOptions.get(opp.Equipment__c);
                }
                return NotifyDates;
            }
        }

    private wrapOpp(Integer ndx, Opportunity o, String err) {
            index = ndx;
            opp = o;
            error = err;           
        }
    }
  }
 

 

  TEST CLASS (wrapper line)
  -------------------------------------
 
 public class testOppclass{

 

 public static testmethod void TestOppMethod(){


  OppController.wrapperOpp Wrapvar = new OppController.wrapperOpp();

}

}

 

 

When I declare a variable I am getting error message as

" Type not visible ; OppController.wrapperOpp" on the line "OppController.wrapperOpp Wrapvar = new OppController.wrapperOpp();"

 

Please help me in identifying the issue.

 

Thanks,

JBabu.

  • May 08, 2012
  • Like
  • 0