I have a visualforce page that represents a contract document, which I'm exporting as .doc file.
This visualforce page's controller makes a query to get some of the fields of the contract record. Then, in my VF page (with inner components) I build a huge contract text using those fields. For some reason though, the only one that actually displays correctly is StartDate, but I'm having problems with all the other fields, including some standard fields (for example, CustomerSigned) and custom fields. All of the text fields render as blank spaces, and all the number fields render as 0.00 (even if the fields have values).
Notes:
- I've tried with apex:outputField and apex:outputText and displaying the field directly, with no luck.
- I've tried adding the rendered attribute checking that the variable has been assigned with the record, like
rendered="{!contract != null}"
- I added a Sytem.debug after the query to see if all the fields are alright, and they are.
- I checked if the user I'm testing has the read permissions for all the fields (it does, as I'm in a sandbox using the admin user)
- I inspected the rendered HTML and I can see the inserted for the fields, but no value present.
This is the beginning of the first sentence of the document:
As you can see, the date field can be seen, but then the other fields are not rendered, just blank spaces.
This is the inspected HTML:
In the rendered HTML, we can see the span element for the date with the right value, and then the other two spans for the other two fields, but with no value inside.
I looked for similar issues online but I've tried anything... At first I thought that the problem was changing the content type to msword, but when removing that and visualizing the visualforce page on salesforce, the issue persists. Any help would be appreciated!
This is the code for the first sentence of the document:
<p>
En la ciudad de Punta del Este, el <apex:outputField value="{!contrato.StartDate}" />, comparece el Sr <apex:outputField value="{!contrato.CustomerSigned.Name}" />, con Documento de Identidad <apex:outputField value="{!contrato.Documento_Tipo__c}" rendered="{!contrato.Documento_Tipo__c != null}"/> <apex:outputField value="{!contrato.Documento_Nro__c}" /> de Nacionalidad <apex:outputField value="{!contrato.Nacionalidad__c}" />, con domicilio físico en <apex:outputField value="{!contrato.Domicilio__c}" />, Uruguay, y domicilio electrónico <apex:outputField value="{!contrato.Email__c}" />, Móvil <apex:outputField value="{!contrato.Telefono__c}" /> en adelante el "Reservante" y por la otra parte INMOBILIARIA Horus Group con domicilio en Edificio Stradivarius apto 1605, Punta del Este, representada en este acto por el señor Darwin Scrollini, con cédula de identidad número Ci 3672709-2/ HHO BROKER Real Estate con domicilio en Av. Roosevelt Pda.1, Biarritz esq, Tabaré, Punta del Este, representada en este acto por el señor <apex:outputText value="{!contrato.Contacto_Inmobiliaria__r.Name}" />, con cédula de identidad número <apex:outputText value="{!contrato.Cedula_Inmobiliaria__c}" /> en adelante la "Inmobiliaria".- AMBAS PARTES CONVIENEN CELEBRAR LA PRESENTE RESERVA (en adelante, la "Reserva"):
</p>
Controller code:
public with sharing class DocumentoContratoController {
public String contractId;
public Contract contrato {get;set;}
public String customerSignedName {get;set;}
public DocumentoContratoController() {}
public DocumentoContratoController(ApexPages.StandardController stdCon){
contractId = stdCon.getId();
init();
}
public void init(){
contrato = [SELECT Id,
RecordType.Name,
Edificio__c,
StartDate,
CustomerSigned.Name,
Documento_Tipo__c,
Nacionalidad__c,
Domicilio__c,
Email__c,
Telefono__c,
Contacto_Inmobiliaria__r.Name,
Cedula_Inmobiliaria__c,
Precio_Reserva__c,
Medios_de_pago__c,
Unidad__c,
Piso__c,
Unidad_Catastral__c,
Piso_Real__c,
Superficie_total_m2__c,
Precio_final_del_apartamento__c,
Compromiso__c,
A_pagar_en_cuotas__c,
Cantidad_de_cuotas__c,
Monto_de_la_Cuota__c,
Saldo__c,
Porcentaje_Alhajamiento__c,
Comision_Inmobiliaria__c,
Inmobiliaria__r.Name,
Direccion_Inmobiliaria__c,
Estado_Civil__c
FROM Contract
WHERE Id = :contractId];
System.debug(contrato);
System.debug(contrato.CustomerSigned.Name);
}
public Integer getCantCuotasMenos(){
return Integer.valueOf(contrato.Cantidad_de_cuotas__c - 1);
}
public Boolean getIsReservaAtelier(){
return contrato.Edificio__c == 'ATELIER' && contrato.RecordType.Name == 'Reserva';
}
public Boolean getIsReservaLeParc(){
return (contrato.Edificio__c == 'Le Parc Punta del Este - Torre IV' || contrato.Edificio__c == 'Le Parc Punta del Este - Torre III') && contrato.RecordType.Name == 'Reserva';
}
public Boolean getIsCompromisoLeParc(){
return (contrato.Edificio__c == 'Le Parc Punta del Este - Torre IV' || contrato.Edificio__c == 'Le Parc Punta del Este - Torre III') && contrato.RecordType.Name == 'Compromiso';
}
public Decimal getSuperficieRedondeada(){
return Decimal.valueOf(contrato.Superficie_total_m2__c).round();
}
public String getDocumentoTipo(){
return contrato.Documento_Tipo__c;
}
}
<apex:outputField>s
and no other markup, do they display? Is the VFP bound to the controller you posted?contrato