• Jana Todddd
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hello there, I'm doing program in which based on choice account/contact or lead has to be created.
while defining parameterized method I'm getting error as Integer (datatype) does not exist
//code

public class CIS_void_nonVoid_Pts {

    public string choice {get;set;}
    public string Acct {get;set;}
    public string con {get;set;}
    public string lead {get;set;}
    
    
    contact cn = new Contact();
        Account ac = new Account();
        lead ll = new lead();
    public void choiceMethod(){
        
        
        if(choice=='Acct'){
           AcctCreate(String X, Integer Y);
        }
       else if(choice=='con'){
            conCreate();
        }
        else if(choice =='lead'){
            leadcreate();
        }
    }
    
    void AcctCreate(String A, integer B){
        
        ac.name = A;
        ac.Phone = ''+B;
        insert ac;
    }
    
    void conCreate(){
        
        cn.lastname = ac.name +' '+'contact' ;
        insert cn;
        
    }
        void leadCreate(){
            lead ll = new lead();
            ll.lastname = cn.LastName;
            ll.Company = ac.name;
            ll.Status = 'open - not contacted';
            insert ll;
        }
    }

can anyone please help !!

Greetings!

 

I have a trouble with my class but i don't know how to handle the error...

 

Here is the scenario... if the user fill all the fields but if don't upload file i get a message error that body and header are missing and are not required, next if they select the files but some field is wrong the page refresh and now the files are missing so if the user try to upload them again we get a error message about the id

 

I'll rally appreciate your help!

 

public class myArcoExtension
{

private final Arco__c webarco;
public myArcoExtension(ApexPages.StandardController stdController)
{
webarco = (Arco__c)stdController.getRecord();
attach = new Attachment();
attach2 = new Attachment();
}

public myArcoExtension(){}

public PageReference saveArco()
{
try {
insert(webarco);
upload();
upload2();
}
catch(System.DMLException e)
{
ApexPages.addMessages(e);
return null;
}
PageReference p = Page.informacion_enviada;
p.setRedirect(true);
return p;
}


public String parentId {get;set;}
public Attachment attach {get;set;}

public ApexPages.Pagereference upload()
{
attach.ParentId = webarco.id;
insert attach;
return new ApexPages.Standardcontroller(attach).view();
}


public String parentId2 {get;set;}
public Attachment attach2 {get;set;}

public ApexPages.Pagereference upload2()
{
attach2.ParentId = webarco.id;
insert attach2;
return new ApexPages.Standardcontroller(attach2).view();
}


/* Clase testMethod para validar el código y cubrir el porcentaje de cobertura */
public static testMethod void myTest() {
Arco__c arco = new Arco__c();
arco.Nombre__c = 'Emmanuel';
arco.Apellidos__c = 'Corona';
arco.Email__c = 'ecorona@mcmtelecom.com.mx';
insert arco;

//Create the controller
ApexPages.StandardController sc = new ApexPages.StandardController(arco);

//Create the instances of the controller
myArcoExtension myPageTest = new myArcoExtension();

myArcoExtension myPageTestSC = new myArcoExtension(sc);
myPageTestSC.saveArco();

Attachment attachment = new Attachment();
attachment.Name = 'Unit Test Attachment';
attachment.Body = Blob.valueOf('Unit Test Attachment Body');

myPageTestSC.attach = attachment;
myPageTestSC.upload();

Attachment attachment2 = new Attachment();
attachment2.Name = 'Unit Test Attachment 2';
attachment2.Body = Blob.valueOf('Unit Test Attachment Body 2');

myPageTestSC.attach2 = attachment2;
myPageTestSC.upload2();
}
}