-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
5Questions
-
2Replies
Problem with Test class & COde coverage
public class jointactionplancon {
//variable declaration
public id i ;
public List<Business_Plan_Response__c> bp{get; set;}
public Business_Plan_Response__c bpr{get; set;}
public List<Business_Plan_Proposal__c> bprlst{get; set;}
public integer num{get; set;}
public integer num1{get; set;}
public Business_Plan_Proposal__c bpprop{get; set;}
//constructor
public jointactionplancon ()
{ bpr=new Business_Plan_Response__c();
i=Apexpages.currentpage().getparameters().get('id');
bprlst= new List<Business_Plan_Proposal__c>();
bprlst=[SELECT id, Proposal_Txt__c,Action_Txt__c,Priority_Num__c,Business_Plan_SFID__c, Review_Txt__c FROM Business_Plan_Proposal__c WHERE Business_Plan_SFID__c=:i ORDER BY Priority_Num__c asc limit 2 ];
bpprop=new Business_Plan_Proposal__c();
bp= new list<Business_Plan_Response__c>();
bp=[SELECT id,Question_Txt__c,Display_Order_Num__c,Response_Txt__c FROM Business_Plan_Response__c WHERE Business_Plan_SFID__c=:i ORDER BY Display_Order_Num__c asc ];
}
//this method is to Add a row in list
public PageReference Add_Row()
{ //bprlst= new List<Business_Plan_Proposal__c>();
for(integer i=0; i<num; i++){
bprlst.add(new Business_Plan_Proposal__c());}
return null;
}
public PageReference Add_Row1()
{
for(integer i=0; i<num1; i++){
bp.add(new Business_Plan_Response__c());}
return null;
}
//to pull list of Active Campaigns based on vob
public list<Campaign> getcamp(){
list<Campaign> ca= new list<Campaign>();
ca=[select Name from Campaign where Type='VOB' and IsActive=true limit 10 ];
return ca;
}
// Saving & Cancel the record and navigating to view page
public PageReference saverec() {
//this loop for updating bp response
for( Business_Plan_Response__c bprs: bp){
if(bprs.id!=null){
bpr.id=bprs.id;
bpr.Question_Txt__c=bprs.Question_Txt__c;
bpr.Response_Txt__c=bprs.Response_Txt__c;
update bpr;}
else{
bprs.Business_Plan_SFID__c=i;
insert bprs;
}
}
//this loop for updating bp proposal
for(Business_Plan_Proposal__c bpps:bprlst){
if(bpps.id!=null)
{
bpprop.id=bpps.id;
bpprop.Proposal_Txt__c=bpps.Proposal_Txt__c;
bpprop.Action_Txt__c=bpps.Action_Txt__c;
bpprop.Review_Txt__c=bpps.Review_Txt__c;
update bpprop;
}else{
bpps.Business_Plan_SFID__c=i;
insert bpps;
}
}
return null;
}
public PageReference cancel() {
return null;
}
}
--------------------------------------
Test class:-
--------------------------------------
@istest
private class testjointActionplan{
static testMethod void testjointActionplan()
{
Business_Plan__c bp= new Business_Plan__c( name='test',Account_SFID__c='00130000011kO2F');
insert bp;
system.assertnotEquals(bp,null);
Business_Plan_Response__c bprs= new Business_Plan_Response__c();
Business_Plan_Response__c bpr= new Business_Plan_Response__c();
bpr.Business_Plan_SFID__c=bp.id;
bpr.id=bprs.id;
bpr.Question_Txt__c=bprs.Question_Txt__c;
bpr.Response_Txt__c=bprs.Response_Txt__c;
insert bpr;
Business_Plan_Proposal__c bplst= new Business_Plan_Proposal__c();
bplst.Business_Plan_SFID__c=bp.id;
insert bplst;
jointactionplancon con= new jointactionplancon ();
con.Add_Row();
con.Add_Row1();
con.saverec();
con.getcamp();
con.cancel() ;
}
}
Am gettin 65% code coverage could any one help me on this
Thanks In advance
-
- Knight12@tarun
- May 01, 2013
- Like
- 0
- Continue reading or reply
Attachment ofVisual Force page as PDF and Emailing
Hi Everyone,
Needed Help on this Issue .I have created a visual force page and trying to send it as an attachment,Its working Fine but after load functionality is needed to send the parameters so the screen shot is given as email and the data input is missing in Email. Could any one suggest.
Here is my code:-
<apex:page controller="pfdTest">
<Apex:inputField value="{!acc.AccName__c}"/>
<apex:inputField value="{!acc.Email__c}"/>
<apex:commandButton value="Save" action="{!pdfmethod}"/>
</apex:page>
public pagereference save()
{
insert acc;
system.debug('-----------------------'+acc.id);
pdfmethod();
pagereference pg=new pagereference('/apex/attachmentPDF?id='+acc.id);
return null;
}
public blob body;
public PageReference pdfmethod(){
//insert acc;
PageReference ref=page.pdfTest;
ref.getParameters().put('id',(String)acc.id);
// system.debug('-------------------------------'+ref.id);
ref.setRedirect(true);
body=ref.getContentAsPDF();
Messaging.EmailFileAttachment mefa=new Messaging.EmailFileAttachment();
mefa.setContentType('application/pdf');
mefa.setFileName('Vinee.Pdf');
mefa.Body=body;
Messaging.SingleEmailMessage msem=new Messaging.SingleEmailMessage();
msem.setToAddresses(new String[] {'tarun.mopuru@gmail.com'});
msem.setSubject('Email PDF Demo');
msem.setPlainTextBody('sending pdf to email from salesforce visualforce');
msem.setFileAttachments(new Messaging.EmailFileAttachment[] {mefa});
//send email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {msem});
return null;
}
Thanks In Advance
-
- Knight12@tarun
- April 29, 2013
- Like
- 0
- Continue reading or reply
Record type in Test classes
I have two record types name as Doctor and Other.
How to achieve the Record type IDs in test class to achieve step1 controller?
Error:- System.QueryException: List has more than 1 row for assignment to SObject
Stack trace:- Class.newpatientController.testnewpatientController: line 72, column 1
public class newpatientController {
Patient__c patient;
Contact contact;
Order__C order;
public Contact getContact() {
if(contact == null) contact = new Contact();
return contact;
}
public Patient__c getpatient() {
if(patient == null) patient = new Patient__c();
return patient;
}
public Order__C getorder() {
if(order == null) order = new Order__C();
return order;
}
public PageReference step() {
return Page.recordtype;
}
public PageReference step1() {
if(Patient.RecordTypeId=='01290000000SNs1AAG')
{
return Page.newdoctor;
}
else
{
return Page.newpatient;
}
}
public PageReference step2() {
return Page.newpatient2;
}
public PageReference step3() {
return Page.newpatient3;
}
public PageReference save() {
insert patient;
system.debug('--------------------------------------------'+patient.id);
contact.Patient__c= Patient.id;
insert contact;
order.Patient_Name__c= patient.id;
insert order;
PageReference orderPage = new PageReference('/' +order.id);
orderPage.setRedirect(true);
return orderPage;
}
private static testmethod void testnewpatientController(){
newpatientController controller = new newpatientController ();
Patient__C pat = new Patient__C(id='a0a90000000SbUN');
id idRT = [select Id from RecordType where SobjectType = 'Patient__c' ].Id;
pat.RecordTypeId = idRT;
pat.Name = 'a0a90000000SbUN';
Order__C ord = new Order__C(id='a0Z9000000C5bNx');
ord.Patient_Name__c = 'a0a90000000SbUN';
ord.Type_of_Study__c = 'Sleep';
ord.Date_of_Study__c = Date.newInstance(2010,12,31);
Contact cont = controller.getContact();
cont.LastName = 'Testlast';
cont.FirstName = 'name1';
cont.phone = '5551211234';
controller.step();
controller.step1();
controller.step2();
controller.step3();
controller.save();
}
}
Thanks In advance.
-
- Knight12@tarun
- January 31, 2013
- Like
- 0
- Continue reading or reply
Inserting account field in visual force page having Person Accounts Record types
Error message while updating Person Account through visual force wizard
herei s my code
<apex:page controller="patientController" tabStyle="Opportunity" sidebar="false" showHeader="false">
<apex:form >
<apex:pageBlock title="Record Type">
<apex:pageMessages />
<apex:pageblocksection >
<apex:panelGrid >
<apex:outputLabel value="Record Type" for="recordtype"/>
<apex:inputField id="recordtype" value="{!PersonAccount.RecordTypeId}"/>
</apex:panelGrid>
</apex:pageblocksection>
<apex:pageBlockSection title="Contact Information">
<apex:panelGrid columns="2">
<apex:outputLabel value="Name" for="perfirstName"/>
<apex:inputField id="perfirstName" value="{!PersonAccount.Name}"/>
</apex:panelGrid>
</apex:pageBlockSection>
<apex:facet name="footer">
<apex:outputPanel >
<apex:commandButton action="{!step1}" value="Next" styleClass="btn"/>
</apex:outputPanel>
</apex:facet>
</apex:pageBlock>
</apex:form>
</apex:page>
Class.patientController.save: line 70, column 1
while inserting the Person account error is
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Account: bad field names on insert/update call: Name: [Name]
Any one please need a suggestion
public PageReference save() {
PersonAccount.RecordTypeId=PersonAccount.RecordTypeId;
insert PersonAccount;
PageReference orderPage = new PageReference('/' +PersonAccount.id);
orderPage.setRedirect(true);
return orderPage;
}
Thanks In advance,
Newbie @ knight12
-
- Knight12@tarun
- January 21, 2013
- Like
- 0
- Continue reading or reply
Validation Rule For two check boxes
HI Board,
could any one help from a situation . The Situation is I do have two Check boxes (Checkbox A & Checkbox B).And My condition is to allow any one of the check box is true ,not the two at a time.
If checkbox A is true , Check box B should be False and IF Checkbox B is true , Check box B should be False , Both should not be TRUE.
Thanks In ADVANCE
Tarun(Dark Knight)
-
- Knight12@tarun
- January 04, 2013
- Like
- 0
- Continue reading or reply
Problem with Test class & COde coverage
public class jointactionplancon {
//variable declaration
public id i ;
public List<Business_Plan_Response__c> bp{get; set;}
public Business_Plan_Response__c bpr{get; set;}
public List<Business_Plan_Proposal__c> bprlst{get; set;}
public integer num{get; set;}
public integer num1{get; set;}
public Business_Plan_Proposal__c bpprop{get; set;}
//constructor
public jointactionplancon ()
{ bpr=new Business_Plan_Response__c();
i=Apexpages.currentpage().getparameters().get('id');
bprlst= new List<Business_Plan_Proposal__c>();
bprlst=[SELECT id, Proposal_Txt__c,Action_Txt__c,Priority_Num__c,Business_Plan_SFID__c, Review_Txt__c FROM Business_Plan_Proposal__c WHERE Business_Plan_SFID__c=:i ORDER BY Priority_Num__c asc limit 2 ];
bpprop=new Business_Plan_Proposal__c();
bp= new list<Business_Plan_Response__c>();
bp=[SELECT id,Question_Txt__c,Display_Order_Num__c,Response_Txt__c FROM Business_Plan_Response__c WHERE Business_Plan_SFID__c=:i ORDER BY Display_Order_Num__c asc ];
}
//this method is to Add a row in list
public PageReference Add_Row()
{ //bprlst= new List<Business_Plan_Proposal__c>();
for(integer i=0; i<num; i++){
bprlst.add(new Business_Plan_Proposal__c());}
return null;
}
public PageReference Add_Row1()
{
for(integer i=0; i<num1; i++){
bp.add(new Business_Plan_Response__c());}
return null;
}
//to pull list of Active Campaigns based on vob
public list<Campaign> getcamp(){
list<Campaign> ca= new list<Campaign>();
ca=[select Name from Campaign where Type='VOB' and IsActive=true limit 10 ];
return ca;
}
// Saving & Cancel the record and navigating to view page
public PageReference saverec() {
//this loop for updating bp response
for( Business_Plan_Response__c bprs: bp){
if(bprs.id!=null){
bpr.id=bprs.id;
bpr.Question_Txt__c=bprs.Question_Txt__c;
bpr.Response_Txt__c=bprs.Response_Txt__c;
update bpr;}
else{
bprs.Business_Plan_SFID__c=i;
insert bprs;
}
}
//this loop for updating bp proposal
for(Business_Plan_Proposal__c bpps:bprlst){
if(bpps.id!=null)
{
bpprop.id=bpps.id;
bpprop.Proposal_Txt__c=bpps.Proposal_Txt__c;
bpprop.Action_Txt__c=bpps.Action_Txt__c;
bpprop.Review_Txt__c=bpps.Review_Txt__c;
update bpprop;
}else{
bpps.Business_Plan_SFID__c=i;
insert bpps;
}
}
return null;
}
public PageReference cancel() {
return null;
}
}
--------------------------------------
Test class:-
--------------------------------------
@istest
private class testjointActionplan{
static testMethod void testjointActionplan()
{
Business_Plan__c bp= new Business_Plan__c( name='test',Account_SFID__c='00130000011kO2F');
insert bp;
system.assertnotEquals(bp,null);
Business_Plan_Response__c bprs= new Business_Plan_Response__c();
Business_Plan_Response__c bpr= new Business_Plan_Response__c();
bpr.Business_Plan_SFID__c=bp.id;
bpr.id=bprs.id;
bpr.Question_Txt__c=bprs.Question_Txt__c;
bpr.Response_Txt__c=bprs.Response_Txt__c;
insert bpr;
Business_Plan_Proposal__c bplst= new Business_Plan_Proposal__c();
bplst.Business_Plan_SFID__c=bp.id;
insert bplst;
jointactionplancon con= new jointactionplancon ();
con.Add_Row();
con.Add_Row1();
con.saverec();
con.getcamp();
con.cancel() ;
}
}
Am gettin 65% code coverage could any one help me on this
Thanks In advance
- Knight12@tarun
- May 01, 2013
- Like
- 0
- Continue reading or reply
Validation Rule For two check boxes
HI Board,
could any one help from a situation . The Situation is I do have two Check boxes (Checkbox A & Checkbox B).And My condition is to allow any one of the check box is true ,not the two at a time.
If checkbox A is true , Check box B should be False and IF Checkbox B is true , Check box B should be False , Both should not be TRUE.
Thanks In ADVANCE
Tarun(Dark Knight)
- Knight12@tarun
- January 04, 2013
- Like
- 0
- Continue reading or reply