• Emmanuel Corona
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 53
    Replies

greetings!

 

I'm working in a trigger with the next sintax

 

if (opp.stagename=='Ganada' && mapPuntasize.get(opp.id)==0 && opp.Es_Inactiva__c!=1&& (opp.FUNCION__c<>'Costumer Care' ||opp.FUNCION__c<>'Direccion MCM') ){
opp.addError('La Oportunidad debe tener al menos una punta.');
}

 

But when i test it, i get the error message using a user with Funcion Direccion MCM

 

So what i'm trying to do is to get the message when the user Funcion is not equal to Costumer or Direccion, whats is wrong? how can i add more than one OR in the if?

 

Thank you.

Greetings!

 

I have my page for upload files but i want to restrict the file type only for PDF or ZIP 

 

i have in code: 

 

<apex:inputFile accept=".zip,.pdf*" value="{!attach.body}" filename="{!attach.name}" required="True"/>

 

But on Iexplorer, Mozilla, Chrome and safari i can upload any type of files.

 

Thank you so much!

Greetings!

 

I have a problem with my if statement

 

I don't kow where i'm wrong i'm lost with many if lol

 

if (Clasificacion_comercial__c ="ON",if( text(SLA__r.Tipo_de_Edificio_que_Aplica__c )="ON",if (Clasificacion_comercial__c ="SOT",if( text(SLA__r.Tipo_de_Edificio_que_Aplica__c )="SOT",if (Clasificacion_comercial__c ="OTROS",if( text(SLA__r.Tipo_de_Edificio_que_Aplica__c )="OTROS", SLA__r.Name ,"SLA no asignado"),"SLA sin Asignar")))))

 

What i need is that if the clasificiacion comercial (from object1) is equal to tipo de edificio que aplica (from object2) i get the name from the object2

 

I'll really appreciate your help.

Greetings!

 

I have an email template for a custom object and is relatedToType="SLAyEdif__c" in this object I have a lookup field for the opp, so how can i display the product related list here too???

 

Thank you so much

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();
}
}

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();
}
}

greetings!

 

Is possible to compare to related list from the opp fi they are made with lookup fields? and if the result is false then reject the save or send a message to the user that the values are not the same?

 

Thank you"!!

Greetings!

 

I have a related list on the opp page to a custom object name Building with a lookup field, i have anohter custom object with a opp lookup field for a related list... so is there a way to pass the items from the building related list to the other related list when the user click on NEW???

 

Or is there an example of create a product selection list to use with custom objects?

 

Thank you much!

Greetings!

 

On the Opp i have a related list to a custom object, is there a way to pass another related list from the opp to that custo object??

Thank you so much.

Greetings!

 

Is there a way to count the records on a related list and put the count value in a field? 

Greetings!

 

I have and vf email template for my custom object where i have a lookup field to search for the Opportunity... but when i test the template i get the ID opp instead the name... is there a way to fix it???

Greetings!

 

I'll really appreciate your help if you can help me on how i can build a custom multi select picklist and for values, the name (records) from my custom object for example:

 

Object A

Name: test1

Name: test2

to N

 

The Multi Select Picklist values= test1, test2, to N

 

And add it for use it in my my opportunity page

 

Thank you !

Greetings!

 

I have a problem with the related list for a custom object i hope you can help me

 

I have a custom object called "sla", i have another custom object called "building", an object called "sla request"  and the Opp.

 

I need to make a related list in the opp so the user can request a sla, so i create another object called request, here in this object i have a lookup field to search for the opp, another to search for the SLA... but i need here a related list to include the building... but i only can get a related list with a button NEW, i don't need to create a new building i need to include the building that allready exists in sfdc... but i don't find the way to insert a button "Add"...

 

I would like to have something like the product selection page for the opp

 

 

I will really appreciate your help.

Greetings!

 

I have a problem with the related list for a custom object i hope you can help me

 

I have a custom object called "sla", i have another custom object called "building", an object called "sla request"  and the Opp.

 

I need to make a related list in the opp so the user can request a sla, so i create another object called request, here in this object i have a lookup field to search for the opp, another to search for the SLA... but i need here a related list to include the building... but i only can get a related list with a button NEW, i don't need to create a new building i need to include the building that allready exists in sfdc... but i don't find the way to insert a button "Add"...

 

I would like to have something like the product selection page for the opp

 

 

I will really appreciate your help.

Hello!

 

I have a vf page and 2 classes that register a record and 2 attachments...

 

The thing is scenario 1:

 

If i clic on save, and no attachments are selected, i get an error, but i don't know how or where are they specified as required.

 

Scenario 2:

 

if i capture all the fields and select the files... but the validation rules works on save... i don't see the files attached, if i correct the fields and clic again on saved... depends on wich browser i'm working... i get an id error or sometimes it is saved with the files.....

 

So what i would like to do is to see the error message and depend on the error, send message to the user, open another page or just show again the name of the files attached so the user don't try to select them again...

 

I know it is very difficult to understand but i can share screenshot and what i try to do

Greetings!

 

I have a custom object and a visualforce page for it.

 

On the page i would like to let the user create a new record and upload 2 files (2 attachments)

 

But i don't know how to catch the record id and then add the file to it....

 

Here is my code... I'll really appreciate your help.

 

Page:

 

<apex:page standardController="Arco__c" extensions="myArcoExtension,reCAPTCHA,AttachmentUploadController" title="Captura de Referenciados" showHeader="false" standardStylesheets="false">
    <apex:composition template="{!$Site.Template}">
        <apex:define name="body">
            <apex:form >

                <apex:messages id="error" styleClass="errorMsg" layout="table" style="margin-top:1em; background-color: #FF9300" />
                <apex:pageBlock title="" mode="edit" id="sider2_header" >
                    <apex:pageBlockButtons rendered="{!(verified)}">
                        <apex:commandButton value="Enviar" action="{!savearco}" />

                    </apex:pageBlockButtons>
                    <apex:pageBlockSection title="Programa de Referenciados" collapsible="true" columns="1"  >         

 
Por favor, captura los datos de la persona que referencias:
                        <apex:inputField value="{!Arco__c.Name}" label="Nombre (s)" required="True" style="width: 200px; height: auto; background-color:  #E0FFFF" styleclass="input"/>
                      <apex:inputCheckbox value="{!Arco__c.Aceptaci_n__c}"/>
 <apex:outputText value="Arco: "/><apex:inputText value="{!parentId}"/><br/>
        <apex:outputText value="Archivo:  "/><apex:inputFile value="{!attach.body}" filename="{!attach.name}"/><br/>
        <apex:commandButton value="Adjuntar" action="{!upload}"/>

 

Class

 

public class myArcoExtension
    {
   
      private final Arco__c webarco;
      public myArcoExtension(ApexPages.StandardController stdController)
      {
         webarco = (Arco__c)stdController.getRecord();
      }
      
        public myArcoExtension(){}
       
        public PageReference saveArco()
      {
         try {
         insert(webarco);
      }
        catch(System.DMLException e)
        {
             ApexPages.addMessages(e);
             return null;
        }
        PageReference p = Page.informacion_enviada;
        p.setRedirect(true);
       return p;
      }

 

ublic with sharing class AttachmentUploadController
{

    public AttachmentUploadController(ApexPages.StandardController controller) {

    }

    public String parentId {get;set;}
    public Attachment attach {get;set;}
 
    public AttachmentUploadController()
    {
        attach = new Attachment();
    }
 
    
    public ApexPages.Pagereference upload()
    {
       

        attach.ParentId = parentId;
        insert attach;
       
        return new ApexPages.Standardcontroller(attach).view();  
    }
}

Greetings!

 

I have a vfp web to lead, and i would like to order the fields in one column, in another add some videos but i'm not able to do that, someone can help me??? i'll really appreciate your help

 

 <apex:pageBlockSection title="Solicitud de Información" collapsible="true" columns="1" >         
   
         
                        <apex:inputField value="{!Lead.FirstName}" label="Nombre (s)" required="True" style="width: 200px; height: auto; background-color:  #E0FFFF" styleclass="input"/>
                        <apex:inputField value="{!Lead.LastName}" label="Apellido (s)" required="True" style="width: 200px; height: auto; background-color:  #E0FFFF" styleclass="input"/>
                        <apex:inputField value="{!Lead.Email}" required="True" style="width: 200px; height: auto; background-color:  #E0FFFF" styleclass="input"/>
                        <apex:inputField value="{!Lead.Phone}" required="True" style="width: 200px; height: auto; background-color:  #E0FFFF" styleclass="input"/>
                        <apex:inputField value="{!Lead.Company}" required="True" style="width: 200px; height: auto; background-color:  #E0FFFF" styleclass="input"/>

<apex:iframe width="420" height="315" src="http://www.youtube.com/embed/Qd8OtvSgal8"/>

................

Greetings!


Do you have an idea or example on how to create a report for specific chatter feed content??? for example create a report of some feed that include the word "Close Date" "Sign Contract" or things like that????

Greetings! i'm stuck trying to add the captcha to my visualforce page for web2lead... i'm not an expert with the code so i'll really appreciate some help.

 

I'm using this class for the captcha

 

001 public class reCAPTCHA {
002 
003     /* Configuration */
004 
005     // The API endpoint for the reCAPTCHA service
006     private static String baseUrl = 'https://www.google.com/recaptcha/api/verify';
007 
008     // The keys you get by signing up for reCAPTCHA for your domain
009     private static String privateKey = 'your_private_key';
010     public String publicKey {
011         get { return 'your_public_key'; }
012     }
013 
014     /* Implementation */
015     
016     // Simple form fields for the example form
017     public String myName { get; set; }
018     public String myEmail { get; set; }
019     
020     // Create properties for the non-VF component input fields generated
021     // by the reCAPTCHA JavaScript.
022     public String challenge {
023         get {
024             return ApexPages.currentPage().getParameters().get('recaptcha_challenge_field');
025         }
026     }
027     public String response  {
028         get {
029             return ApexPages.currentPage().getParameters().get('recaptcha_response_field');
030         }
031     }
032     
033     // Whether the submission has passed reCAPTCHA validation or not
034     public Boolean verified { get; private set; }
035     
036     public reCAPTCHA() {
037         this.verified = false;
038     }
039     
040     public PageReference verify() {
041         System.debug('reCAPTCHA verification attempt');
042         // On first page load, form is empty, so no request to make yet
043         if ( challenge == null || response == null ) {
044             System.debug('reCAPTCHA verification attempt with empty form');
045             return null;
046         }
047                     
048         HttpResponse r = makeRequest(baseUrl,
049             'privatekey=' + privateKey +
050             '&remoteip='  + remoteHost +
051             '&challenge=' + challenge +
052             '&response='  + response
053         );
054         
055         if ( r!= null ) {
056             this.verified = (r.getBody().startsWithIgnoreCase('true'));
057         }
058         
059         if(this.verified) {
060             // If they pass verification, you might do something interesting here
061             // Or simply return a PageReference to the "next" page
062             return null;
063         }
064         else {
065             // stay on page to re-try reCAPTCHA
066             return null;
067         }
068     }
069 
070     public PageReference reset() {
071         return null;
072     } 
073 
074     /* Private helper methods */
075     
076     private static HttpResponse makeRequest(string url, string body)  {
077         HttpResponse response = null;
078         HttpRequest req = new HttpRequest(); 
079         req.setEndpoint(url);
080         req.setMethod('POST');
081         req.setBody (body);
082         try {
083             Http http = new Http();
084             response = http.send(req);
085             System.debug('reCAPTCHA response: ' + response);
086             System.debug('reCAPTCHA body: ' + response.getBody());
087         } catch(System.Exception e) {
088             System.debug('ERROR: ' + e);
089         }
090         return response;
091     } 
092         
093     private String remoteHost {
094         get {
095             String ret = '127.0.0.1';
096             // also could use x-original-remote-host
097             Map<String, String> hdrs = ApexPages.currentPage().getHeaders();
098             if (hdrs.get('x-original-remote-addr')!= null)
099                 ret =  hdrs.get('x-original-remote-addr');
100             else if (hdrs.get('X-Salesforce-SIP')!= null)
101                 ret =  hdrs.get('X-Salesforce-SIP');
102             return ret;
103         }
104     }
105 }

 

And here is my web2lead vf page

 

<apex:page standardController="Lead" extensions="myWeb2LeadExtension" title="Interesado en Contratar Servicios de MCM" showHeader="false" standardStylesheets="true">    

  <apex:composition template="{!$Site.Template}">    

<apex:define name="body">  

    <apex:form >

      <apex:messages id="error" styleClass="errorMsg" layout="table" style="margin-top:1em; background-color: #FF9300" />     

    <apex:pageBlock title="" mode="edit" id="sider2_header">    

       <apex:pageBlockButtons >  

           <apex:commandButton value="Enviar" action="{!saveLead}" />        

   </apex:pageBlockButtons>     

      <apex:pageBlockSection title="Solicitud de Información" collapsible="true" columns="3" >              

       <apex:inputField value="{!Lead.FirstName}" label="Nombre (s)" required="True" style="width: 300px; height: auto; background-color:  #E0FFFF" styleclass="input"/>         

   <apex:inputField value="{!Lead.LastName}" label="Apellido (s)" required="True" style="width: 300px; height: auto; background-color:  #E0FFFF" styleclass="input"/>           

<apex:inputField value="{!Lead.Email}" required="True" style="width: 300px; height: auto; background-color:  #E0FFFF" styleclass="input"/>   

<apex:inputField value="{!Lead.Phone}" required="True" style="width: 300px; height: auto; background-color:  #E0FFFF" styleclass="input"/>

 <apex:inputField value="{!Lead.Company}" required="True" style="width: 300px; height: auto; background-color:  #E0FFFF" styleclass="input"/>

 <apex:inputField value="{!Lead.NumberOfEmployees}" Label="Número Aproximado de Empleados" style="width: 300px; height: auto; background-color:  #E0FFFF" styleclass="input"/>           

<apex:inputField value="{!Lead.Industry}" style="width: 300px; height: auto; background-color:  #E0FFFF" styleclass="input" />           

<apex:inputField value="{!Lead.Street}" style="width: 300px; height: auto; background-color:  #E0FFFF" styleclass="input"/>           

<apex:inputField value="{!Lead.City}" style="width: 300px; height: auto; background-color:  #E0FFFF" styleclass="input"/>           

<apex:inputField value="{!Lead.State}" style="width: 300px; height: auto; background-color:  #E0FFFF" styleclass="input"/>           

<apex:inputField value="{!Lead.PostalCode}" style="width: 300px; height: aut; background-color:  #E0FFFF" styleclass="input"/>   

 <apex:inputField value="{!Lead.ProductoInteres__c}" style="width: Auto; height: auto; background-color:  #E0FFFF" styleclass="input"/>

 <apex:inputField value="{!Lead.ProveedoresVozActual__c}" label="Proveedor Actual de Voz" style="width: Auto; height: auto;background-color:  #E0FFFF" styleclass="input"/>           

<apex:inputField value="{!Lead.ProveedoresDatosActual__c}" label="Proveedor Actual de Datos" style="width: Auto; height: auto;background-color:  #E0FFFF" styleclass="input" />

      

<apex:inputField value="{!Lead.Description}" Label="Comentarios" style="width: 300px; height: 600; background-color:  #E0FFFF" styleclass="input"/> </apex:pageBlockSection>

 

       </apex:pageBlock>     

</apex:form>    

</apex:define>  

  </apex:composition>

  </apex:page>

 

So i don't know where i need to star!!!

 

What i would like to do is, when load the page, hide the send button, add the captcha to the form... if the captcha is correct, then show the Send button and send the information to  salesforce, if the captcha is not valid then send a message to try again but without reload the page...

 

Again, thank you so much... and i'll really appreciate your help!!!

greetings!

 

I'm working in a trigger with the next sintax

 

if (opp.stagename=='Ganada' && mapPuntasize.get(opp.id)==0 && opp.Es_Inactiva__c!=1&& (opp.FUNCION__c<>'Costumer Care' ||opp.FUNCION__c<>'Direccion MCM') ){
opp.addError('La Oportunidad debe tener al menos una punta.');
}

 

But when i test it, i get the error message using a user with Funcion Direccion MCM

 

So what i'm trying to do is to get the message when the user Funcion is not equal to Costumer or Direccion, whats is wrong? how can i add more than one OR in the if?

 

Thank you.

Greetings!

 

I have my page for upload files but i want to restrict the file type only for PDF or ZIP 

 

i have in code: 

 

<apex:inputFile accept=".zip,.pdf*" value="{!attach.body}" filename="{!attach.name}" required="True"/>

 

But on Iexplorer, Mozilla, Chrome and safari i can upload any type of files.

 

Thank you so much!

Greetings!

 

I have a problem with my if statement

 

I don't kow where i'm wrong i'm lost with many if lol

 

if (Clasificacion_comercial__c ="ON",if( text(SLA__r.Tipo_de_Edificio_que_Aplica__c )="ON",if (Clasificacion_comercial__c ="SOT",if( text(SLA__r.Tipo_de_Edificio_que_Aplica__c )="SOT",if (Clasificacion_comercial__c ="OTROS",if( text(SLA__r.Tipo_de_Edificio_que_Aplica__c )="OTROS", SLA__r.Name ,"SLA no asignado"),"SLA sin Asignar")))))

 

What i need is that if the clasificiacion comercial (from object1) is equal to tipo de edificio que aplica (from object2) i get the name from the object2

 

I'll really appreciate your help.

Greetings!

 

I have an email template for a custom object and is relatedToType="SLAyEdif__c" in this object I have a lookup field for the opp, so how can i display the product related list here too???

 

Thank you so much

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();
}
}

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();
}
}

greetings!

 

Is possible to compare to related list from the opp fi they are made with lookup fields? and if the result is false then reject the save or send a message to the user that the values are not the same?

 

Thank you"!!

Greetings!

 

Is there a way to count the records on a related list and put the count value in a field?