• Jose María Nicolás Arfelis
  • NEWBIE
  • 50 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 37
    Replies
Hi all,

I am trying to cover some lines in my controller apex class, but since hours dealing with the error message:
 
Expecting colon, found 'TestPostgrado1'.
The method I am trying to cover through my controller test class is this (method in my controller):
 
public list<Product2> getProgramsFromListId(String listId){
    list<Product2> listProgramas = new list<Product2>();
    String query = 'Select Id, Name from Product2 where Id In ' + listId ; 
    listProgramas = Database.query(query);
    return listProgramas;
}
In order to cover that part I have written these lines in my code on the controller test class:
 
Product2 postgrado1 =  new Product2(Name = 'TestPostgrad1');
insert postgrado1;

Product2 postgrado2 =  new Product2(Name = 'TestPostgrad2');
insert postgrado2;

List<Product2> postgrados = new List<Product2> ();
postgrados.add(postgrado1);
postgrados.add(postgrado2);
        
        //List<Product2> listProgramas = new list<Product2>();
        //listProgramas.add(postgrado.Name);
  
controller.getProgramsFromListName(postgrado1.Name);
ok, I know postgrado1.Name is not correct, I was trying with several variants, but nothing happens, the errors is still being displayed.
I tend to think that it has to do with the "IN" in the SELECT statement in the controller method,

Does anybody know, what I am doing wrong or what is missing in the lines in my test class?. The errors are pointing to the line
 
controller.getProgramsFromListName(postgrado1.Name);
in my controller test class.

and to the line
 
listProgramas = Database.query(query);
I would appreciate any help.





 
Hi all,

I have the requirement to get a field autopopulated according to the value of another field.
For example, I have the parent object Postgraduate Course. This has the related list Questions (Preguntas):

The Question object has a lookup to the Postgraduate Course.
To distinguish among postgraduate courses with the same name, we use one field: the Edition of the Postgraduate Course.

The Question edit mode looks like this:

User-added image

For example, if the Postgraduate Course is SEGURIDAD CLINICA and the Edition of that Postgraduate Course is 2017-2018, when you click on the button New on the related object Questions, the field Edtion on this object should be autopopulated with the value in the field Edition of the Postgraduate Course, being in Edit Mode, so our client can recognize for which Postgraduate Course he will add a question.

Is something like that possible in Salesforce?.
Hi all,

I hope that somebody answers my question as I am making efforts to describe what my problem is. I am trying to solve this without success.
I would like to autopopulate two lookup fields when I press the button New on a related list.

Matriculaci_n__c is the object where the related list Títulos is to find. The object is T_tulo__c.
I would like to add a button New on the related list Titulos, in order to get to the detail page where I can find two lookups autopopulated with the Postgraduate Course (Programa_acad_mico_1__c) and the Name of the Applicant (Cuenta_de_Alumno__c) mentioned in the Matriculaci_n__c object.

For this I built the following Apex Code:
 
public with sharing class SobreescribeTituloNuevo {
    
 public SobreescribeTituloNuevo(ApexPages.StandardController controller) {
    }
    public Pagereference onLoad(){
        PageReference newPage = new PageReference('/a10/e?');
        String TituloId;
        for(String keyValue : ApexPages.currentPage().getParameters().keySet()){
            if(!keyValue.contains('override') ){
                newPage.getParameters().put(keyValue, ApexPages.currentPage().getParameters().get(keyValue));
                if(keyValue.contains('retURL')) {
                  TituloId = ApexPages.currentPage().getParameters().get('retURL');
                }
            }
        }
        system.debug(TituloId);
        TituloId =  TituloId.removeStart('/');
        if(TituloId.length() >= 15) {
        Matriculaci_n__c objMatriculacion = [Select Id, Programa_acad_mico_1__c, Programa_acad_mico_1__r.Name, Cuenta_de_Alumno__c, Cuenta_de_Alumno__r.Name from Matriculaci_n__c where Id =: TituloId];
            newPage.getParameters().put('00N3E000000QaTd_lkid', objMatriculacion.Programa_acad_mico_1__c);
            newPage.getParameters().put('00N3E000000QaTd', objMatriculacion.Programa_acad_mico_1__r.Name);
			newPage.getParameters().put('00N3E000000XmQ3_lkid', objMatriculacion.Cuenta_de_Alumno__c);
			newPage.getParameters().put('00N3E000000XmQ3', objMatriculacion.Cuenta_de_Alumno__r.Name);
            newPage.getParameters().put('nooverride','1');
        }
        else {
            newPage.getParameters().put('nooverride','0');
        }
        return newPage.setRedirect(true);
    }
}
My Visualforce page looks like this:
 
<apex:page standardController="T_tulo__c" extensions="SobreescribeTituloNuevo" action="{!onLoad}">
</apex:page>
When I try to create a button for the related list Títulos, the Content field doesn't display anything, does anybody know why?. I already tried with many of the supposed solutions given in the internet, but none works for me, and I don't know where else do I have to change something or where is the mistake here.

User-added image
The IDs are here on this page fictitious.

As you see the Content field is not shown, can please somebody help me? :(.

 
Hi all,

there is a strange behavior regarding sending automatic emails via Salesforce and using templates based on Visualforce and HTML.
When I send an email with a link, this link appears correctly when the email goes to Gmail, but not when going to Hotmail or my client's email address.
When it goes to Hotmail it appears like:

User-added image
When it goes to my client's email address, the link is displayed this way:

User-added image

On Gmail:

User-added image
The code on the email template invoking that link is:
 
<tr>
     
        <td style="text-align:justify;padding: 20px 0 5px 0;padding: 20px 0 30px 0;color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
          <c:email_solicitud_contacto intencion="{!relatedTo}" language_sc="Es"/>     
        </td>
     
     </tr>
The code in the component email_solicitud_contacto is:
 
<apex:component controller="email_solicitud_contacto_controller" id="emailProgramasComponent" access="global">

    <apex:attribute name="intencion" description="La intención de estudio" type="Intencion_de_estudios__c" />
    <apex:attribute name="language_sc" description="El idioma de la solicitud" type="String" assignto="{!language}" />
    <ul>
        <apex:outputpanel rendered="{!language=='Es'}">
            <li><a href="{!intencion.Producto__r.Enlace_Web__c}">{!intencion.Producto__r.Name} ( {!intencion.Producto__r.Edicion_de_Postgrado__c} )</a></li>
        </apex:outputpanel>
        <apex:outputpanel rendered="{!language=='En'}">
            <li><a href="{!intencion.Producto__r.Enlace_Web__c}">{!intencion.Producto__r.Nombre_de_curso_en_ingles__c} ( {!intencion.Producto__r.Edicion_de_Postgrado__c} )</a></li>
        </apex:outputpanel>
        <apex:outputpanel rendered="{!language=='Cat'}">
            <li><a href="{!intencion.Producto__r.Enlace_Web__c}">{!intencion.Producto__r.Nombre_de_curso_en_catalan__c} ( {!intencion.Producto__r.Edicion_de_Postgrado__c} )</a></li>
        </apex:outputpanel>
    </ul>

</apex:component>
Is there something wrong? how can I apply responsiveness here so the link appears the same for all Email Accounts?.
Please people, I need your help, I am realy doing efforts writing this thread, attaching screenshots, codes, so I would appreciate somebody gives me some light here.





 
Hi all,

I would like to create a Trigger Handler invoking an Account record type, but after some research and test I couldn't find the way to invoke a specific record type and fields of that record type in APEX. The name of the Account record type I am talking about is "Profesores". Here is my code:
 
public with sharing class ProfesorEventoTriggerHandler {

  @future 
  public static void ProcesaProfesoresAsync(Set<ID> eventoIds){

    // recoge el map del evento id y de los profesores sepprevados por punto y coma a construir
    Map<Id, String> eventoProfesorMap = new Map<Id, String>();
    //RecordType RecType = [Select Id From RecordType Where SobjectType = 'Account' and DeveloperName = 'Profesores'];

    // consigue TODOS los profesores para todos los eventos afectados de tal modo que podamos construir
    List<Relacion_Profesor_Evento__c> eventoProfesores = [select id, Evento__c, RecType.Id
      Account.Name from Relacion_Profesor_Evento__c 
      where Evento__c IN :eventoIds order by Account.Name];

    for (Relacion_Profesor_Evento__c prev : eventoProfesores) {
      if (!eventoProfesorMap.containsKey(prev.Evento__c)) {
        // si el key del evento no existe, agregarlo con nombre del profesor
        eventoProfesorMap.put(prev.Evento__c,prev.Account.Name);
      } else {
        // si el key del evento ya existe, agregar ", 
        // if the key (account) already exist, add "; nombre del profesor"
        eventoProfesorMap.put(prev.Evento__c,eventoProfesorMap.get(prev.Evento__c) + 
          ', ' + prev.Account.Name);
      }
    }

    // consigue los eventos que fueron afectados
    List<Evento__c> eventos = [select id from Evento__c where Id IN :eventoIds];

    // agrega la lista de profesores separados por punto y coma
    for (Evento__c ev : eventos)
      ev.Account = eventoProfesorMap.get(ev.id);

    // actualiza los eventos
    update eventos;

  }  

}
Account.Name should be for example something like this "get the value in field Name of the Record type "Profesores" of the object Account".

Can please somebody help me as I am stuck here since hours?.

Regards
 
Hi all,

as I am a newbie in the programming world in Salesforce, I would like to know, which kind of codes in Salesforce need a "Test" part?.
Til now, I know Triggers need it, which other types of Codes need a "Test" part.

I would appreciate your answers.

Best regards.

 
Hi all,

we have an email template built with Visualforce with "relatedToType="ObjectA__c":
 
<messaging:emailTemplate subject="Answer to your Request for Information" recipientType="Contact" relatedToType="ObjectA__c">
ObjectA was created to store all Resquests for Informations coming to Salesforce from the university web.

On the other hand, ObjectB was created to store all links the university, our client, has.
For ObjectB these fields were created: Name of Link, URL of Link.

ObjectA and ObjectB have no relationship, means, no Master-Detail and no Lookup.

However, I would like to refer to the field URL of the Link of ObjectB in the email template this way:
 
<messaging:emailTemplate subject="Answer to your Request for Information" recipientType="Contact" relatedToType="ObjectA__c">
...
<apex:outputLink value="{!IF(ObjectB__r.Name_of_Link__c = 'URL Admission Form', '{!ObjectB__r.URL_of_Link__c}', '')}" id="Admission">Admission Form</apex:outputLink>

...
The objective is for future manual changes in the value of the field URL of Link, to do these changes directly in the tab for ObjectB and not in the email template.

I tried using the code above, but it doesn't work.
Even refering to a formula field doesn't work.

I would appreciate your tips as I am struggling hours and hours trying to solve this :(.
Hi all,

down vote favoritewe have the object Preinscripción containing records about which Postgraduate course someone applied for and paid. It contains the Name of the Applicant, the Postgraduate Course, the Identification Number, Status of the Preinscripción and a checkbox indicating whether a record with the same values Name of Applicant, Postgraduate Course and Identification Number exists or not in another object, the object Admission.
For example, let's say I have a record with data Name Pepe Flores, Postgraduate Course Cardiovascular Medicine, ID Number 1234567 in the object Preinscripción, if these values are also contained in the same fields in the object Admission, the checkbox should automatically be checked or populated.
Is it possible to make that work? is coding needed?.
Email service address is too long for something I ma trying to implement.  I need it below 64 characters.  Is there a way to shorten the email service address besides before the @