-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
12Questions
-
6Replies
Hi I have a doubt on export to excell in visualforce can any one suggest me doing this..
Hi i have written a code in visual force page but to that code i want to add "Export" button and when we click "export" button then the pageblockTable content should be converted into excell sheet. that means i have to take "pageblocktable" as reference for export button i am trying it but unfortunatly it is not coming can any one sugest me please..
can any one help me with the sample example please
thanks in advance
can any one help me with the sample example please
thanks in advance
- rajesh kumar 10
- September 01, 2014
- Like
- 0
Hi i was getting a problem in a visualforce page pdf and controller can any try to help me pls..
Hi i was getting problem with pdf that in visual force page that my "description " field is out of bouce that means i want to break the string i can not able to do that..
when i enter more words in the description field then the half table is only coming in pdf file so can any one find my problem please..
her i am giving my controller and visual foce codes:
controller :
public class QuotePDFAustria{
Public Quote qut{get;set;}
Public List<QuoteLineItem> QuLiIt{get;set;}
Public Date dat{get;set;}
Public QuotePDFAustria(ApexPages.StandardController controller){
qut = [SELECT id,name,Payment_Terms__c,Notes__c,Customer__r.name,Customer__r.City__c,Customer__r.State__c,Customer__r.Postal_Code__c,Customer__r.Country__c,GrandTotal,Quote_Address_To__r.name,Quote_Address_To__r.Salutation,Quote_Address_To__r.LastName,Quote_Address_To__r.email,Quote_Address_To__r.Phone,Opportunity.Primary_Inside_Sales__r.name,Primary_Inside_Sales__r.name,Primary_Inside_Sales_Email__c,Quote_Date__c,opportunity.Primary_Outside_Sales__r.name,opportunity.Primary_Outside_Sales__r.Phone,opportunity.Primary_Outside_Sales__r.Email,opportunity.Primary_Outside_Sales__r.fax,opportunity.Primary_Outside_Sales__r.Title,Inside_Sales_Fax__c,Inside_Sales_Phone__c,Inside_Sales_Title__c FROM Quote WHERE id =: ApexPages.CurrentPage().getParameters().get('id')];
QuLiIt = [SELECT id,LineNumber,Quantity,Item_Number__c,Asset__r.Model__c,Part_Description__c,UnitPrice,Asset__r.SerialNumber FROM QuoteLineItem WHERE QuoteId =: qut.id];
if(qut.Quote_Date__c != null)
dat = qut.Quote_Date__c + 30;
}
}
VisualForce :
<apex:page standardController="Quote" extensions="QuotePDFAustria" renderAs="pdf">
<head>
<style type="text/css">
@PageBreak{
page-break:always;
page-break-inside:avoid;
}
@media print{
table {page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
}
@page {
margin-top: 20%; margin-bottom: 110px;
margin-left:50px; margin-right:50px;
@top-center {
content: element(header);
}
@bottom-left {
content: element(footer);
height: 500px;
}
}
div.footer {
position: running(footer);
}
div.header {
margin:0 50px 0 0;
position: running(header);
}
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:15px;
color:#000;
border-width: 1px;
border-color: #000;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
</style>
</head>
<div class="header" align="center" >
<div><apex:image height="110px" width="230pk" value="{!$Resource.CC_IMI}"/></div>
</div>
<apex:form >
<!-- This Section is for PAGE 1-->
<table class="gridtable" width="100%">
<tr>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Customer :"/></u>
<p><b>{!qut.Customer__r.name}</b><br/>
{!qut.Customer__r.City__c}<br/>
{!qut.Customer__r.State__c} {!qut.Customer__r.Postal_Code__c}<br/>
<b>{!qut.Customer__r.Country__c}</b>
</p>
</td>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Supplier :"/></u>
<p><b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
<b>Austria</b>
</p>
</td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="To :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.name}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="From :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Opportunity.Primary_Inside_Sales__r.name}</td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Email :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.email}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Pages :"/></td>
<td style="padding-top:10px;padding-bottom:10px"></td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Phone :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.phone}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Date :"/></td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,date,dd'/'MM'/'yyyy}"><apex:param value="{!qut.Quote_Date__c}"/></apex:outputText></td>
</tr>
<tr align="center">
<td width="12%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Add Data :"/></td>
<td width="38%" style="padding-top:10px;padding-bottom:10px"></td>
<td width="12%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Cc :"/></td>
<td width="38%" style="padding-top:10px;padding-bottom:10px">{!qut.opportunity.Primary_Outside_Sales__r.name}</td>
</tr>
</table><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;">
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="QUOTATION No.:"/></th>
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qut.name}"/></th>
</tr>
</table><br/><br/>
Dear {!qut.Quote_Address_To__r.Salutation} {!qut.Quote_Address_To__r.LastName},<br/><br/>
We thank you for your inquiry and offer in accordance with the previous order ............... with the negotiated
purchase and warranty conditions as follows.<br/><br/><br/>
When ordering, we ask you to refer to the old order and confirm the validity if this purchasing and
warranty conditions.<br/><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px">Pos.</td>
<td width="5%" style="padding-top:10px;padding-bottom:10px">Q</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Article No.</td>
<td width="40%" style="padding-top:10px;padding-bottom:10px">Description</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pc</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/Pos</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">SL No.</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Valve Type</td>
</tr>
<apex:repeat value="{!QuLiIt}" var="qli">
<tr style="page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Item_Number__c}"/></td>
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Quantity}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.LineNumber}"/></td>
<td width="40%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Part_Description__c}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.UnitPrice}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qli.UnitPrice * qli.Quantity}"/></apex:outputText></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.SerialNumber}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.Model__c}"/></td>
</tr>
</apex:repeat>
<tr style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%"></td>
<td width="5%"></td>
<td width="10%"></td>
<td width="40%" style="text-align:right;padding-top:10px;padding-bottom:10px"><b>TOTAL</b></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pos.</td>
<td width="10%"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qut.GrandTotal}"/></apex:outputText></td>
<td width="10%"></td>
<td width="10%"></td>
</tr>
</table>
<br/><br/><br/>
We look forward to your early acceptance.<br/><br/>
Yours sincerely,<br/><br/>
<b>CCI Valve Technology GmbH<br/><br/><br/><br/><br/>
{!qut.Opportunity.Primary_Inside_Sales__r.name}</b>
</apex:form>
</apex:page>
when i enter more words in the description field then the half table is only coming in pdf file so can any one find my problem please..
her i am giving my controller and visual foce codes:
controller :
public class QuotePDFAustria{
Public Quote qut{get;set;}
Public List<QuoteLineItem> QuLiIt{get;set;}
Public Date dat{get;set;}
Public QuotePDFAustria(ApexPages.StandardController controller){
qut = [SELECT id,name,Payment_Terms__c,Notes__c,Customer__r.name,Customer__r.City__c,Customer__r.State__c,Customer__r.Postal_Code__c,Customer__r.Country__c,GrandTotal,Quote_Address_To__r.name,Quote_Address_To__r.Salutation,Quote_Address_To__r.LastName,Quote_Address_To__r.email,Quote_Address_To__r.Phone,Opportunity.Primary_Inside_Sales__r.name,Primary_Inside_Sales__r.name,Primary_Inside_Sales_Email__c,Quote_Date__c,opportunity.Primary_Outside_Sales__r.name,opportunity.Primary_Outside_Sales__r.Phone,opportunity.Primary_Outside_Sales__r.Email,opportunity.Primary_Outside_Sales__r.fax,opportunity.Primary_Outside_Sales__r.Title,Inside_Sales_Fax__c,Inside_Sales_Phone__c,Inside_Sales_Title__c FROM Quote WHERE id =: ApexPages.CurrentPage().getParameters().get('id')];
QuLiIt = [SELECT id,LineNumber,Quantity,Item_Number__c,Asset__r.Model__c,Part_Description__c,UnitPrice,Asset__r.SerialNumber FROM QuoteLineItem WHERE QuoteId =: qut.id];
if(qut.Quote_Date__c != null)
dat = qut.Quote_Date__c + 30;
}
}
VisualForce :
<apex:page standardController="Quote" extensions="QuotePDFAustria" renderAs="pdf">
<head>
<style type="text/css">
@PageBreak{
page-break:always;
page-break-inside:avoid;
}
@media print{
table {page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
}
@page {
margin-top: 20%; margin-bottom: 110px;
margin-left:50px; margin-right:50px;
@top-center {
content: element(header);
}
@bottom-left {
content: element(footer);
height: 500px;
}
}
div.footer {
position: running(footer);
}
div.header {
margin:0 50px 0 0;
position: running(header);
}
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:15px;
color:#000;
border-width: 1px;
border-color: #000;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
</style>
</head>
<div class="header" align="center" >
<div><apex:image height="110px" width="230pk" value="{!$Resource.CC_IMI}"/></div>
</div>
<apex:form >
<!-- This Section is for PAGE 1-->
<table class="gridtable" width="100%">
<tr>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Customer :"/></u>
<p><b>{!qut.Customer__r.name}</b><br/>
{!qut.Customer__r.City__c}<br/>
{!qut.Customer__r.State__c} {!qut.Customer__r.Postal_Code__c}<br/>
<b>{!qut.Customer__r.Country__c}</b>
</p>
</td>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Supplier :"/></u>
<p><b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
<b>Austria</b>
</p>
</td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="To :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.name}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="From :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Opportunity.Primary_Inside_Sales__r.name}</td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Email :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.email}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Pages :"/></td>
<td style="padding-top:10px;padding-bottom:10px"></td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Phone :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.phone}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Date :"/></td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,date,dd'/'MM'/'yyyy}"><apex:param value="{!qut.Quote_Date__c}"/></apex:outputText></td>
</tr>
<tr align="center">
<td width="12%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Add Data :"/></td>
<td width="38%" style="padding-top:10px;padding-bottom:10px"></td>
<td width="12%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Cc :"/></td>
<td width="38%" style="padding-top:10px;padding-bottom:10px">{!qut.opportunity.Primary_Outside_Sales__r.name}</td>
</tr>
</table><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;">
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="QUOTATION No.:"/></th>
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qut.name}"/></th>
</tr>
</table><br/><br/>
Dear {!qut.Quote_Address_To__r.Salutation} {!qut.Quote_Address_To__r.LastName},<br/><br/>
We thank you for your inquiry and offer in accordance with the previous order ............... with the negotiated
purchase and warranty conditions as follows.<br/><br/><br/>
When ordering, we ask you to refer to the old order and confirm the validity if this purchasing and
warranty conditions.<br/><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px">Pos.</td>
<td width="5%" style="padding-top:10px;padding-bottom:10px">Q</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Article No.</td>
<td width="40%" style="padding-top:10px;padding-bottom:10px">Description</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pc</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/Pos</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">SL No.</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Valve Type</td>
</tr>
<apex:repeat value="{!QuLiIt}" var="qli">
<tr style="page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Item_Number__c}"/></td>
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Quantity}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.LineNumber}"/></td>
<td width="40%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Part_Description__c}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.UnitPrice}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qli.UnitPrice * qli.Quantity}"/></apex:outputText></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.SerialNumber}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.Model__c}"/></td>
</tr>
</apex:repeat>
<tr style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%"></td>
<td width="5%"></td>
<td width="10%"></td>
<td width="40%" style="text-align:right;padding-top:10px;padding-bottom:10px"><b>TOTAL</b></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pos.</td>
<td width="10%"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qut.GrandTotal}"/></apex:outputText></td>
<td width="10%"></td>
<td width="10%"></td>
</tr>
</table>
<br/><br/><br/>
We look forward to your early acceptance.<br/><br/>
Yours sincerely,<br/><br/>
<b>CCI Valve Technology GmbH<br/><br/><br/><br/><br/>
{!qut.Opportunity.Primary_Inside_Sales__r.name}</b>
</apex:form>
</apex:page>
- rajesh kumar 10
- September 01, 2014
- Like
- 1
I have a doubt on controller string splitting ? can any help me pls!
I have a problem with string spliting that when i create a pdf the table is excceding because of 'description' so i want to split that 'description' string i am trying to do it but unable to fix it i am sending the contrlooer and visualforce code can any try to help me out...
MY controller:
public class QuotePDFAustria{
Public Quote qut{get;set;}
Public List<QuoteLineItem> QuLiIt{get;set;}
Public Date dat{get;set;}
Public QuotePDFAustria(ApexPages.StandardController controller){
qut = [SELECT id,name,Payment_Terms__c,Notes__c,Customer__r.name,Customer__r.City__c,Customer__r.State__c,Customer__r.Postal_Code__c,Customer__r.Country__c,GrandTotal,Quote_Address_To__r.name,Quote_Address_To__r.Salutation,Quote_Address_To__r.LastName,Quote_Address_To__r.email,Quote_Address_To__r.Phone,Opportunity.Primary_Inside_Sales__r.name,Primary_Inside_Sales__r.name,Primary_Inside_Sales_Email__c,Quote_Date__c,opportunity.Primary_Outside_Sales__r.name,opportunity.Primary_Outside_Sales__r.Phone,opportunity.Primary_Outside_Sales__r.Email,opportunity.Primary_Outside_Sales__r.fax,opportunity.Primary_Outside_Sales__r.Title,Inside_Sales_Fax__c,Inside_Sales_Phone__c,Inside_Sales_Title__c FROM Quote WHERE id =: ApexPages.CurrentPage().getParameters().get('id')];
QuLiIt = [SELECT id,LineNumber,Quantity,Item_Number__c,Asset__r.Model__c,Part_Description__c,UnitPrice,Asset__r.SerialNumber FROM QuoteLineItem WHERE QuoteId =: qut.id];
if(qut.Quote_Date__c != null)
dat = qut.Quote_Date__c + 30;
}
}
and my Visualforce page:
<apex:page standardController="Quote" extensions="QuotePDFAustria" renderAs="pdf">
<head>
<style type="text/css">
@PageBreak{
page-break:always;
page-break-inside:avoid;
}
@media print{
table {page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
}
@page {
margin-top: 20%; margin-bottom: 110px;
margin-left:50px; margin-right:50px;
@top-center {
content: element(header);
}
@bottom-left {
content: element(footer);
height: 500px;
}
}
div.footer {
position: running(footer);
}
div.header {
margin:0 50px 0 0;
position: running(header);
}
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:15px;
color:#000;
border-width: 1px;
border-color: #000;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
</style>
</head>
<div class="footer">
<table border="0" width="100%" height = "100%" cellspacing="0" cellpadding="0">
<tr>
<td width="70%" >
<b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
Austria
</td>
<td width="30%">
Tel.: +43-1-869 27 40<br/>
Fax : +43-1-865 36 03<br/>
<b>www.ccivalve.com</b><br/>
e-mail : cci@ccivalve.at
</td>
</tr>
</table>
</div>
<div class="header" align="center" >
<div><apex:image height="110px" width="230pk" value="{!$Resource.CC_IMI}"/></div>
</div>
<apex:form >
<!-- This Section is for PAGE 1-->
<table class="gridtable" width="100%">
<tr>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Customer :"/></u>
<p><b>{!qut.Customer__r.name}</b><br/>
{!qut.Customer__r.City__c}<br/>
{!qut.Customer__r.State__c} {!qut.Customer__r.Postal_Code__c}<br/>
<b>{!qut.Customer__r.Country__c}</b>
</p>
</td>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Supplier :"/></u>
<p><b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
<b>Austria</b>
</p>
</td>
</table><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;">
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="QUOTATION No.:"/></th>
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qut.name}"/></th>
</tr>
</table><br/><br/>
Dear {!qut.Quote_Address_To__r.Salutation} {!qut.Quote_Address_To__r.LastName},<br/><br/>
We thank you for your inquiry and offer in accordance with the previous order ............... with the negotiated
purchase and warranty conditions as follows.<br/><br/><br/>
When ordering, we ask you to refer to the old order and confirm the validity if this purchasing and
warranty conditions.<br/><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px">Pos.</td>
<td width="5%" style="padding-top:10px;padding-bottom:10px">Q</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Article No.</td>
<td width="40%" style="padding-top:10px;padding-bottom:10px">Description</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pc</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/Pos</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">SL No.</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Valve Type</td>
</tr>
<apex:repeat value="{!QuLiIt}" var="qli">
<tr style="page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Item_Number__c}"/></td>
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Quantity}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.LineNumber}"/></td>
<td width="40%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Part_Description__c}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.UnitPrice}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qli.UnitPrice * qli.Quantity}"/></apex:outputText></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.SerialNumber}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.Model__c}"/></td>
</tr>
</apex:repeat>
<tr style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%"></td>
<td width="5%"></td>
<td width="10%"></td>
<td width="40%" style="text-align:right;padding-top:10px;padding-bottom:10px"><b>TOTAL</b></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pos.</td>
<td width="10%"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qut.GrandTotal}"/></apex:outputText></td>
<td width="10%"></td>
<td width="10%"></td>
</tr>
</table>
</apex:form>
</apex:page>
MY controller:
public class QuotePDFAustria{
Public Quote qut{get;set;}
Public List<QuoteLineItem> QuLiIt{get;set;}
Public Date dat{get;set;}
Public QuotePDFAustria(ApexPages.StandardController controller){
qut = [SELECT id,name,Payment_Terms__c,Notes__c,Customer__r.name,Customer__r.City__c,Customer__r.State__c,Customer__r.Postal_Code__c,Customer__r.Country__c,GrandTotal,Quote_Address_To__r.name,Quote_Address_To__r.Salutation,Quote_Address_To__r.LastName,Quote_Address_To__r.email,Quote_Address_To__r.Phone,Opportunity.Primary_Inside_Sales__r.name,Primary_Inside_Sales__r.name,Primary_Inside_Sales_Email__c,Quote_Date__c,opportunity.Primary_Outside_Sales__r.name,opportunity.Primary_Outside_Sales__r.Phone,opportunity.Primary_Outside_Sales__r.Email,opportunity.Primary_Outside_Sales__r.fax,opportunity.Primary_Outside_Sales__r.Title,Inside_Sales_Fax__c,Inside_Sales_Phone__c,Inside_Sales_Title__c FROM Quote WHERE id =: ApexPages.CurrentPage().getParameters().get('id')];
QuLiIt = [SELECT id,LineNumber,Quantity,Item_Number__c,Asset__r.Model__c,Part_Description__c,UnitPrice,Asset__r.SerialNumber FROM QuoteLineItem WHERE QuoteId =: qut.id];
if(qut.Quote_Date__c != null)
dat = qut.Quote_Date__c + 30;
}
}
and my Visualforce page:
<apex:page standardController="Quote" extensions="QuotePDFAustria" renderAs="pdf">
<head>
<style type="text/css">
@PageBreak{
page-break:always;
page-break-inside:avoid;
}
@media print{
table {page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
}
@page {
margin-top: 20%; margin-bottom: 110px;
margin-left:50px; margin-right:50px;
@top-center {
content: element(header);
}
@bottom-left {
content: element(footer);
height: 500px;
}
}
div.footer {
position: running(footer);
}
div.header {
margin:0 50px 0 0;
position: running(header);
}
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:15px;
color:#000;
border-width: 1px;
border-color: #000;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
</style>
</head>
<div class="footer">
<table border="0" width="100%" height = "100%" cellspacing="0" cellpadding="0">
<tr>
<td width="70%" >
<b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
Austria
</td>
<td width="30%">
Tel.: +43-1-869 27 40<br/>
Fax : +43-1-865 36 03<br/>
<b>www.ccivalve.com</b><br/>
e-mail : cci@ccivalve.at
</td>
</tr>
</table>
</div>
<div class="header" align="center" >
<div><apex:image height="110px" width="230pk" value="{!$Resource.CC_IMI}"/></div>
</div>
<apex:form >
<!-- This Section is for PAGE 1-->
<table class="gridtable" width="100%">
<tr>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Customer :"/></u>
<p><b>{!qut.Customer__r.name}</b><br/>
{!qut.Customer__r.City__c}<br/>
{!qut.Customer__r.State__c} {!qut.Customer__r.Postal_Code__c}<br/>
<b>{!qut.Customer__r.Country__c}</b>
</p>
</td>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Supplier :"/></u>
<p><b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
<b>Austria</b>
</p>
</td>
</table><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;">
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="QUOTATION No.:"/></th>
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qut.name}"/></th>
</tr>
</table><br/><br/>
Dear {!qut.Quote_Address_To__r.Salutation} {!qut.Quote_Address_To__r.LastName},<br/><br/>
We thank you for your inquiry and offer in accordance with the previous order ............... with the negotiated
purchase and warranty conditions as follows.<br/><br/><br/>
When ordering, we ask you to refer to the old order and confirm the validity if this purchasing and
warranty conditions.<br/><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px">Pos.</td>
<td width="5%" style="padding-top:10px;padding-bottom:10px">Q</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Article No.</td>
<td width="40%" style="padding-top:10px;padding-bottom:10px">Description</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pc</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/Pos</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">SL No.</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Valve Type</td>
</tr>
<apex:repeat value="{!QuLiIt}" var="qli">
<tr style="page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Item_Number__c}"/></td>
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Quantity}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.LineNumber}"/></td>
<td width="40%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Part_Description__c}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.UnitPrice}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qli.UnitPrice * qli.Quantity}"/></apex:outputText></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.SerialNumber}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.Model__c}"/></td>
</tr>
</apex:repeat>
<tr style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%"></td>
<td width="5%"></td>
<td width="10%"></td>
<td width="40%" style="text-align:right;padding-top:10px;padding-bottom:10px"><b>TOTAL</b></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pos.</td>
<td width="10%"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qut.GrandTotal}"/></apex:outputText></td>
<td width="10%"></td>
<td width="10%"></td>
</tr>
</table>
</apex:form>
</apex:page>
- rajesh kumar 10
- August 28, 2014
- Like
- 0
I Have a problem with my Test class with my trigger? can any one solve this?
Here is my Trigger
trigger accountApprovalSubmit on Account (after insert) {
for (Account a : trigger.new) {
if (a.RecordType_Name__c == 'Plant' && !a.BlockTrigger__c && (a.Plant_Type__c == 'New Plant' || a.Plant_Type__c == 'Normal Plant'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
else {
if (a.RecordType_Name__c == 'Plant' && (a.Plant_Business_Type__c == 'New construction')
&& (a.plant_Type__c == 'potential plant')
&& (a.status__c!='active') && (a.super_region__c=='EAME')
&& (a.account_industry_type__c =='Power - Fossil'||a.account_industry_type__c =='O & G'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
}
}
}
and Below is my Test class
@isTest
public class TestAccountApprovalSubmit{
public static testmethod void accountApprovalSubmit(){
RecordType rdObj = [Select Id from RecordType where Name = 'Plant' and SobjectType ='Account'];
account a=new account();
a.Name='Sample';
a.RecordTypeId = rdObj.Id;
a.Plant_Business_Type__c = 'New construction';
a.plant_Type__c = 'potential plant';
a.status__c = 'inactive';
a.super_region__c = 'EAME';
a.account_industry_type__c='Power - Fossil';
a.Country__c = 'INDIA';
a.State__c = 'GOA';
a.Address__c = 'USA';
a.City__c = 'USA';
a.Postal_Code__c = 'USA';
Test.startTest();
insert a;
Test.stopTest();
}
}
The code is covering only 66%
so can any one please suggest me for better code coverage..
thanks in advance
trigger accountApprovalSubmit on Account (after insert) {
for (Account a : trigger.new) {
if (a.RecordType_Name__c == 'Plant' && !a.BlockTrigger__c && (a.Plant_Type__c == 'New Plant' || a.Plant_Type__c == 'Normal Plant'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
else {
if (a.RecordType_Name__c == 'Plant' && (a.Plant_Business_Type__c == 'New construction')
&& (a.plant_Type__c == 'potential plant')
&& (a.status__c!='active') && (a.super_region__c=='EAME')
&& (a.account_industry_type__c =='Power - Fossil'||a.account_industry_type__c =='O & G'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
}
}
}
and Below is my Test class
@isTest
public class TestAccountApprovalSubmit{
public static testmethod void accountApprovalSubmit(){
RecordType rdObj = [Select Id from RecordType where Name = 'Plant' and SobjectType ='Account'];
account a=new account();
a.Name='Sample';
a.RecordTypeId = rdObj.Id;
a.Plant_Business_Type__c = 'New construction';
a.plant_Type__c = 'potential plant';
a.status__c = 'inactive';
a.super_region__c = 'EAME';
a.account_industry_type__c='Power - Fossil';
a.Country__c = 'INDIA';
a.State__c = 'GOA';
a.Address__c = 'USA';
a.City__c = 'USA';
a.Postal_Code__c = 'USA';
Test.startTest();
insert a;
Test.stopTest();
}
}
The code is covering only 66%
so can any one please suggest me for better code coverage..
thanks in advance
- rajesh kumar 10
- August 25, 2014
- Like
- 0
Problem on trigger can any see my problem
I have a doubt on trigger that i created a trigger on Primary application allocation object which is related to opportunity and when i create records in primary application allocation object then in opportunity object the "Primary Application Allocation Set" field should be checked and when i delete all the records in primary application allocation object which are are related to same opportunity record then that field should be false. but my trigger is creating a problem that when i am creating records then that field is comnig true but when i delete atleast one record then it is becoming false but i dont want like that when i delete all records in primaary application alocation which are related to that opportunity then only the field should be false..
Below is my trigger please go through it and suggest me please..
trigger UpdatePrimaryApllicationAllocationSet on Primary_Application_Allocation__c (after insert,after delete) {
list<id> lst = new list<id>();
if(trigger.isInsert){
for(Primary_Application_Allocation__c paa : trigger.new) {
lst.add(paa.opportunity__c);
}}
if(trigger.isDelete){
for(Primary_Application_Allocation__c paa : trigger.old) {
lst.add(paa.opportunity__c);
}
}
list<Opportunity> opplst = new list<Opportunity>();
opplst=[SELECT Primary_Application_Allocation_Set__c FROM Opportunity where Id in :lst];
if(trigger.isInsert) {
for(Primary_Application_Allocation__c paa : trigger.new) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.Id) {
o.Primary_Application_Allocation_Set__c = true;
}
}
}
update opplst;
}
if(trigger.isDelete) {
for(Primary_Application_Allocation__c paa : trigger.old) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.id) {
o.Primary_Application_Allocation_Set__c = False;
}
}
}
update opplst;
}
}
thanks in advance
Below is my trigger please go through it and suggest me please..
trigger UpdatePrimaryApllicationAllocationSet on Primary_Application_Allocation__c (after insert,after delete) {
list<id> lst = new list<id>();
if(trigger.isInsert){
for(Primary_Application_Allocation__c paa : trigger.new) {
lst.add(paa.opportunity__c);
}}
if(trigger.isDelete){
for(Primary_Application_Allocation__c paa : trigger.old) {
lst.add(paa.opportunity__c);
}
}
list<Opportunity> opplst = new list<Opportunity>();
opplst=[SELECT Primary_Application_Allocation_Set__c FROM Opportunity where Id in :lst];
if(trigger.isInsert) {
for(Primary_Application_Allocation__c paa : trigger.new) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.Id) {
o.Primary_Application_Allocation_Set__c = true;
}
}
}
update opplst;
}
if(trigger.isDelete) {
for(Primary_Application_Allocation__c paa : trigger.old) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.id) {
o.Primary_Application_Allocation_Set__c = False;
}
}
}
update opplst;
}
}
thanks in advance
- rajesh kumar 10
- August 21, 2014
- Like
- 0
I have facing a problem with the Test class for my trigger can any one please solve my problem below i am providing my trigger and test calss and error i was facing..
My Trigger is:
trigger UpdatePrimaryApllicationAllocationSet on Primary_Application_Allocation__c (after insert,after delete) {
list<id> lst = new list<id>();
if(trigger.isInsert){
for(Primary_Application_Allocation__c paa : trigger.new) {
lst.add(paa.opportunity__c);
}}
if(trigger.isDelete){
for(Primary_Application_Allocation__c paa : trigger.old) {
lst.add(paa.opportunity__c);
}
}
list<Opportunity> opplst = new list<Opportunity>();
opplst=[SELECT Primary_Application_Allocation_Set__c FROM Opportunity where Id in :lst];
if(trigger.isInsert) {
for(Primary_Application_Allocation__c paa : trigger.new) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.Id) {
o.Primary_Application_Allocation_Set__c = true;
}
}
}
update opplst;
}
if(trigger.isDelete) {
for(Primary_Application_Allocation__c paa : trigger.old) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.id) {
o.Primary_Application_Allocation_Set__c = False;
}
}
}
update opplst;
}
}
and my
Test calss is:
@isTest
public class TestUpdatePrimaryApllicationAllocation {
RecordType rt = [select id,name from RecordType where name='Owner' and SobjectType='Account' limit 1];
RecordType rt1 = [select id,name from RecordType where name='NC Power' and SobjectType='Opportunity' limit 1];
static testMethod void insertPrimaryApllicationAllocationSet() {
Account acc = new Account(name = 'Test Account',country__c = 'Bangladesh');
insert acc;
Opportunity opp = new Opportunity(Name = 'Test Opp',stageName ='Sales Lead',CloseDate = Date.Today(),
ForecastCategoryName = 'Pipeline',CurrencyIsoCode = 'USD - U.S. Dollar');
insert opp;
Primary_Application_Allocation__c paa = new Primary_Application_Allocation__c( Opportunity__c = opp.id);
Test.startTest();
insert paa;
Test.stopTest();
Opportunity updatedOpp = [Select Id, Primary_Application_Allocation_Set__c from Opportunity where id =: opp.id];
System.assert(updatedOpp.Primary_Application_Allocation_Set__c);
}
static testMethod void deletePrimaryApllicationAllocationSet(){
Account acc = new Account(name = 'Test Account');
insert acc;
Opportunity opp = new Opportunity(Name = 'Test Opp', Amount = 10020);
insert opp;
Primary_Application_Allocation__c paa = new Primary_Application_Allocation__c( Opportunity__c = opp.id);
insert paa;
Test.startTest();
delete paa;
Test.stoptest();
Opportunity updatedOpp = [Select Id, Primary_Application_Allocation_Set__c from Opportunity where id =: opp.id];
System.assert(!updatedOpp.Primary_Application_Allocation_Set__c);
}
}
and i was facing the errors as:
Error Message : System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Opportunity Currency: invalid currency code: USD - U.S. Dollar: [CurrencyIsoCode]
Stack Trace Class : TestUpdatePrimaryApllicationAllocation.insertPrimaryApllicationAllocationSet: line 13, column 1
Error Message : System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AssignAccountTerritorytoOpportunity: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.AssignAccountTerritorytoOpportunity: line 2, column 1: []
Stack Trace : Class.TestUpdatePrimaryApllicationAllocation.deletePrimaryApllicationAllocationSet: line 27, column 1
trigger UpdatePrimaryApllicationAllocationSet on Primary_Application_Allocation__c (after insert,after delete) {
list<id> lst = new list<id>();
if(trigger.isInsert){
for(Primary_Application_Allocation__c paa : trigger.new) {
lst.add(paa.opportunity__c);
}}
if(trigger.isDelete){
for(Primary_Application_Allocation__c paa : trigger.old) {
lst.add(paa.opportunity__c);
}
}
list<Opportunity> opplst = new list<Opportunity>();
opplst=[SELECT Primary_Application_Allocation_Set__c FROM Opportunity where Id in :lst];
if(trigger.isInsert) {
for(Primary_Application_Allocation__c paa : trigger.new) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.Id) {
o.Primary_Application_Allocation_Set__c = true;
}
}
}
update opplst;
}
if(trigger.isDelete) {
for(Primary_Application_Allocation__c paa : trigger.old) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.id) {
o.Primary_Application_Allocation_Set__c = False;
}
}
}
update opplst;
}
}
and my
Test calss is:
@isTest
public class TestUpdatePrimaryApllicationAllocation {
RecordType rt = [select id,name from RecordType where name='Owner' and SobjectType='Account' limit 1];
RecordType rt1 = [select id,name from RecordType where name='NC Power' and SobjectType='Opportunity' limit 1];
static testMethod void insertPrimaryApllicationAllocationSet() {
Account acc = new Account(name = 'Test Account',country__c = 'Bangladesh');
insert acc;
Opportunity opp = new Opportunity(Name = 'Test Opp',stageName ='Sales Lead',CloseDate = Date.Today(),
ForecastCategoryName = 'Pipeline',CurrencyIsoCode = 'USD - U.S. Dollar');
insert opp;
Primary_Application_Allocation__c paa = new Primary_Application_Allocation__c( Opportunity__c = opp.id);
Test.startTest();
insert paa;
Test.stopTest();
Opportunity updatedOpp = [Select Id, Primary_Application_Allocation_Set__c from Opportunity where id =: opp.id];
System.assert(updatedOpp.Primary_Application_Allocation_Set__c);
}
static testMethod void deletePrimaryApllicationAllocationSet(){
Account acc = new Account(name = 'Test Account');
insert acc;
Opportunity opp = new Opportunity(Name = 'Test Opp', Amount = 10020);
insert opp;
Primary_Application_Allocation__c paa = new Primary_Application_Allocation__c( Opportunity__c = opp.id);
insert paa;
Test.startTest();
delete paa;
Test.stoptest();
Opportunity updatedOpp = [Select Id, Primary_Application_Allocation_Set__c from Opportunity where id =: opp.id];
System.assert(!updatedOpp.Primary_Application_Allocation_Set__c);
}
}
and i was facing the errors as:
Error Message : System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Opportunity Currency: invalid currency code: USD - U.S. Dollar: [CurrencyIsoCode]
Stack Trace Class : TestUpdatePrimaryApllicationAllocation.insertPrimaryApllicationAllocationSet: line 13, column 1
Error Message : System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AssignAccountTerritorytoOpportunity: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.AssignAccountTerritorytoOpportunity: line 2, column 1: []
Stack Trace : Class.TestUpdatePrimaryApllicationAllocation.deletePrimaryApllicationAllocationSet: line 27, column 1
- rajesh kumar 10
- August 19, 2014
- Like
- 0
I am new to test Class and i have a problem with the test class for a trigger
This is my trigger
trigger UpdatePrimaryApllicationAllocationSet on Primary_Application_Allocation__c (after insert,after delete) {
list<id> lst = new list<id>();
if(trigger.isInsert){
for(Primary_Application_Allocation__c paa : trigger.new) {
lst.add(paa.opportunity__c);
}}
if(trigger.isDelete){
for(Primary_Application_Allocation__c paa : trigger.old) {
lst.add(paa.opportunity__c);
}
}
list<Opportunity> opplst = new list<Opportunity>();
opplst=[SELECT Primary_Application_Allocation_Set__c FROM Opportunity where Id in :lst];
if(trigger.isInsert) {
for(Primary_Application_Allocation__c paa : trigger.new) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.Id) {
o.Primary_Application_Allocation_Set__c = true;
}
}
}
update opplst;
}
if(trigger.isDelete) {
for(Primary_Application_Allocation__c paa : trigger.old) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.id) {
o.Primary_Application_Allocation_Set__c = False;
}
}
}
update opplst;
}
}
and down i have written a test class but it is totally mess cause i am unaware of test class can any one help me in doing this..
@isTest
public class UpdatePrimaryApllicationAllocationSet {
static testMethod void UpdatePrimaryApllicationAllocationSet() {
Test.startTest();
Primary_Application_Allocation__c paa = new Primary_Application_Allocation__c(name='sample');
opportunity o = [select name,oppotunity from opportunity where o.opportunity = paa.opportunity];
insert paa;
update o;
Test.stopStart();
}
}
trigger UpdatePrimaryApllicationAllocationSet on Primary_Application_Allocation__c (after insert,after delete) {
list<id> lst = new list<id>();
if(trigger.isInsert){
for(Primary_Application_Allocation__c paa : trigger.new) {
lst.add(paa.opportunity__c);
}}
if(trigger.isDelete){
for(Primary_Application_Allocation__c paa : trigger.old) {
lst.add(paa.opportunity__c);
}
}
list<Opportunity> opplst = new list<Opportunity>();
opplst=[SELECT Primary_Application_Allocation_Set__c FROM Opportunity where Id in :lst];
if(trigger.isInsert) {
for(Primary_Application_Allocation__c paa : trigger.new) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.Id) {
o.Primary_Application_Allocation_Set__c = true;
}
}
}
update opplst;
}
if(trigger.isDelete) {
for(Primary_Application_Allocation__c paa : trigger.old) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.id) {
o.Primary_Application_Allocation_Set__c = False;
}
}
}
update opplst;
}
}
and down i have written a test class but it is totally mess cause i am unaware of test class can any one help me in doing this..
@isTest
public class UpdatePrimaryApllicationAllocationSet {
static testMethod void UpdatePrimaryApllicationAllocationSet() {
Test.startTest();
Primary_Application_Allocation__c paa = new Primary_Application_Allocation__c(name='sample');
opportunity o = [select name,oppotunity from opportunity where o.opportunity = paa.opportunity];
insert paa;
update o;
Test.stopStart();
}
}
- rajesh kumar 10
- August 18, 2014
- Like
- 0
I have facing a problem on trigger that..
I have to to write a trigger on object Primary application allocation that is related to opportuniity and
when atlease 1 record is created, set the opportunity.primary_application_allocation_set check mark = true
and
And when all the primary application records are deleted, set the opportunity.primary_application_allocation_set check mark = false ..
I was facing problem with this to write a trigger. so please can any one help on this..
when atlease 1 record is created, set the opportunity.primary_application_allocation_set check mark = true
and
And when all the primary application records are deleted, set the opportunity.primary_application_allocation_set check mark = false ..
I was facing problem with this to write a trigger. so please can any one help on this..
- rajesh kumar 10
- August 18, 2014
- Like
- 0
Hi i can a doubt in Test class for my Trigger i tried it but getting some Error can any pls tell whta the problem with my test class?
This is my trigger
trigger NCAccountApprovalSubmit on Account (after insert) {
for (Account a : trigger.new) {
if (a.RecordType_Name__c == 'Plant' && (a.Plant_Business_Type__c == 'New construction')
&& (a.plant_Type__c == 'potential plant')
&& (a.status__c!='active') && (a.super_region__c=='EAME')
&& (a.account_industry_type__c =='Power - Fossil'||a.account_industry_type__c =='O & G'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
}
}
And this is my Test Class
static testMethod void accountApprovalSubmitTest1(){
User ur = [Select u.Profile.Name, u.ProfileId, u.Id From User u where u.UserName = 'integration@ccivalve.com.beta' and isactive = true limit 1];
System.runAs(ur){
RecordType rdObj = [Select Id from RecordType where Name = 'Plant'];
Account tempObj = new Account();
tempObj.Name = 'Test';
tempObj.Account_Industry_Type__c = 'Power - Fossil';
tempObj.Country__c = 'CHINA';
tempObj.Plant_Business_Type__c = 'Aftermarket';
tempObj.Plant_Type__c = 'New Plant';
tempObj.RecordTypeId = rdObj.Id;
tempObj.Address__c = 'USA';
tempObj.City__c = 'USA';
tempObj.Postal_Code__c = 'USA';
insert tempObj;
}
}
the Error i was getting
Error Message System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process found.: []
Stack Trace Class.NCAccountApprovalSubmitTest.NCAccountApprovalSubmit.
trigger NCAccountApprovalSubmit on Account (after insert) {
for (Account a : trigger.new) {
if (a.RecordType_Name__c == 'Plant' && (a.Plant_Business_Type__c == 'New construction')
&& (a.plant_Type__c == 'potential plant')
&& (a.status__c!='active') && (a.super_region__c=='EAME')
&& (a.account_industry_type__c =='Power - Fossil'||a.account_industry_type__c =='O & G'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
}
}
And this is my Test Class
static testMethod void accountApprovalSubmitTest1(){
User ur = [Select u.Profile.Name, u.ProfileId, u.Id From User u where u.UserName = 'integration@ccivalve.com.beta' and isactive = true limit 1];
System.runAs(ur){
RecordType rdObj = [Select Id from RecordType where Name = 'Plant'];
Account tempObj = new Account();
tempObj.Name = 'Test';
tempObj.Account_Industry_Type__c = 'Power - Fossil';
tempObj.Country__c = 'CHINA';
tempObj.Plant_Business_Type__c = 'Aftermarket';
tempObj.Plant_Type__c = 'New Plant';
tempObj.RecordTypeId = rdObj.Id;
tempObj.Address__c = 'USA';
tempObj.City__c = 'USA';
tempObj.Postal_Code__c = 'USA';
insert tempObj;
}
}
the Error i was getting
Error Message System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process found.: []
Stack Trace Class.NCAccountApprovalSubmitTest.NCAccountApprovalSubmit.
- rajesh kumar 10
- August 16, 2014
- Like
- 0
Can any one help writing Test class for the below trigger?
trigger NCAccountApprovalSubmit on Account (after insert) {
for (Account a : trigger.new) {
if (a.RecordType_Name__c == 'Plant' && (a.Plant_Business_Type__c == 'New construction')
&& (a.plant_Type__c == 'potential plant')
&& (a.status__c!='active') && (a.super_region__c=='EAME')
&& (a.account_industry_type__c =='Power - Fossil'||a.account_industry_type__c =='O & G'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
}
}
for (Account a : trigger.new) {
if (a.RecordType_Name__c == 'Plant' && (a.Plant_Business_Type__c == 'New construction')
&& (a.plant_Type__c == 'potential plant')
&& (a.status__c!='active') && (a.super_region__c=='EAME')
&& (a.account_industry_type__c =='Power - Fossil'||a.account_industry_type__c =='O & G'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
}
}
- rajesh kumar 10
- August 12, 2014
- Like
- 0
I have a doubt on Test class can that i have written a trigger and i have writen test class for that but it was covering only 40% can any one please solve my problem???
My trigger is :
trigger accountApprovalSubmit on Account (after insert) {
for (Account a : trigger.new) {
if (a.RecordType_Name__c == 'Plant' && (a.Plant_Type__c == 'New Plant' || a.Plant_Type__c == 'Normal Plant'||
a.plant_Type__c == 'potential plant') && (a.plant_bussiness_Type__c == 'Aftermarket'||a.plant_bussiness_Type__c == 'New construction')
&& (a.status__c!='active') && (a.super_region__c=='EAME')
&& (a.account_industry_type__c =='Powe-Fossil'||a.account_industry_type__c =='O&G'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
}
}
Below is the TEST CLASS
@isTest
private class accountApprovalSubmit {
static testMethod void accountApprovalSubmit() {
Test.startTest();
Account acc= new Account(name='intelsjr',RecordtypeId='012U0000000Tq1N',Plant_Type__c = 'Potential Plant' ,
plant_business_Type__c = 'New Construction' ,status__c = 'inactive',
super_region__c='EAME',account_industry_type__c ='O&G');
insert acc;
List<ProcessInstance> p = [SELECT Id, (SELECT Id, StepStatus, Comments FROM StepsAndWorkitems)
FROM ProcessInstance where targetObjectId =:acc.id];
system.assertNotEquals(null,p);
Test.stopTest();
}
}
It was covering only 40% so please can any one solve my problem..
Thanks in Advance..
trigger accountApprovalSubmit on Account (after insert) {
for (Account a : trigger.new) {
if (a.RecordType_Name__c == 'Plant' && (a.Plant_Type__c == 'New Plant' || a.Plant_Type__c == 'Normal Plant'||
a.plant_Type__c == 'potential plant') && (a.plant_bussiness_Type__c == 'Aftermarket'||a.plant_bussiness_Type__c == 'New construction')
&& (a.status__c!='active') && (a.super_region__c=='EAME')
&& (a.account_industry_type__c =='Powe-Fossil'||a.account_industry_type__c =='O&G'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
}
}
Below is the TEST CLASS
@isTest
private class accountApprovalSubmit {
static testMethod void accountApprovalSubmit() {
Test.startTest();
Account acc= new Account(name='intelsjr',RecordtypeId='012U0000000Tq1N',Plant_Type__c = 'Potential Plant' ,
plant_business_Type__c = 'New Construction' ,status__c = 'inactive',
super_region__c='EAME',account_industry_type__c ='O&G');
insert acc;
List<ProcessInstance> p = [SELECT Id, (SELECT Id, StepStatus, Comments FROM StepsAndWorkitems)
FROM ProcessInstance where targetObjectId =:acc.id];
system.assertNotEquals(null,p);
Test.stopTest();
}
}
It was covering only 40% so please can any one solve my problem..
Thanks in Advance..
- rajesh kumar 10
- August 12, 2014
- Like
- 0
I have doubt on Approval process that can anyone please solve my solution!
I have 2 record types i.e 'a' and 'b',
(when i give record type='a' and field plant_Type=new,custom new,old and field sub_region=asia) and
(when i give record typr='b' and field plant_Type=custom new and field sub_region=asia).
then the roceors has to be approved....
(when i give record type='a' and field plant_Type=new,custom new,old and field sub_region=asia) and
(when i give record typr='b' and field plant_Type=custom new and field sub_region=asia).
then the roceors has to be approved....
- rajesh kumar 10
- August 10, 2014
- Like
- 0
Hi i was getting a problem in a visualforce page pdf and controller can any try to help me pls..
Hi i was getting problem with pdf that in visual force page that my "description " field is out of bouce that means i want to break the string i can not able to do that..
when i enter more words in the description field then the half table is only coming in pdf file so can any one find my problem please..
her i am giving my controller and visual foce codes:
controller :
public class QuotePDFAustria{
Public Quote qut{get;set;}
Public List<QuoteLineItem> QuLiIt{get;set;}
Public Date dat{get;set;}
Public QuotePDFAustria(ApexPages.StandardController controller){
qut = [SELECT id,name,Payment_Terms__c,Notes__c,Customer__r.name,Customer__r.City__c,Customer__r.State__c,Customer__r.Postal_Code__c,Customer__r.Country__c,GrandTotal,Quote_Address_To__r.name,Quote_Address_To__r.Salutation,Quote_Address_To__r.LastName,Quote_Address_To__r.email,Quote_Address_To__r.Phone,Opportunity.Primary_Inside_Sales__r.name,Primary_Inside_Sales__r.name,Primary_Inside_Sales_Email__c,Quote_Date__c,opportunity.Primary_Outside_Sales__r.name,opportunity.Primary_Outside_Sales__r.Phone,opportunity.Primary_Outside_Sales__r.Email,opportunity.Primary_Outside_Sales__r.fax,opportunity.Primary_Outside_Sales__r.Title,Inside_Sales_Fax__c,Inside_Sales_Phone__c,Inside_Sales_Title__c FROM Quote WHERE id =: ApexPages.CurrentPage().getParameters().get('id')];
QuLiIt = [SELECT id,LineNumber,Quantity,Item_Number__c,Asset__r.Model__c,Part_Description__c,UnitPrice,Asset__r.SerialNumber FROM QuoteLineItem WHERE QuoteId =: qut.id];
if(qut.Quote_Date__c != null)
dat = qut.Quote_Date__c + 30;
}
}
VisualForce :
<apex:page standardController="Quote" extensions="QuotePDFAustria" renderAs="pdf">
<head>
<style type="text/css">
@PageBreak{
page-break:always;
page-break-inside:avoid;
}
@media print{
table {page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
}
@page {
margin-top: 20%; margin-bottom: 110px;
margin-left:50px; margin-right:50px;
@top-center {
content: element(header);
}
@bottom-left {
content: element(footer);
height: 500px;
}
}
div.footer {
position: running(footer);
}
div.header {
margin:0 50px 0 0;
position: running(header);
}
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:15px;
color:#000;
border-width: 1px;
border-color: #000;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
</style>
</head>
<div class="header" align="center" >
<div><apex:image height="110px" width="230pk" value="{!$Resource.CC_IMI}"/></div>
</div>
<apex:form >
<!-- This Section is for PAGE 1-->
<table class="gridtable" width="100%">
<tr>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Customer :"/></u>
<p><b>{!qut.Customer__r.name}</b><br/>
{!qut.Customer__r.City__c}<br/>
{!qut.Customer__r.State__c} {!qut.Customer__r.Postal_Code__c}<br/>
<b>{!qut.Customer__r.Country__c}</b>
</p>
</td>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Supplier :"/></u>
<p><b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
<b>Austria</b>
</p>
</td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="To :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.name}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="From :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Opportunity.Primary_Inside_Sales__r.name}</td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Email :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.email}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Pages :"/></td>
<td style="padding-top:10px;padding-bottom:10px"></td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Phone :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.phone}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Date :"/></td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,date,dd'/'MM'/'yyyy}"><apex:param value="{!qut.Quote_Date__c}"/></apex:outputText></td>
</tr>
<tr align="center">
<td width="12%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Add Data :"/></td>
<td width="38%" style="padding-top:10px;padding-bottom:10px"></td>
<td width="12%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Cc :"/></td>
<td width="38%" style="padding-top:10px;padding-bottom:10px">{!qut.opportunity.Primary_Outside_Sales__r.name}</td>
</tr>
</table><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;">
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="QUOTATION No.:"/></th>
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qut.name}"/></th>
</tr>
</table><br/><br/>
Dear {!qut.Quote_Address_To__r.Salutation} {!qut.Quote_Address_To__r.LastName},<br/><br/>
We thank you for your inquiry and offer in accordance with the previous order ............... with the negotiated
purchase and warranty conditions as follows.<br/><br/><br/>
When ordering, we ask you to refer to the old order and confirm the validity if this purchasing and
warranty conditions.<br/><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px">Pos.</td>
<td width="5%" style="padding-top:10px;padding-bottom:10px">Q</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Article No.</td>
<td width="40%" style="padding-top:10px;padding-bottom:10px">Description</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pc</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/Pos</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">SL No.</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Valve Type</td>
</tr>
<apex:repeat value="{!QuLiIt}" var="qli">
<tr style="page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Item_Number__c}"/></td>
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Quantity}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.LineNumber}"/></td>
<td width="40%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Part_Description__c}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.UnitPrice}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qli.UnitPrice * qli.Quantity}"/></apex:outputText></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.SerialNumber}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.Model__c}"/></td>
</tr>
</apex:repeat>
<tr style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%"></td>
<td width="5%"></td>
<td width="10%"></td>
<td width="40%" style="text-align:right;padding-top:10px;padding-bottom:10px"><b>TOTAL</b></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pos.</td>
<td width="10%"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qut.GrandTotal}"/></apex:outputText></td>
<td width="10%"></td>
<td width="10%"></td>
</tr>
</table>
<br/><br/><br/>
We look forward to your early acceptance.<br/><br/>
Yours sincerely,<br/><br/>
<b>CCI Valve Technology GmbH<br/><br/><br/><br/><br/>
{!qut.Opportunity.Primary_Inside_Sales__r.name}</b>
</apex:form>
</apex:page>
when i enter more words in the description field then the half table is only coming in pdf file so can any one find my problem please..
her i am giving my controller and visual foce codes:
controller :
public class QuotePDFAustria{
Public Quote qut{get;set;}
Public List<QuoteLineItem> QuLiIt{get;set;}
Public Date dat{get;set;}
Public QuotePDFAustria(ApexPages.StandardController controller){
qut = [SELECT id,name,Payment_Terms__c,Notes__c,Customer__r.name,Customer__r.City__c,Customer__r.State__c,Customer__r.Postal_Code__c,Customer__r.Country__c,GrandTotal,Quote_Address_To__r.name,Quote_Address_To__r.Salutation,Quote_Address_To__r.LastName,Quote_Address_To__r.email,Quote_Address_To__r.Phone,Opportunity.Primary_Inside_Sales__r.name,Primary_Inside_Sales__r.name,Primary_Inside_Sales_Email__c,Quote_Date__c,opportunity.Primary_Outside_Sales__r.name,opportunity.Primary_Outside_Sales__r.Phone,opportunity.Primary_Outside_Sales__r.Email,opportunity.Primary_Outside_Sales__r.fax,opportunity.Primary_Outside_Sales__r.Title,Inside_Sales_Fax__c,Inside_Sales_Phone__c,Inside_Sales_Title__c FROM Quote WHERE id =: ApexPages.CurrentPage().getParameters().get('id')];
QuLiIt = [SELECT id,LineNumber,Quantity,Item_Number__c,Asset__r.Model__c,Part_Description__c,UnitPrice,Asset__r.SerialNumber FROM QuoteLineItem WHERE QuoteId =: qut.id];
if(qut.Quote_Date__c != null)
dat = qut.Quote_Date__c + 30;
}
}
VisualForce :
<apex:page standardController="Quote" extensions="QuotePDFAustria" renderAs="pdf">
<head>
<style type="text/css">
@PageBreak{
page-break:always;
page-break-inside:avoid;
}
@media print{
table {page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
}
@page {
margin-top: 20%; margin-bottom: 110px;
margin-left:50px; margin-right:50px;
@top-center {
content: element(header);
}
@bottom-left {
content: element(footer);
height: 500px;
}
}
div.footer {
position: running(footer);
}
div.header {
margin:0 50px 0 0;
position: running(header);
}
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:15px;
color:#000;
border-width: 1px;
border-color: #000;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
</style>
</head>
<div class="header" align="center" >
<div><apex:image height="110px" width="230pk" value="{!$Resource.CC_IMI}"/></div>
</div>
<apex:form >
<!-- This Section is for PAGE 1-->
<table class="gridtable" width="100%">
<tr>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Customer :"/></u>
<p><b>{!qut.Customer__r.name}</b><br/>
{!qut.Customer__r.City__c}<br/>
{!qut.Customer__r.State__c} {!qut.Customer__r.Postal_Code__c}<br/>
<b>{!qut.Customer__r.Country__c}</b>
</p>
</td>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Supplier :"/></u>
<p><b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
<b>Austria</b>
</p>
</td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="To :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.name}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="From :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Opportunity.Primary_Inside_Sales__r.name}</td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Email :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.email}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Pages :"/></td>
<td style="padding-top:10px;padding-bottom:10px"></td>
</tr>
<tr align="center">
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Phone :"/></td>
<td style="padding-top:10px;padding-bottom:10px">{!qut.Quote_Address_To__r.phone}</td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Date :"/></td>
<td style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,date,dd'/'MM'/'yyyy}"><apex:param value="{!qut.Quote_Date__c}"/></apex:outputText></td>
</tr>
<tr align="center">
<td width="12%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Add Data :"/></td>
<td width="38%" style="padding-top:10px;padding-bottom:10px"></td>
<td width="12%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="Cc :"/></td>
<td width="38%" style="padding-top:10px;padding-bottom:10px">{!qut.opportunity.Primary_Outside_Sales__r.name}</td>
</tr>
</table><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;">
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="QUOTATION No.:"/></th>
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qut.name}"/></th>
</tr>
</table><br/><br/>
Dear {!qut.Quote_Address_To__r.Salutation} {!qut.Quote_Address_To__r.LastName},<br/><br/>
We thank you for your inquiry and offer in accordance with the previous order ............... with the negotiated
purchase and warranty conditions as follows.<br/><br/><br/>
When ordering, we ask you to refer to the old order and confirm the validity if this purchasing and
warranty conditions.<br/><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px">Pos.</td>
<td width="5%" style="padding-top:10px;padding-bottom:10px">Q</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Article No.</td>
<td width="40%" style="padding-top:10px;padding-bottom:10px">Description</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pc</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/Pos</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">SL No.</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Valve Type</td>
</tr>
<apex:repeat value="{!QuLiIt}" var="qli">
<tr style="page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Item_Number__c}"/></td>
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Quantity}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.LineNumber}"/></td>
<td width="40%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Part_Description__c}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.UnitPrice}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qli.UnitPrice * qli.Quantity}"/></apex:outputText></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.SerialNumber}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.Model__c}"/></td>
</tr>
</apex:repeat>
<tr style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%"></td>
<td width="5%"></td>
<td width="10%"></td>
<td width="40%" style="text-align:right;padding-top:10px;padding-bottom:10px"><b>TOTAL</b></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pos.</td>
<td width="10%"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qut.GrandTotal}"/></apex:outputText></td>
<td width="10%"></td>
<td width="10%"></td>
</tr>
</table>
<br/><br/><br/>
We look forward to your early acceptance.<br/><br/>
Yours sincerely,<br/><br/>
<b>CCI Valve Technology GmbH<br/><br/><br/><br/><br/>
{!qut.Opportunity.Primary_Inside_Sales__r.name}</b>
</apex:form>
</apex:page>
- rajesh kumar 10
- September 01, 2014
- Like
- 1
I have a doubt on controller string splitting ? can any help me pls!
I have a problem with string spliting that when i create a pdf the table is excceding because of 'description' so i want to split that 'description' string i am trying to do it but unable to fix it i am sending the contrlooer and visualforce code can any try to help me out...
MY controller:
public class QuotePDFAustria{
Public Quote qut{get;set;}
Public List<QuoteLineItem> QuLiIt{get;set;}
Public Date dat{get;set;}
Public QuotePDFAustria(ApexPages.StandardController controller){
qut = [SELECT id,name,Payment_Terms__c,Notes__c,Customer__r.name,Customer__r.City__c,Customer__r.State__c,Customer__r.Postal_Code__c,Customer__r.Country__c,GrandTotal,Quote_Address_To__r.name,Quote_Address_To__r.Salutation,Quote_Address_To__r.LastName,Quote_Address_To__r.email,Quote_Address_To__r.Phone,Opportunity.Primary_Inside_Sales__r.name,Primary_Inside_Sales__r.name,Primary_Inside_Sales_Email__c,Quote_Date__c,opportunity.Primary_Outside_Sales__r.name,opportunity.Primary_Outside_Sales__r.Phone,opportunity.Primary_Outside_Sales__r.Email,opportunity.Primary_Outside_Sales__r.fax,opportunity.Primary_Outside_Sales__r.Title,Inside_Sales_Fax__c,Inside_Sales_Phone__c,Inside_Sales_Title__c FROM Quote WHERE id =: ApexPages.CurrentPage().getParameters().get('id')];
QuLiIt = [SELECT id,LineNumber,Quantity,Item_Number__c,Asset__r.Model__c,Part_Description__c,UnitPrice,Asset__r.SerialNumber FROM QuoteLineItem WHERE QuoteId =: qut.id];
if(qut.Quote_Date__c != null)
dat = qut.Quote_Date__c + 30;
}
}
and my Visualforce page:
<apex:page standardController="Quote" extensions="QuotePDFAustria" renderAs="pdf">
<head>
<style type="text/css">
@PageBreak{
page-break:always;
page-break-inside:avoid;
}
@media print{
table {page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
}
@page {
margin-top: 20%; margin-bottom: 110px;
margin-left:50px; margin-right:50px;
@top-center {
content: element(header);
}
@bottom-left {
content: element(footer);
height: 500px;
}
}
div.footer {
position: running(footer);
}
div.header {
margin:0 50px 0 0;
position: running(header);
}
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:15px;
color:#000;
border-width: 1px;
border-color: #000;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
</style>
</head>
<div class="footer">
<table border="0" width="100%" height = "100%" cellspacing="0" cellpadding="0">
<tr>
<td width="70%" >
<b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
Austria
</td>
<td width="30%">
Tel.: +43-1-869 27 40<br/>
Fax : +43-1-865 36 03<br/>
<b>www.ccivalve.com</b><br/>
e-mail : cci@ccivalve.at
</td>
</tr>
</table>
</div>
<div class="header" align="center" >
<div><apex:image height="110px" width="230pk" value="{!$Resource.CC_IMI}"/></div>
</div>
<apex:form >
<!-- This Section is for PAGE 1-->
<table class="gridtable" width="100%">
<tr>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Customer :"/></u>
<p><b>{!qut.Customer__r.name}</b><br/>
{!qut.Customer__r.City__c}<br/>
{!qut.Customer__r.State__c} {!qut.Customer__r.Postal_Code__c}<br/>
<b>{!qut.Customer__r.Country__c}</b>
</p>
</td>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Supplier :"/></u>
<p><b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
<b>Austria</b>
</p>
</td>
</table><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;">
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="QUOTATION No.:"/></th>
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qut.name}"/></th>
</tr>
</table><br/><br/>
Dear {!qut.Quote_Address_To__r.Salutation} {!qut.Quote_Address_To__r.LastName},<br/><br/>
We thank you for your inquiry and offer in accordance with the previous order ............... with the negotiated
purchase and warranty conditions as follows.<br/><br/><br/>
When ordering, we ask you to refer to the old order and confirm the validity if this purchasing and
warranty conditions.<br/><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px">Pos.</td>
<td width="5%" style="padding-top:10px;padding-bottom:10px">Q</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Article No.</td>
<td width="40%" style="padding-top:10px;padding-bottom:10px">Description</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pc</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/Pos</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">SL No.</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Valve Type</td>
</tr>
<apex:repeat value="{!QuLiIt}" var="qli">
<tr style="page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Item_Number__c}"/></td>
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Quantity}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.LineNumber}"/></td>
<td width="40%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Part_Description__c}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.UnitPrice}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qli.UnitPrice * qli.Quantity}"/></apex:outputText></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.SerialNumber}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.Model__c}"/></td>
</tr>
</apex:repeat>
<tr style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%"></td>
<td width="5%"></td>
<td width="10%"></td>
<td width="40%" style="text-align:right;padding-top:10px;padding-bottom:10px"><b>TOTAL</b></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pos.</td>
<td width="10%"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qut.GrandTotal}"/></apex:outputText></td>
<td width="10%"></td>
<td width="10%"></td>
</tr>
</table>
</apex:form>
</apex:page>
MY controller:
public class QuotePDFAustria{
Public Quote qut{get;set;}
Public List<QuoteLineItem> QuLiIt{get;set;}
Public Date dat{get;set;}
Public QuotePDFAustria(ApexPages.StandardController controller){
qut = [SELECT id,name,Payment_Terms__c,Notes__c,Customer__r.name,Customer__r.City__c,Customer__r.State__c,Customer__r.Postal_Code__c,Customer__r.Country__c,GrandTotal,Quote_Address_To__r.name,Quote_Address_To__r.Salutation,Quote_Address_To__r.LastName,Quote_Address_To__r.email,Quote_Address_To__r.Phone,Opportunity.Primary_Inside_Sales__r.name,Primary_Inside_Sales__r.name,Primary_Inside_Sales_Email__c,Quote_Date__c,opportunity.Primary_Outside_Sales__r.name,opportunity.Primary_Outside_Sales__r.Phone,opportunity.Primary_Outside_Sales__r.Email,opportunity.Primary_Outside_Sales__r.fax,opportunity.Primary_Outside_Sales__r.Title,Inside_Sales_Fax__c,Inside_Sales_Phone__c,Inside_Sales_Title__c FROM Quote WHERE id =: ApexPages.CurrentPage().getParameters().get('id')];
QuLiIt = [SELECT id,LineNumber,Quantity,Item_Number__c,Asset__r.Model__c,Part_Description__c,UnitPrice,Asset__r.SerialNumber FROM QuoteLineItem WHERE QuoteId =: qut.id];
if(qut.Quote_Date__c != null)
dat = qut.Quote_Date__c + 30;
}
}
and my Visualforce page:
<apex:page standardController="Quote" extensions="QuotePDFAustria" renderAs="pdf">
<head>
<style type="text/css">
@PageBreak{
page-break:always;
page-break-inside:avoid;
}
@media print{
table {page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
}
@page {
margin-top: 20%; margin-bottom: 110px;
margin-left:50px; margin-right:50px;
@top-center {
content: element(header);
}
@bottom-left {
content: element(footer);
height: 500px;
}
}
div.footer {
position: running(footer);
}
div.header {
margin:0 50px 0 0;
position: running(header);
}
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:15px;
color:#000;
border-width: 1px;
border-color: #000;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #000;
}
</style>
</head>
<div class="footer">
<table border="0" width="100%" height = "100%" cellspacing="0" cellpadding="0">
<tr>
<td width="70%" >
<b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
Austria
</td>
<td width="30%">
Tel.: +43-1-869 27 40<br/>
Fax : +43-1-865 36 03<br/>
<b>www.ccivalve.com</b><br/>
e-mail : cci@ccivalve.at
</td>
</tr>
</table>
</div>
<div class="header" align="center" >
<div><apex:image height="110px" width="230pk" value="{!$Resource.CC_IMI}"/></div>
</div>
<apex:form >
<!-- This Section is for PAGE 1-->
<table class="gridtable" width="100%">
<tr>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Customer :"/></u>
<p><b>{!qut.Customer__r.name}</b><br/>
{!qut.Customer__r.City__c}<br/>
{!qut.Customer__r.State__c} {!qut.Customer__r.Postal_Code__c}<br/>
<b>{!qut.Customer__r.Country__c}</b>
</p>
</td>
<td colspan="2" width="50%" style="vertical-align:Top;padding-top:5px;padding-left:20px;">
<u><apex:outputText value="Supplier :"/></u>
<p><b>CCI Valve Technology GmbH</b><br/>
Lemböckgasse 63/1<br/>
AT-1230 Vienna<br/>
<b>Austria</b>
</p>
</td>
</table><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;">
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="QUOTATION No.:"/></th>
<th width="50%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qut.name}"/></th>
</tr>
</table><br/><br/>
Dear {!qut.Quote_Address_To__r.Salutation} {!qut.Quote_Address_To__r.LastName},<br/><br/>
We thank you for your inquiry and offer in accordance with the previous order ............... with the negotiated
purchase and warranty conditions as follows.<br/><br/><br/>
When ordering, we ask you to refer to the old order and confirm the validity if this purchasing and
warranty conditions.<br/><br/>
<table width="100%" class="gridtable">
<tr align="center" style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px">Pos.</td>
<td width="5%" style="padding-top:10px;padding-bottom:10px">Q</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Article No.</td>
<td width="40%" style="padding-top:10px;padding-bottom:10px">Description</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pc</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/Pos</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">SL No.</td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">Valve Type</td>
</tr>
<apex:repeat value="{!QuLiIt}" var="qli">
<tr style="page-break:after:auto;page-break-inside:avoid;">
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Item_Number__c}"/></td>
<td width="5%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Quantity}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.LineNumber}"/></td>
<td width="40%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Part_Description__c}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.UnitPrice}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qli.UnitPrice * qli.Quantity}"/></apex:outputText></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.SerialNumber}"/></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px"><apex:outputText value="{!qli.Asset__r.Model__c}"/></td>
</tr>
</apex:repeat>
<tr style="background-color:#C0C0C0;page-break:after:auto;page-break-inside:avoid;">
<td width="5%"></td>
<td width="5%"></td>
<td width="10%"></td>
<td width="40%" style="text-align:right;padding-top:10px;padding-bottom:10px"><b>TOTAL</b></td>
<td width="10%" style="padding-top:10px;padding-bottom:10px">USD/pos.</td>
<td width="10%"><apex:outputText value="{0,Number,###,###,###.00}"><apex:param value="{!qut.GrandTotal}"/></apex:outputText></td>
<td width="10%"></td>
<td width="10%"></td>
</tr>
</table>
</apex:form>
</apex:page>
- rajesh kumar 10
- August 28, 2014
- Like
- 0
Problem on trigger can any see my problem
I have a doubt on trigger that i created a trigger on Primary application allocation object which is related to opportunity and when i create records in primary application allocation object then in opportunity object the "Primary Application Allocation Set" field should be checked and when i delete all the records in primary application allocation object which are are related to same opportunity record then that field should be false. but my trigger is creating a problem that when i am creating records then that field is comnig true but when i delete atleast one record then it is becoming false but i dont want like that when i delete all records in primaary application alocation which are related to that opportunity then only the field should be false..
Below is my trigger please go through it and suggest me please..
trigger UpdatePrimaryApllicationAllocationSet on Primary_Application_Allocation__c (after insert,after delete) {
list<id> lst = new list<id>();
if(trigger.isInsert){
for(Primary_Application_Allocation__c paa : trigger.new) {
lst.add(paa.opportunity__c);
}}
if(trigger.isDelete){
for(Primary_Application_Allocation__c paa : trigger.old) {
lst.add(paa.opportunity__c);
}
}
list<Opportunity> opplst = new list<Opportunity>();
opplst=[SELECT Primary_Application_Allocation_Set__c FROM Opportunity where Id in :lst];
if(trigger.isInsert) {
for(Primary_Application_Allocation__c paa : trigger.new) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.Id) {
o.Primary_Application_Allocation_Set__c = true;
}
}
}
update opplst;
}
if(trigger.isDelete) {
for(Primary_Application_Allocation__c paa : trigger.old) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.id) {
o.Primary_Application_Allocation_Set__c = False;
}
}
}
update opplst;
}
}
thanks in advance
Below is my trigger please go through it and suggest me please..
trigger UpdatePrimaryApllicationAllocationSet on Primary_Application_Allocation__c (after insert,after delete) {
list<id> lst = new list<id>();
if(trigger.isInsert){
for(Primary_Application_Allocation__c paa : trigger.new) {
lst.add(paa.opportunity__c);
}}
if(trigger.isDelete){
for(Primary_Application_Allocation__c paa : trigger.old) {
lst.add(paa.opportunity__c);
}
}
list<Opportunity> opplst = new list<Opportunity>();
opplst=[SELECT Primary_Application_Allocation_Set__c FROM Opportunity where Id in :lst];
if(trigger.isInsert) {
for(Primary_Application_Allocation__c paa : trigger.new) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.Id) {
o.Primary_Application_Allocation_Set__c = true;
}
}
}
update opplst;
}
if(trigger.isDelete) {
for(Primary_Application_Allocation__c paa : trigger.old) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.id) {
o.Primary_Application_Allocation_Set__c = False;
}
}
}
update opplst;
}
}
thanks in advance
- rajesh kumar 10
- August 21, 2014
- Like
- 0
I have facing a problem with the Test class for my trigger can any one please solve my problem below i am providing my trigger and test calss and error i was facing..
My Trigger is:
trigger UpdatePrimaryApllicationAllocationSet on Primary_Application_Allocation__c (after insert,after delete) {
list<id> lst = new list<id>();
if(trigger.isInsert){
for(Primary_Application_Allocation__c paa : trigger.new) {
lst.add(paa.opportunity__c);
}}
if(trigger.isDelete){
for(Primary_Application_Allocation__c paa : trigger.old) {
lst.add(paa.opportunity__c);
}
}
list<Opportunity> opplst = new list<Opportunity>();
opplst=[SELECT Primary_Application_Allocation_Set__c FROM Opportunity where Id in :lst];
if(trigger.isInsert) {
for(Primary_Application_Allocation__c paa : trigger.new) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.Id) {
o.Primary_Application_Allocation_Set__c = true;
}
}
}
update opplst;
}
if(trigger.isDelete) {
for(Primary_Application_Allocation__c paa : trigger.old) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.id) {
o.Primary_Application_Allocation_Set__c = False;
}
}
}
update opplst;
}
}
and my
Test calss is:
@isTest
public class TestUpdatePrimaryApllicationAllocation {
RecordType rt = [select id,name from RecordType where name='Owner' and SobjectType='Account' limit 1];
RecordType rt1 = [select id,name from RecordType where name='NC Power' and SobjectType='Opportunity' limit 1];
static testMethod void insertPrimaryApllicationAllocationSet() {
Account acc = new Account(name = 'Test Account',country__c = 'Bangladesh');
insert acc;
Opportunity opp = new Opportunity(Name = 'Test Opp',stageName ='Sales Lead',CloseDate = Date.Today(),
ForecastCategoryName = 'Pipeline',CurrencyIsoCode = 'USD - U.S. Dollar');
insert opp;
Primary_Application_Allocation__c paa = new Primary_Application_Allocation__c( Opportunity__c = opp.id);
Test.startTest();
insert paa;
Test.stopTest();
Opportunity updatedOpp = [Select Id, Primary_Application_Allocation_Set__c from Opportunity where id =: opp.id];
System.assert(updatedOpp.Primary_Application_Allocation_Set__c);
}
static testMethod void deletePrimaryApllicationAllocationSet(){
Account acc = new Account(name = 'Test Account');
insert acc;
Opportunity opp = new Opportunity(Name = 'Test Opp', Amount = 10020);
insert opp;
Primary_Application_Allocation__c paa = new Primary_Application_Allocation__c( Opportunity__c = opp.id);
insert paa;
Test.startTest();
delete paa;
Test.stoptest();
Opportunity updatedOpp = [Select Id, Primary_Application_Allocation_Set__c from Opportunity where id =: opp.id];
System.assert(!updatedOpp.Primary_Application_Allocation_Set__c);
}
}
and i was facing the errors as:
Error Message : System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Opportunity Currency: invalid currency code: USD - U.S. Dollar: [CurrencyIsoCode]
Stack Trace Class : TestUpdatePrimaryApllicationAllocation.insertPrimaryApllicationAllocationSet: line 13, column 1
Error Message : System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AssignAccountTerritorytoOpportunity: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.AssignAccountTerritorytoOpportunity: line 2, column 1: []
Stack Trace : Class.TestUpdatePrimaryApllicationAllocation.deletePrimaryApllicationAllocationSet: line 27, column 1
trigger UpdatePrimaryApllicationAllocationSet on Primary_Application_Allocation__c (after insert,after delete) {
list<id> lst = new list<id>();
if(trigger.isInsert){
for(Primary_Application_Allocation__c paa : trigger.new) {
lst.add(paa.opportunity__c);
}}
if(trigger.isDelete){
for(Primary_Application_Allocation__c paa : trigger.old) {
lst.add(paa.opportunity__c);
}
}
list<Opportunity> opplst = new list<Opportunity>();
opplst=[SELECT Primary_Application_Allocation_Set__c FROM Opportunity where Id in :lst];
if(trigger.isInsert) {
for(Primary_Application_Allocation__c paa : trigger.new) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.Id) {
o.Primary_Application_Allocation_Set__c = true;
}
}
}
update opplst;
}
if(trigger.isDelete) {
for(Primary_Application_Allocation__c paa : trigger.old) {
for(Opportunity o : opplst) {
if(paa.Opportunity__c == o.id) {
o.Primary_Application_Allocation_Set__c = False;
}
}
}
update opplst;
}
}
and my
Test calss is:
@isTest
public class TestUpdatePrimaryApllicationAllocation {
RecordType rt = [select id,name from RecordType where name='Owner' and SobjectType='Account' limit 1];
RecordType rt1 = [select id,name from RecordType where name='NC Power' and SobjectType='Opportunity' limit 1];
static testMethod void insertPrimaryApllicationAllocationSet() {
Account acc = new Account(name = 'Test Account',country__c = 'Bangladesh');
insert acc;
Opportunity opp = new Opportunity(Name = 'Test Opp',stageName ='Sales Lead',CloseDate = Date.Today(),
ForecastCategoryName = 'Pipeline',CurrencyIsoCode = 'USD - U.S. Dollar');
insert opp;
Primary_Application_Allocation__c paa = new Primary_Application_Allocation__c( Opportunity__c = opp.id);
Test.startTest();
insert paa;
Test.stopTest();
Opportunity updatedOpp = [Select Id, Primary_Application_Allocation_Set__c from Opportunity where id =: opp.id];
System.assert(updatedOpp.Primary_Application_Allocation_Set__c);
}
static testMethod void deletePrimaryApllicationAllocationSet(){
Account acc = new Account(name = 'Test Account');
insert acc;
Opportunity opp = new Opportunity(Name = 'Test Opp', Amount = 10020);
insert opp;
Primary_Application_Allocation__c paa = new Primary_Application_Allocation__c( Opportunity__c = opp.id);
insert paa;
Test.startTest();
delete paa;
Test.stoptest();
Opportunity updatedOpp = [Select Id, Primary_Application_Allocation_Set__c from Opportunity where id =: opp.id];
System.assert(!updatedOpp.Primary_Application_Allocation_Set__c);
}
}
and i was facing the errors as:
Error Message : System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Opportunity Currency: invalid currency code: USD - U.S. Dollar: [CurrencyIsoCode]
Stack Trace Class : TestUpdatePrimaryApllicationAllocation.insertPrimaryApllicationAllocationSet: line 13, column 1
Error Message : System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AssignAccountTerritorytoOpportunity: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.AssignAccountTerritorytoOpportunity: line 2, column 1: []
Stack Trace : Class.TestUpdatePrimaryApllicationAllocation.deletePrimaryApllicationAllocationSet: line 27, column 1
- rajesh kumar 10
- August 19, 2014
- Like
- 0
I have facing a problem on trigger that..
I have to to write a trigger on object Primary application allocation that is related to opportuniity and
when atlease 1 record is created, set the opportunity.primary_application_allocation_set check mark = true
and
And when all the primary application records are deleted, set the opportunity.primary_application_allocation_set check mark = false ..
I was facing problem with this to write a trigger. so please can any one help on this..
when atlease 1 record is created, set the opportunity.primary_application_allocation_set check mark = true
and
And when all the primary application records are deleted, set the opportunity.primary_application_allocation_set check mark = false ..
I was facing problem with this to write a trigger. so please can any one help on this..
- rajesh kumar 10
- August 18, 2014
- Like
- 0
Hi i can a doubt in Test class for my Trigger i tried it but getting some Error can any pls tell whta the problem with my test class?
This is my trigger
trigger NCAccountApprovalSubmit on Account (after insert) {
for (Account a : trigger.new) {
if (a.RecordType_Name__c == 'Plant' && (a.Plant_Business_Type__c == 'New construction')
&& (a.plant_Type__c == 'potential plant')
&& (a.status__c!='active') && (a.super_region__c=='EAME')
&& (a.account_industry_type__c =='Power - Fossil'||a.account_industry_type__c =='O & G'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
}
}
And this is my Test Class
static testMethod void accountApprovalSubmitTest1(){
User ur = [Select u.Profile.Name, u.ProfileId, u.Id From User u where u.UserName = 'integration@ccivalve.com.beta' and isactive = true limit 1];
System.runAs(ur){
RecordType rdObj = [Select Id from RecordType where Name = 'Plant'];
Account tempObj = new Account();
tempObj.Name = 'Test';
tempObj.Account_Industry_Type__c = 'Power - Fossil';
tempObj.Country__c = 'CHINA';
tempObj.Plant_Business_Type__c = 'Aftermarket';
tempObj.Plant_Type__c = 'New Plant';
tempObj.RecordTypeId = rdObj.Id;
tempObj.Address__c = 'USA';
tempObj.City__c = 'USA';
tempObj.Postal_Code__c = 'USA';
insert tempObj;
}
}
the Error i was getting
Error Message System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process found.: []
Stack Trace Class.NCAccountApprovalSubmitTest.NCAccountApprovalSubmit.
trigger NCAccountApprovalSubmit on Account (after insert) {
for (Account a : trigger.new) {
if (a.RecordType_Name__c == 'Plant' && (a.Plant_Business_Type__c == 'New construction')
&& (a.plant_Type__c == 'potential plant')
&& (a.status__c!='active') && (a.super_region__c=='EAME')
&& (a.account_industry_type__c =='Power - Fossil'||a.account_industry_type__c =='O & G'))
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(a.id);
Approval.ProcessResult result = Approval.process(app);
}
}
}
And this is my Test Class
static testMethod void accountApprovalSubmitTest1(){
User ur = [Select u.Profile.Name, u.ProfileId, u.Id From User u where u.UserName = 'integration@ccivalve.com.beta' and isactive = true limit 1];
System.runAs(ur){
RecordType rdObj = [Select Id from RecordType where Name = 'Plant'];
Account tempObj = new Account();
tempObj.Name = 'Test';
tempObj.Account_Industry_Type__c = 'Power - Fossil';
tempObj.Country__c = 'CHINA';
tempObj.Plant_Business_Type__c = 'Aftermarket';
tempObj.Plant_Type__c = 'New Plant';
tempObj.RecordTypeId = rdObj.Id;
tempObj.Address__c = 'USA';
tempObj.City__c = 'USA';
tempObj.Postal_Code__c = 'USA';
insert tempObj;
}
}
the Error i was getting
Error Message System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process found.: []
Stack Trace Class.NCAccountApprovalSubmitTest.NCAccountApprovalSubmit.
- rajesh kumar 10
- August 16, 2014
- Like
- 0