• Vishwanath
  • NEWBIE
  • 24 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 26
    Replies
Hi 
I have a page url like
when we click on this link it should open as a public link where, the user can insert the data into the system.
How can i do this, link as a public usage without login credentials???
thanks in advance
  • January 25, 2012
  • Like
  • 0

Hi,

how to use <div style="page-break-after:auto;"> in the below code i  tried  but not worked

issue is when the page is going to second page it will displaing on the header please any one give some solution to

<apex:page controller="LetterController" sidebar="false" showheader="false" renderAs="PDF">
<html>
<head>
<style type="text/css">
            @page {          
                @top-center {                   
                    content: element(header);               
                            }
                @bottom-left {
                    content: element(footer);
                            }           
                 }                       
         
            div.header { 
                padding: -5px;              
                position: running(header);           
                        }           
            
            div.footer {
                padding:-5px;
                position: running(footer);                                   
                        }

        </style>
<style type="text/css">
    @page { 
        size: A4 landscape;

        }
    }
 </style>
<style type="text/css">
table
{

border-collapse:collapse;
}
table, td, th
{

border:1px solid black;
}

</style>
</head>
<body>
<form>
    <div class="header">   
                <img style="WIDTH:130px; HEIGHT: 80px" src='{!URLFOR($Resource.UOP)}' title="logo" align="right"/>
				
            </div>

            <div class="footer" align="center"> 
                <hr/>
                    <apex:outputText value="UOP Confidential" style="font-style:Arial;font-size:15pt;color :#000000" />
            </div>
                
				  <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
				    <br/>
			
<table cellspacing="5" cellpadding="5">
	<div style="page-break-after:auto;">	
<tr>
<td ><b>name</b></td>
<td ><b>class</b></td>
<td><b>year</b></td>
<td><b>lname </b></td>

</tr>

<apex:repeat value="{!PUList}" var="p" >
<apex:repeat value="{!p.Payment_Throughput_Histroy__r}" var="pt">
<tr>
<td>

{!p.name}
</td>

<td>
{!pt.class}
</td>
<td>
{!pt.year}
</td>
<td>
{!pt.lname}
</td>
</tr>
</apex:repeat>
</apex:repeat>
</div>
</table>


</form>
</body>
</html>
</apex:page>

 Thanks,

 

how can i do this

Hi,

Please help me on this URL overriding

{!IF(ISPICKVAL(Opportunity.Forecast_Type__c,"Ship Date Specific"),
'/{!Opportunity.Id}/e?clone=1&retURL=%2F{!Opportunity.Id}&00N80000004eYzp={!Opportunity.Id}&00N80000004eZ0S=false&00N80000004eZ0u= &opp9={!TODAY()}',
'/{!Opportunity.Id}/e?clone=1&retURL=%2F{!Opportunity.Id}&00N80000004eYzp={!Opportunity.Id}&00N80000004eZ0S=false')}

 trying to clone the opportunity depending on the pick list value, using custome button

it saved but when i click the button it show URL No Longal EXISTS,

 

Thanks

Hi,

 

nedd help to write test class for below code

public class controller
{
Acc__c access{get;set;}
ANonSTD__c accNONSTD{get;set;}
AccSTD__c accSTD{get;set;}

public accessories(ApexPages.StandardController controller) {
 accSTD = new Accessories__c();
 accNONSTD = new Accessories__c();
 access = (Accessories__c)controller.getRecord();
List<Accessories__c> list_accTemp = new List<Accessories__c>();
  Accessories__c accTemp = new Accessories__c();
    if(access != null){
           list_accTemp  = [SELECT Id, Name, Type__c, Date_Ordered__c,  Date_Received__c  FROM Accessories__c  WHERE Id=:access.Id LIMIT 1];
         }
		 
        if(!list_accTemp.isEmpty())
            accTemp = list_accTemp[0];
        system.debug('??!!'+accTemp );

        if(accTemp.Type__c == 'Standard HB&J SSPDS Accessory')
            accSTD = accTemp;
        else    
            accNONSTD = accTemp;
			}
  public PageReference savecheck() {  
        PageReference retURL;        

        if(access.Type__c == 'Standard'){
            if(validateFields(accSTD)){
                accSTD.Type__c = access.Type__c;
                accSTD.Date_Ordered__c = access.Date_Ordered__c;
                accSTD.Date_Received__c = access.Date_Received__c;
             
                upsert accSTD;
                retURL= new PageReference('/'+accSTD.id);
             
            }
            else
                retURL = NULL;
        }
        else{
            if(validateFields(accNONSTD)){
                accNONSTD.Type__c = access.Type__c;
                accNONSTD.Date_Ordered__c = access.Date_Ordered__c;
                accNONSTD.Date_Received__c = access.Date_Received__c;
                
                upsert accNONSTD;
                retURL= new PageReference('/'+accNONSTD.id); 
            }
            else
                retURL = NULL;
        }
        //retURL.setRedirect(true);
        return retURL;
    }
	public Boolean validateFields(Acc__c givenRecord){
        Boolean blnReturn = true;
        
        if(givenRecord.Type__c == 'Standard HB&J SSPDS Accessory'){
            if(givenRecord.Product_Fleet__c == null){
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Product-Fleet Profile: You must enter a value.');
                ApexPages.addMessage(myMsg);
                blnReturn = false;
            }
            
            if(givenRecord.Quantity__c == ''){
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Quantity: You must enter a value.');
                ApexPages.addMessage(myMsg);
                blnReturn = false;
            }
          }
        else{
            if(givenRecord.Product_Fleet__c == null){
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Product-Fleet Profile: You must enter a value.');
                ApexPages.addMessage(myMsg);
                blnReturn = false;
            }
            
             if(givenRecord.Quantity__c == ''){
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Quantity: You must enter a value.');
                ApexPages.addMessage(myMsg);
                blnReturn = false;
            }
            
           
        }
        
        return blnReturn;
    }
}

 Thanks

Hi,

I have a static method as given below im tryong to writte a test class for this it shows error

please any one give some idea to solve this problem

 

public class controller
{
public static SPQ__c product { get; set; }
public String productname { get; set; }   
@RemoteAction
    global static SPQ__c getSPQPr(String productname) {
        product = [select id ,Standard_Cost__c, name from SPQ__c where name= :productname and Year__c='Mid Year 2011' limit 1];  
        return product;
    }  


@RemoteAction
    global static Test__c getType() {
        AccType = [select Accessory_Type__c , name from Test__c where id= :'a2mQ0000001MpvE' limit 1];
        return AccType;
    }  
    }

 Thanks,

Hi,

how to write test case for  below code

 

List<A__c> pay=new <A__c>();

pay=[select id,name,Year__c,Event__c from A__c where parent__c=:ppid];
  for(A__c rh:trigger.new)
   {
   for(A__c p:pay)
   {
   if(p.Year__c==rh.Year__c && p.Event__c==rh.Event__c)
   {
   Trigger.new[0].Year__c.addError(''+rh.Year__c+'Report is Created');
   }
   }
  }

 

Thaks..

Hi,

how to retrieve current year in apex class

Hi,

 

How to avoid 'System.LimitException: Too many SOQL queries: 101'

 

if(Trigger.isUpdate || Trigger.isUpdate)
     {
     Double ReportOverage;
    Double diffOverage;
    Double AuditOverage;
    for(UOP_Royalty_Payment_History__c UOP:Trigger.new)
    {
        if(UOP.Payment_History_Event__c!='Report')
        {
            List<UOP_Royalty_Payment_History__c> UOPList=[select id,name,Payment_History_Event__c,Overage__c,Throughput__c,Previous_Fully_Paid_Capacity__c from UOP_Royalty_Payment_History__c where Payment_History_Event__c=:'Report' and Process_Unit__c=:UOP.Process_Unit__c and UOP_Year__c=:UOP.UOP_Year__c limit 1];
            if(UOPList.size()>0)
            {
                ReportOverage=UOPList[0].Overage__c;
            }
            if(ReportOverage==null) // || ReportOverage=='')
            {
               UOP.Invoice_Ammount_For_FA_DA__c=UOP.Invoice_Amount__c;                 // Trigger.new[0].UOP_Year__c.addError('There is no Report in '+UOP.UOP_Year__c+'');  
            }
            else
            {
                AuditOverage=UOP.Throughput__c - UOP.Previous_Fully_Paid_Capacity__c;
                diffOverage=AuditOverage - ReportOverage;
                if(diffOverage <= 0)
                {
                    UOP.Invoice_Ammount_For_FA_DA__c=0.0;
                }
                else
                {
                    UOP.Invoice_Ammount_For_FA_DA__c=diffOverage * UOP.Royalty_Rate__c * (UOP.Applicable_BLS11__c / UOP.BLS_Base__c);
                }
            }
        }
        }
     }

 thansk

Hi All,

Please help me from this problem

 

i have one custome object and i wrote two wolrk flow rule (for some calculation) and one trigger (also some calculation, before insert and before update)

and 3 validation rules, and one formula filed it will call the value form other object depending on the condition

 

all of above is working fine, but it will take long time to save the record and when i open the system log

last line is showing

 05:30:*********** MAXIMUM DEBUG LOG SIZE REACHED *********** 

 

is it mean is any problem with in my trigger or work flow......?

 

 

 

 

 

Hi,

Please help me from this issue,

i need to display the error message on field when the list is empty

 

Trigger code

trigger InvoiceAmountCal on UOP_Royalty_Payment_History__c (Before insert,Before Update) 
{
Double ReportOverage;
Double diffOverage;
Double AuditOverage;
for(UOP_Royalty_Payment_History__c UOP:Trigger.new)
{
if(UOP.Payment_History_Event__c!='Report')
{
UOP_Royalty_Payment_History__c UOPList=[select id,name,Payment_History_Event__c,Overage__c,Throughput__c,Previous_Fully_Paid_Capacity__c from UOP_Royalty_Payment_History__c where Payment_History_Event__c=:'Report' and Process_Unit__c=:UOP.Process_Unit__c and UOP_Year__c=:UOP.UOP_Year__c];
ReportOverage=UOPList.Overage__c;
if(ReportOverage==null)
{
Trigger.new[0].UOP_Year__c.addError('There is no Report in '+UOP.UOP_Year__c+'');  
}
else
{
AuditOverage=UOP.Throughput__c - UOP.Previous_Fully_Paid_Capacity__c;
diffOverage=AuditOverage - ReportOverage;
if(diffOverage <= 0)
{
UOP.Invoice_Ammount_For_FA_DA__c=0.0;
}
else
{
UOP.Invoice_Ammount_For_FA_DA__c=diffOverage * UOP.Royalty_Rate__c * (UOP.Applicable_BLS__c / UOP.BLS_Base__c);
}
}
}
}
}

 in above trigger if  ReportOverage==null or the UOPList==null then it should display error

but when im save the record trigger displaing error list has no rows for assissgment to Sobject

 

 

HI,

Please any one, help me to solve this issue

 

"System.LimitException: Too many script statements: 200001  'Extarnal entry point" in test class

this error is occure when im going to run the test class

 

Controller:

public class paymentinvoicepdf
{
public paymentinvoicepdf(ApexPages.StandardController controller)
{
}
Public List<UOP_Aggregation_Group__c> agroup{get;set;}
public String contname{get;set;}
public String title{get;set;}
public String Email{get;set;}
public String Telephone{get;set;}
public Boolean flag{get;set;} //{get;set;}
public Royalty_Contacts__c rc{get;set;}
public List<Royalty_Contacts__c> rc1{get;set;}
public List<Royalty_Contacts__c> rc2{get;set;}

public PageReference royalcon()
{
Id id=Apexpages.currentpage().getparameters().get('id');
UOP_Royalty_Payment_History__c urp=[select id,name,Process_Unit__r.Account__r.UOP_CA_S_Account_Manager__c,Payment_History_Event__c,Invoice_Number__c,Invoice_Date__c from UOP_Royalty_Payment_History__c where id=:id];
id urpid=urp.Process_Unit__c;
 rc1=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Primary)'];
 if(rc1.size()>0)
 {
 flag=true;
 }
 
 rc2=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Secondary)' and Royalty_Role__c=:'Royalty (Primary)' ];
 if(rc2.size()>0)
 {
 flag=false;
 }
 /*for(Royalty_Contacts__c r:rc1)
 {
 if(r.Royalty_Role__c=='Royalty (Primary)')
 {
 flag=true;
 contname=r.Contact__r.name;
 title=r.Title__c;
 Email=r.Email__c;
 Telephone=r.Phone__c;
 //rc=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Primary)'];
 }
 else if(r.Royalty_Role__c=='Royalty (Secondary)')
 {
 flag=false;
 }
 
 }*/



 Process_Unit__c pu=[select id,name,Aggregation_Group__c from Process_Unit__c where id=:urpid];
 id aid=pu.Aggregation_Group__c;
 
 agroup=[select id,name,(select id,name,Aggregation_Group__c,Unique_Process_Unit_Identifier__c from Process_Units__r) from UOP_Aggregation_Group__c where id=:aid];
 
return null;
}

}

 

test class:

@istest()
public class paymentinvoicepdftest
{
public static testmethod void test()
{
UOP_Royalty_Payment_History__c uopCreat=new UOP_Royalty_Payment_History__c(Payment_History_Event__c='Report');
ApexPages.StandardController accCtrl = new ApexPages.Standardcontroller(uopCreat);


paymentinvoicepdf pay=new paymentinvoicepdf(accCtrl );
Account ac=new Account(name='test');
//ac.SAP_Customer_Info__c=s.id;
insert ac;
Process_Unit__c pu=new Process_Unit__c(name='testAccount',Account__c=ac.id,Status__c='Licensed',Technology_Supplier__c='ABB Lummus',
Units_Fully_Paid_Capacity__c='Accounting Units',Agreement_Status__c='Fully Executed',License_Type__c='Unit',Subject_To_Audit__c='yes',
Current_Royalty_Type__c='Fully Paid',UOM_Capacity__c='BPSD');
insert pu;
UOP_Royalty_Payment_History__c uop=new UOP_Royalty_Payment_History__c(Payment_History_Event__c='Report',Process_Unit__c=pu.id,
Royalty_Rate__c=0.50,Applicable_BLS__c=10,BLS_Base__c=100,UOP_Year__c='2001',Overage__c=11000);
insert uop;
    ApexPages.currentPage().getParameters().put('id',uop.id);

UOP_Royalty_Payment_History__c urp=[select id,name,Process_Unit__r.Account__r.UOP_CA_S_Account_Manager__c,Payment_History_Event__c,Invoice_Number__c,Invoice_Date__c from UOP_Royalty_Payment_History__c limit 1];
List<Royalty_Contacts__c> rc1=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urp.id and Royalty_Role__c=:'Royalty (Primary)']; 
 Process_Unit__c pu1=[select id,name,Aggregation_Group__c from Process_Unit__c where id=:pu.id limit 1];
 UOP_Aggregation_Group__c a=new UOP_Aggregation_Group__c(name='test');
 insert a;
 
 List<UOP_Aggregation_Group__c> agroup=[select id,name,(select id,name,Aggregation_Group__c,Unique_Process_Unit_Identifier__c from Process_Units__r) from UOP_Aggregation_Group__c where id=:a.id];
 
pay.royalcon();
}
}

 Give me some suggestions how to solve this issue

 

Thanks,

Vishwa A

Hi,

 

I am wrting the test class in Unlimited edition sandbox , when i use Test.starttest() method it will gives error as

 

' Method does not exist or incorrect signature: test.starttest() at line ......'

 

Priveously it works fine, but know it displaying the above error..

 

 

Hi, please any one help me out from  this issue,

im writing the test class for the trigger and im not able to cover the code that comes under for loop,

 

Trigger code

trigger PayHist_insert_Under_Agr_ProcessUnit on Royalty_Payment_History__c (before insert)
 {
 if
 (!TriggerRecurHelp.hasAlreadyCreatedRecursiv())
 {
 set<String> agid=new set<String>();
 set<id> pid=new set<id>();
 id ppid;
 for(Royalty_Payment_History__c UOP:Trigger.new)
 {
 ppid=UOP.Process_Unit__c;
 agid.add(UOP.Aggregation_Group__c);
 pid.add(UOP.Process_Unit__c);
 }
 Process_unit__c pp=[select id,name,Aggregation_Group__r.id from Process_Unit__c where id=:ppid];
 id aagid=pp.Aggregation_Group__r.id;
 UOP_Aggregation_Group__c aa;id prid;
 if(pp.Aggregation_Group__r.id!=null)
 {
 aa=[select id,name from UOP_Aggregation_Group__c where id=:aagid];
 prid=aa.id;
 }
 List<Process_Unit__c> pc=new List<PRocess_Unit__c>();
 pc=[select id,name from Process_Unit__c where Aggregation_Group__r.id=:prid and id!=:ppid];
 System.debug('total PU'+pc.size());
 List<Royalty_Payment_History__c> 
 insrtpay=new List<Royalty_Payment_History__c>();   
 Royalty_Payment_History__c inpay=new Royalty_Payment_History__c();   
 for(Royalty_Payment_History__c U:Trigger.new)  
 {    
 for(Process_Unit__c p:pc) 
 {    
 insrtpay.add(new Royalty_Payment_History__c(
 Payment_History_Event__c=U.Payment_History_Event__c,
 Process_Unit__c=p.id,    
 UOP_Year__c=U.UOP_Year__c,      
 Royalty_Type__c=U.Royalty_Type__c,   
 Comments__c=U.Comments__c,      
 Applicable_BLS__c=U.Applicable_BLS__c,   
 Application__c=U.Application__c,    
 Application_Id__c=U.Application_Id__c,       
 Capacity_Reporting_Inaccuracy__c=U.Capacity_Reporting_Inaccuracy__c,  
 BLS_Base__c=U.BLS_Base__c,       
 Created_By_User_Id__c=U.Created_By_User_Id__c,   
 Due_Date__c=U.Due_Date__c,      
 Invoice_Ammount_For_FA_DA__c=U.Invoice_Ammount_For_FA_DA__c,   
 Invoice_Amount__c=U.Invoice_Amount__c,      
 Invoice_Date__c=U.Invoice_Date__c,       
 Invoice_Number__c=U.Invoice_Number__c,   
 Invoice_Paid_Date__c=U.Invoice_Paid_Date__c,   
 Last_Modified_By_User_Id__c=U.Last_Modified_By_User_Id__c,     
 Mail__c=U.Mail__c,      
 New_Fully_Paid_Capacity__c=U.New_Fully_Paid_Capacity__c,   
 Overage__c=U.Overage__c,      
 Previous_Fully_Paid_Capacity__c=U.Previous_Fully_Paid_Capacity__c,   
 Process_Type__c=U.Process_Type__c,      
 Purchase_Order_No__c=U.Purchase_Order_No__c,  
 Report_Processed_Date__c=U.Report_Processed_Date__c,    
 Royalty_Rate__c=U.Royalty_Rate__c,  
 Sales_Order_No__c=U.Sales_Order_No__c,  
 Throughput__c=U.Throughput__c,      
 Units_of_Measure__c=U.Units_of_Measure__c));  
 }  
 }   
 TriggerRecurHelp.sethasAlreadyCreatedRecursiv(); 
 System.debug('insrtpay'+insrtpay.size()); 
 if (!insrtpay.isEmpty())
 {    
 try{  
 insert insrtpay;  
 }catch(Exception e){} 
 }       
 }     
 }
 

  test class code:

@istest()
Public class PayHist_insert_Under_Agr_ProcessUnittest
{
public static testmethod void test()
{
Aggregation_Group__c UOP=new Aggregation_Group__c();
UOP.name='testAgg';
insert UOP;

Process_Unit__c pp=new Process_Unit__c();
pp.name='test';
pp.Aggregation_Group__c=UOP.id;
insert pp;


Royalty_Payment_History__c UPay=new Royalty_Payment_History__c();
UPay.Payment_History_Event__c='Report';   
 UPay.Process_Unit__c=pp.id;     
 UPay.UOP_Year__c='2000';      
 insert Upay;

 
 List<Royalty_Payment_History__c> UPay1=new List<Royalty_Payment_History__c>();
 
 Royalty_Payment_History__c uu=new Royalty_Payment_History__c(Payment_History_Event__c=Upay.Payment_History_Event__c,Process_Unit__c=pp.id,UOP_Year__c=Upay.UOP_Year__c);
 UPay1.add(uu);
 
 
 insert Upay1;
 
}

}

 

Thank you

:

 

Hi..

 

I have an object named as 'Periods', I want some of my specific users to edit the records which are already been created by the Administrator, where as New Records can only be created by the Administrator. I don't know how to achieve this, I guess its simple but actually I am new to Salesforce so don't know much of the option.

 

Please help!

Thanks,

 

Meer

  • March 06, 2012
  • Like
  • 0

Hi,

how to use <div style="page-break-after:auto;"> in the below code i  tried  but not worked

issue is when the page is going to second page it will displaing on the header please any one give some solution to

<apex:page controller="LetterController" sidebar="false" showheader="false" renderAs="PDF">
<html>
<head>
<style type="text/css">
            @page {          
                @top-center {                   
                    content: element(header);               
                            }
                @bottom-left {
                    content: element(footer);
                            }           
                 }                       
         
            div.header { 
                padding: -5px;              
                position: running(header);           
                        }           
            
            div.footer {
                padding:-5px;
                position: running(footer);                                   
                        }

        </style>
<style type="text/css">
    @page { 
        size: A4 landscape;

        }
    }
 </style>
<style type="text/css">
table
{

border-collapse:collapse;
}
table, td, th
{

border:1px solid black;
}

</style>
</head>
<body>
<form>
    <div class="header">   
                <img style="WIDTH:130px; HEIGHT: 80px" src='{!URLFOR($Resource.UOP)}' title="logo" align="right"/>
				
            </div>

            <div class="footer" align="center"> 
                <hr/>
                    <apex:outputText value="UOP Confidential" style="font-style:Arial;font-size:15pt;color :#000000" />
            </div>
                
				  <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
				    <br/>
			
<table cellspacing="5" cellpadding="5">
	<div style="page-break-after:auto;">	
<tr>
<td ><b>name</b></td>
<td ><b>class</b></td>
<td><b>year</b></td>
<td><b>lname </b></td>

</tr>

<apex:repeat value="{!PUList}" var="p" >
<apex:repeat value="{!p.Payment_Throughput_Histroy__r}" var="pt">
<tr>
<td>

{!p.name}
</td>

<td>
{!pt.class}
</td>
<td>
{!pt.year}
</td>
<td>
{!pt.lname}
</td>
</tr>
</apex:repeat>
</apex:repeat>
</div>
</table>


</form>
</body>
</html>
</apex:page>

 Thanks,

 

how can i do this

Hi,

Please help me on this URL overriding

{!IF(ISPICKVAL(Opportunity.Forecast_Type__c,"Ship Date Specific"),
'/{!Opportunity.Id}/e?clone=1&retURL=%2F{!Opportunity.Id}&00N80000004eYzp={!Opportunity.Id}&00N80000004eZ0S=false&00N80000004eZ0u= &opp9={!TODAY()}',
'/{!Opportunity.Id}/e?clone=1&retURL=%2F{!Opportunity.Id}&00N80000004eYzp={!Opportunity.Id}&00N80000004eZ0S=false')}

 trying to clone the opportunity depending on the pick list value, using custome button

it saved but when i click the button it show URL No Longal EXISTS,

 

Thanks

Hi ,

I have a VisualForce page that allows you to enter text in fields and then display them in a formatted PDF page by clicking a preview button. This is done by using a second VisualForce page to display the rendered PDF. I want the rendered PDF page to appear in a separate windows page.

First VF Page - Enter PDF Text

                <apex:commandButton id="previewButton" action="{!previewPDF}" value="Preview"/>

the action !previewPDF is then called in an apex class

Apex Class

The class contains processing to calculate and format fields on the final rendered page and finally
creates a new page reference

  public pagereference previewPDF () {
        // Direct to the PDF page
        PageReference pageRef = new PageReference('/apex/vfNCDLetterBF?id=' + Policy__c.Id);      
        return pageRef;
  }

Second VF Page - Render PDF Text

This VF page should then render the text as a PDF in a separate window but it appears in the original window which forces the user to use the back button to return to the first VF Page.

I have tried adding the onClick.Window javascript to the first VF page but this does not work.
I have found similiar answers to this question but they dont work with my pages and classes
I have already tried this solution which did not work for me as a need to call the apex class before I

execute the onclick command.

 

http://boards.developerforce.com/t5/Visualforce-Development/opening-a-new-window-from-apex-code/m-p/241731/highlight/true#M31916

 

Any insights or help would be appreciated

Many Thanks
Brian



 
Authorization Required 

You must first log in or register before accessing this page. 
If you have forgotten your password, click Forgot Password to reset it. 

   
Powered by

 

Hi,

I have a static method as given below im tryong to writte a test class for this it shows error

please any one give some idea to solve this problem

 

public class controller
{
public static SPQ__c product { get; set; }
public String productname { get; set; }   
@RemoteAction
    global static SPQ__c getSPQPr(String productname) {
        product = [select id ,Standard_Cost__c, name from SPQ__c where name= :productname and Year__c='Mid Year 2011' limit 1];  
        return product;
    }  


@RemoteAction
    global static Test__c getType() {
        AccType = [select Accessory_Type__c , name from Test__c where id= :'a2mQ0000001MpvE' limit 1];
        return AccType;
    }  
    }

 Thanks,

Hi 
I have a page url like
when we click on this link it should open as a public link where, the user can insert the data into the system.
How can i do this, link as a public usage without login credentials???
thanks in advance
  • January 25, 2012
  • Like
  • 0

Hi All

 

I have the following code and i am not able to test IF Condition in my code.

 

Here is my class and test class so far

global class updateOpportunityStage implements Database.Batchable<sObject>,Schedulable{
global string query ;

global updateOpportunityStage(){

Query = 'Select Id,BigMachines__Status__c,BigMachines__Is_Primary__c,BigMachines__Opportunity__c    from BigMachines__Quote__c where BigMachines__Is_Primary__c = true and BigMachines__Status__c like \'%unison%\' ';

}

global database.querylocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);    
}
    global void execute(SchedulableContext SC){
        integer bSize;
        integer Interval;
        try{
            Apex_Jobs_Settings__c aJob = [select id, name, batch_size__c, Run_Schedule_Interval__c, Isactive__c from Apex_Jobs_Settings__c where name = 'ContactsMerge' limit 1];
            if( aJob.IsActive__c = true){
                bSize = integer.valueOf(aJob.Batch_Size__c);
                Interval = integer.valueOf(aJob.Run_Schedule_Interval__c);
            }  
            else{
      
      
            }
        }
        catch(Exception ex){
        system.debug('ERROR: '+ ex);
        bSize=150;
        interval = 30;
    }    
        updateOpportunityStage stg = new updateOpportunityStage();
        DateTime todayMin = Datetime.now();
        DateTime today = todayMin.addMinutes(Interval);
        
        String seconds = '0';
        Integer minutes = today.minute();
        Integer hours = today.hour(); 
        Integer dayOfMonth = today.day(); 
        Integer month = today.month(); 
        Integer milisec = today.millisecond();
        String dayOfWeek = '?'; 
        Integer year = today.year(); 

        String sch = seconds + ' ' + minutes + ' ' + hours + ' ' + dayOfMonth + ' ' + month + ' ' + dayOfWeek + ' ' + year;
     
        String j = 'New Job:'+hours+':'+minutes+':'+seconds+':'+milisec;

        system.schedule(j, sch, stg);
       
        database.executebatch(stg, bSize);
        
     }

global void execute(Database.BatchableContext BC, List<sObject> scope){

     
    Set<id> liOppIds = new Set<id>();

for(sObject s : scope){

BigMachines__Quote__c quote = (BigMachines__Quote__c)s;
System.debug('Adil'+quote);
if(quote.BigMachines__Status__c.contains('Unison') && quote.BigMachines__Is_Primary__c == true)
liOppIds.add(quote.BigMachines__Opportunity__c);

}


//query all the opportunities in a single query
List<Opportunity> opp = new List<Opportunity>();
opp = [select id, StageName from Opportunity where id in :liOppIds and stagename != 'Closed Won' and  CloseDate >= Today];
for ( Opportunity opps : opp)
{
opps.StageName = 'Closed Won' ; 
}
//update all opportunities in a single DML
if(opp.size() > 0)
update opp;
 
    }
  global void finish(Database.BatchableContext BC){}  

}

 Test class is as follows

 

@isTest

Private class updateOpportunityStage_Test
{
static testMethod void Testclass(){

Opportunity Opp = new Opportunity(Name = 'Test',StageName = 'Closed Won',CloseDate= date.today());

insert opp;



BigMachines__Quote__c bmq = new BigMachines__Quote__c(BigMachines__Status__c = '%Unison%');

insert bmq;
  Apex_Jobs_Settings__c aJob = new   Apex_Jobs_Settings__c(Name ='test',batch_size__c=150,Run_Schedule_Interval__c=30,Isactive__c=true);

insert ajob;



  Test.startTest();  
// Schedule the job
            updateOpportunityStage stg = new updateOpportunityStage();

        
        ID batchprocessid = Database.executeBatch(stg,150);
              updateOpportunityStage stg1 = new updateOpportunityStage();
   String sch = '0 0 6 13 2 ?';        
     system.schedule('Schedule Test', sch, stg1);
 Test.stopTest();

}


}

 Thanks

Adil

Hi,

 

Any one please help me for displaying the static resource as footer image in visual force page(render as=pdf). I tried a lot but i am not getting. Thanks in advance.

 

 

Thanks,

Lakshmi.

Hi,

how to write test case for  below code

 

List<A__c> pay=new <A__c>();

pay=[select id,name,Year__c,Event__c from A__c where parent__c=:ppid];
  for(A__c rh:trigger.new)
   {
   for(A__c p:pay)
   {
   if(p.Year__c==rh.Year__c && p.Event__c==rh.Event__c)
   {
   Trigger.new[0].Year__c.addError(''+rh.Year__c+'Report is Created');
   }
   }
  }

 

Thaks..

hello

         i am new salesforce.i want to write test class for triggers and controller class.

         please help me to write test class

Hi,

 

How to avoid 'System.LimitException: Too many SOQL queries: 101'

 

if(Trigger.isUpdate || Trigger.isUpdate)
     {
     Double ReportOverage;
    Double diffOverage;
    Double AuditOverage;
    for(UOP_Royalty_Payment_History__c UOP:Trigger.new)
    {
        if(UOP.Payment_History_Event__c!='Report')
        {
            List<UOP_Royalty_Payment_History__c> UOPList=[select id,name,Payment_History_Event__c,Overage__c,Throughput__c,Previous_Fully_Paid_Capacity__c from UOP_Royalty_Payment_History__c where Payment_History_Event__c=:'Report' and Process_Unit__c=:UOP.Process_Unit__c and UOP_Year__c=:UOP.UOP_Year__c limit 1];
            if(UOPList.size()>0)
            {
                ReportOverage=UOPList[0].Overage__c;
            }
            if(ReportOverage==null) // || ReportOverage=='')
            {
               UOP.Invoice_Ammount_For_FA_DA__c=UOP.Invoice_Amount__c;                 // Trigger.new[0].UOP_Year__c.addError('There is no Report in '+UOP.UOP_Year__c+'');  
            }
            else
            {
                AuditOverage=UOP.Throughput__c - UOP.Previous_Fully_Paid_Capacity__c;
                diffOverage=AuditOverage - ReportOverage;
                if(diffOverage <= 0)
                {
                    UOP.Invoice_Ammount_For_FA_DA__c=0.0;
                }
                else
                {
                    UOP.Invoice_Ammount_For_FA_DA__c=diffOverage * UOP.Royalty_Rate__c * (UOP.Applicable_BLS11__c / UOP.BLS_Base__c);
                }
            }
        }
        }
     }

 thansk

Hi ,

 

Here i trying to create a wrapper class for multiple objects.But when i triedto save the class it is showing this error Unexpected token '{'

public class wrapperClassController
 {

        public List<wrapperClassController>wrapperClassList{get;set;}
        public List<Payment_Schedule__c> ps{get;set;} 
        public id oppId;
        public wrapperClassController (ApexPages.StandardController  controller)
        { 
           oppId = Apexpages.CurrentPage().getParameters().get('id');
         
        } 
        
         public List<wrapperClassController> getSR() {
         if(wrapperClassList == null) {
            wrapperClassList = new List<wrapperClassController>();
             for(Payment_Schedule__c  ps : [select Name,Display_Order__c,Tentative_Due_Date__c,Installment_Value_in__c,Balance__c,Installment_Basic_Value__c,VAT__c,Service_Tax__c,Deposits_Other_Charges__c,Total__c,Due_Date__c,Opportunity__r.Name,Payment_Received__c  from Payment_Schedule__c where Opportunity__c =: oppId Order By Display_Order__c]) {    
                       
              wrapperClassList.add(new wrapperClassController(ps));
             }
          }
         return wrapperClassList;
      }
   
      public PageReference processSelected() {
   
    List<Payment_Schedule__c> selectedPayment= new List<Payment_Schedule__c>();
 
          for(wrapperClassController cCon :getSR()) {
              if(cCon.selected == true) {
                 selectedPayment.add(cCon.con);
              }
          }
   
         System.debug('These are the selected paymentschedule..');
          for(Payment_Schedule__c  con : selectedPayment) {
              system.debug(con);
          }
          
          return null;
      
   
}
        public wrapperClassController
         {//showing error (Unexpected token)
          public Payment_Schedule__c con {get; set;}
          public Boolean selected {get; set;}

         public wrapperClassController(Payment_Schedule__c c)
            { 
            
            con = c;
            selected = false;
            }
    }
   
}

 

 Can anyone find soution for this

 

Thanks

Amrit

  • December 13, 2011
  • Like
  • 0

Hi All,

     i want to display the pick list in vf page.In that pick list i want to display the another custom object records.Its urgent.Any one can u please help me this.

 

Thanks in advance.

Hi All,

 

I have written a query where I want to update a field on opportunity if Opportunity Owner of any opportunity is changed. I have a field Previous_Owner__c on opportunity which stores the name of previous owner if owner is changed.

I am getting the below error:

"Apex trigger OpptyPreOwnAssn caused an unexpected exception, contact your administrator: OpptyPreOwnAssn: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 006P0000003XNGsIAO; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 006P0000003XNGs) is currently in trigger OpptyPreOwnAssn, therefore it cannot recursively update itself".

 

 

trigger OpptyPreOwnAssn on Opportunity ( before update) {

     List <Opportunity> listOppty= [Select Id,OwnerID, Previous_Owner__c from Opportunity where Id In:Trigger.New];

    Set<ID> Owner1id = new Set<ID>();

   

    List<Opportunity> opp2= new List<opportunity>();      

       

     for(Opportunity opp1 : listOppty){                 

       Owner1id.add(opp1.OwnerId);   }  

 

     List< User > listusr = [Select Id,Name from User where ID in : Owner1id];         

 

  

for (ID id1:Owner1ID){     

 for (Opportunity opp:listOppty){                

   for (User usr:listusr){           

      if(opp.ownerid==usr.id){

                             opp.Previous_Owner__c=usr.Name;              

                             opp2.add(opp);                            

                     }}  }   }              

                 update opp2;              

  }

 

 

 

I am not able to figure out why I am getting the  error. Can anybody please suggest the remedy for the above.

 

Thanks

~Alok

Can someone please help me wtih this error message on the following Custom Controller:

 

 

Save error: Uknown property 'ProductsController.opp'

 

Here is the custom controller:

 

public class ProductsController {

public List <Opportunity>getProducts(){

List <Opportunity> opp;

opp = [Select Name from Opportunity];

return opp;

}
}

 

 

 

Here is the Visualforce page:

<apex:page controller="ProductsController">

<apex:form >
<apex:dataTable value = "{!opp}" var="prod">
</apex:dataTable>
</apex:form>


</apex:page>

 

 

I am not sure why it is telling me that the opp variable used in the List of my custom controller is an unknown property.

 

Error Message: Save error: Unknown property: 'ProductsController.opp'

Hi,

Please help me from this issue,

i need to display the error message on field when the list is empty

 

Trigger code

trigger InvoiceAmountCal on UOP_Royalty_Payment_History__c (Before insert,Before Update) 
{
Double ReportOverage;
Double diffOverage;
Double AuditOverage;
for(UOP_Royalty_Payment_History__c UOP:Trigger.new)
{
if(UOP.Payment_History_Event__c!='Report')
{
UOP_Royalty_Payment_History__c UOPList=[select id,name,Payment_History_Event__c,Overage__c,Throughput__c,Previous_Fully_Paid_Capacity__c from UOP_Royalty_Payment_History__c where Payment_History_Event__c=:'Report' and Process_Unit__c=:UOP.Process_Unit__c and UOP_Year__c=:UOP.UOP_Year__c];
ReportOverage=UOPList.Overage__c;
if(ReportOverage==null)
{
Trigger.new[0].UOP_Year__c.addError('There is no Report in '+UOP.UOP_Year__c+'');  
}
else
{
AuditOverage=UOP.Throughput__c - UOP.Previous_Fully_Paid_Capacity__c;
diffOverage=AuditOverage - ReportOverage;
if(diffOverage <= 0)
{
UOP.Invoice_Ammount_For_FA_DA__c=0.0;
}
else
{
UOP.Invoice_Ammount_For_FA_DA__c=diffOverage * UOP.Royalty_Rate__c * (UOP.Applicable_BLS__c / UOP.BLS_Base__c);
}
}
}
}
}

 in above trigger if  ReportOverage==null or the UOPList==null then it should display error

but when im save the record trigger displaing error list has no rows for assissgment to Sobject

 

 

HI,

Please any one, help me to solve this issue

 

"System.LimitException: Too many script statements: 200001  'Extarnal entry point" in test class

this error is occure when im going to run the test class

 

Controller:

public class paymentinvoicepdf
{
public paymentinvoicepdf(ApexPages.StandardController controller)
{
}
Public List<UOP_Aggregation_Group__c> agroup{get;set;}
public String contname{get;set;}
public String title{get;set;}
public String Email{get;set;}
public String Telephone{get;set;}
public Boolean flag{get;set;} //{get;set;}
public Royalty_Contacts__c rc{get;set;}
public List<Royalty_Contacts__c> rc1{get;set;}
public List<Royalty_Contacts__c> rc2{get;set;}

public PageReference royalcon()
{
Id id=Apexpages.currentpage().getparameters().get('id');
UOP_Royalty_Payment_History__c urp=[select id,name,Process_Unit__r.Account__r.UOP_CA_S_Account_Manager__c,Payment_History_Event__c,Invoice_Number__c,Invoice_Date__c from UOP_Royalty_Payment_History__c where id=:id];
id urpid=urp.Process_Unit__c;
 rc1=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Primary)'];
 if(rc1.size()>0)
 {
 flag=true;
 }
 
 rc2=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Secondary)' and Royalty_Role__c=:'Royalty (Primary)' ];
 if(rc2.size()>0)
 {
 flag=false;
 }
 /*for(Royalty_Contacts__c r:rc1)
 {
 if(r.Royalty_Role__c=='Royalty (Primary)')
 {
 flag=true;
 contname=r.Contact__r.name;
 title=r.Title__c;
 Email=r.Email__c;
 Telephone=r.Phone__c;
 //rc=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urpid and Royalty_Role__c=:'Royalty (Primary)'];
 }
 else if(r.Royalty_Role__c=='Royalty (Secondary)')
 {
 flag=false;
 }
 
 }*/



 Process_Unit__c pu=[select id,name,Aggregation_Group__c from Process_Unit__c where id=:urpid];
 id aid=pu.Aggregation_Group__c;
 
 agroup=[select id,name,(select id,name,Aggregation_Group__c,Unique_Process_Unit_Identifier__c from Process_Units__r) from UOP_Aggregation_Group__c where id=:aid];
 
return null;
}

}

 

test class:

@istest()
public class paymentinvoicepdftest
{
public static testmethod void test()
{
UOP_Royalty_Payment_History__c uopCreat=new UOP_Royalty_Payment_History__c(Payment_History_Event__c='Report');
ApexPages.StandardController accCtrl = new ApexPages.Standardcontroller(uopCreat);


paymentinvoicepdf pay=new paymentinvoicepdf(accCtrl );
Account ac=new Account(name='test');
//ac.SAP_Customer_Info__c=s.id;
insert ac;
Process_Unit__c pu=new Process_Unit__c(name='testAccount',Account__c=ac.id,Status__c='Licensed',Technology_Supplier__c='ABB Lummus',
Units_Fully_Paid_Capacity__c='Accounting Units',Agreement_Status__c='Fully Executed',License_Type__c='Unit',Subject_To_Audit__c='yes',
Current_Royalty_Type__c='Fully Paid',UOM_Capacity__c='BPSD');
insert pu;
UOP_Royalty_Payment_History__c uop=new UOP_Royalty_Payment_History__c(Payment_History_Event__c='Report',Process_Unit__c=pu.id,
Royalty_Rate__c=0.50,Applicable_BLS__c=10,BLS_Base__c=100,UOP_Year__c='2001',Overage__c=11000);
insert uop;
    ApexPages.currentPage().getParameters().put('id',uop.id);

UOP_Royalty_Payment_History__c urp=[select id,name,Process_Unit__r.Account__r.UOP_CA_S_Account_Manager__c,Payment_History_Event__c,Invoice_Number__c,Invoice_Date__c from UOP_Royalty_Payment_History__c limit 1];
List<Royalty_Contacts__c> rc1=[select id,name,contact__r.name,Royalty_Role__c,Title__c,Phone__c,Email__c  from Royalty_Contacts__c where Process_unit__r.id=:urp.id and Royalty_Role__c=:'Royalty (Primary)']; 
 Process_Unit__c pu1=[select id,name,Aggregation_Group__c from Process_Unit__c where id=:pu.id limit 1];
 UOP_Aggregation_Group__c a=new UOP_Aggregation_Group__c(name='test');
 insert a;
 
 List<UOP_Aggregation_Group__c> agroup=[select id,name,(select id,name,Aggregation_Group__c,Unique_Process_Unit_Identifier__c from Process_Units__r) from UOP_Aggregation_Group__c where id=:a.id];
 
pay.royalcon();
}
}

 Give me some suggestions how to solve this issue

 

Thanks,

Vishwa A