• Javier Castro
  • NEWBIE
  • 50 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
Hi everyone,
I hope you can help me. I need to generate a JSON but the format i get it's not like I require.

I get:
"portalReformasNecesariasEdificio" : false,
"portalReformasNecesarias" : false,
"porcentajePropiedad" : 100.00,
"plazoContratoDatosOcupacionales" : null,
"plantas" : [ {
    "attributes" : {
      "type" : "HAY_Informe_Mediadores_Planta__c",
      "url" : "/services/data/v44.0/sobjects/HAY_Informe_Mediadores_Planta__c/a1G3E0000014zl0UAA"
    },
    "Id" : "a1G3E0000014zl0UAA",
    "HAY_Informe_Mediadores__c" : "a1i3E000000PvmrQAC",
    "HAY_Floor_Number__c" : 0,
    "HAY_Room_Type__c" : "01",
    "HAY_Room_Number__c" : 3
  }, {
    "attributes" : {
      "type" : "HAY_Informe_Mediadores_Planta__c",
      "url" : "/services/data/v44.0/sobjects/HAY_Informe_Mediadores_Planta__c/a1G3E0000014zl1UAA"
    },
    "Id" : "a1G3E0000014zl1UAA",
    "HAY_Informe_Mediadores__c" : "a1i3E000000PvmrQAC",
    "HAY_Floor_Number__c" : 0,
    "HAY_Room_Type__c" : "02",
    "HAY_Room_Number__c" : 1
  }],
//more fields

I need:
//fields
"plantas": [
        {
          "roomtype": "01",
          "roomnumber": "3",
          "floornumber": "0"
        },
        {
          "roomtype": "02",
          "roomnumber": "1",
          "floornumber": "0"
        },
        //etc
//more fields
I dont know how to get the result I need. I'm using a wrapper with the fields of the parent object and a list to save the child records and the JSON.SerializePretty method
class wrapper{
   //fields of the parent object {get; set;}
   List<Child__c> childs {get; set;}

   public wrapper(Parent__c parent, List<Child__c> listChilds){
     //parent fields = parent.field
     childs = listChilds
   }
}

class AnotherClass {
  //Logic to get parent data
  //Logic to get list of childs
  public method{
      String jsonBody = JSON.prettySerialize(new wrapper(parent, child),false);
  }
}

I hope you can help I'm not able to solve this.
Thanks in advance.
 
Hi everyone, I am working on a Lightning Component which has a lightning select with its values fetched dynamically from a picklist field.
 
<lightning:select aura:id="select" label="Estado de la cita" name="source" onchange="{!c.handleSelect}" class="slds-m-bottom_medium">
     <option value="" disabled="true" text="-- Selecciona Estado --"/>
     <option value="Todos" text="Todos"/>
     <aura:iteration var="stat" items="{!v.statusList}">
          <option value="{!stat}" text="{!stat}"/>
     </aura:iteration>
 </lightning:select>

I found on the Internet this solution but it's not working for me
doInit: function(cmp){
        
        var action = cmp.get("c.getStatus");
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            var statusList = response.getReturnValue();
            if(state == "SUCCESS"){
                cmp.set("v.statusList",statusList);
                window.setTimeout(
                $A.getCallback( function() {
                    cmp.find("select").set("v.statusList", statusList[1]);
                }));
            }
        });
        
        $A.enqueueAction(action);
    },
The cmp.find recover the value I want but then that value it's not setted as default.

Someone can help me?

Regards and thanks in advance
 
Hi everyone.

I hope you can help me. I'm working with a lightning component which has an aura iteration with another component inside.

My code:
 
<aura:iteration var="event" items="{!v.events}">
       <c:LC_Events event="{!event}"/>                
 </aura:iteration>

I would like to know if there is any way to limit the number of records displayed and make a kind of button to load more or show more like in list views or related lists because when I have very few records I have no problem but when I have many records I get a very long vertical scroll and this is I want to avoid.

Regards
 
Hi, I'm new in Salesforce and I'm making a visualforce:
I have this summarized visualforce code:
<!--The code is summarized, this is not my complete code-->

<div>
<apex:form id="tabla2">
        <apex:pageBlock >
          <apex:pageBlockTable value="{!lstCitas}" var="citas" styleClass="table table-hover">
            <apex:column value="{!citas.Name}"/>
            <apex:column value="{!citas.CloseDate}"/>
            <apex:column >
              <apex:commandButton value="My button" styleClass="btn btn-primary" action="{!mostrarCitaIndividualDoctor}" rerender="p1">
                  <apex:param name="nombre" value="{!citas.Name}" assignTo="{!nombre}"/>
                  <apex:param name="fecha" value="{!citas.CloseDate}" assignTo="{!fecha}"/>
              </apex:commandButton>
            </apex:column>
          </apex:pageBlockTable>
        </apex:pageBlock>
</apex:form>
</div>

<!--More code-->

<div id="p1">
<apex:form >
              <label>Nombre: {!nombreC}</label>
              <label>Fecha de cierre: {!fechaC}</label>
</apex:form>
</div>

And my summarized controller code:
 
public class controlador{

    public String nombre {get; set;}
    public String fecha {get; set;}
    public String nombreC {get; set;}
    public String fechaC{get; set;}
   
    /*More code*/

    public void mostrarCitaIndividualDoctor(){
        nombreC = this.nombre;
        fechaC = this.fecha;
    }

    /*More code*/
}
The table shows the values properly, when I click the button, I get the name and the date, and I show this values in the other div(p1). It works for the name but in the date I always get a null value.
I have tried to change to Date the varaible in the controller but it still doesn't work for me.

How can I get the date?

Thanks in advance.

 
Hi, I am new in Salesforce and now I am learning about lightning components.
I have this code:
<aura:component controller="AcordeonControlador"> 
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> 
    <aura:attribute name="lstAcc" type="List"/>
    <lightning:accordion>
        <aura:iteration items="{!v.lstAcc}" var="acc">
            <lightning:accordionSection name="{!acc.Name}" label="{!acc.Name}">
                <lightning:icon iconName="standard:account"/>
                <p>Telefono: {!acc.Phone}</p>
                <p>Dirección: {!acc.ShippingStreet}</p>
                <p>Ciudad: {!acc.ShippingCity}</p>
                <p>Estado: {!acc.ShippingState}</p>
                <p>Codigo postal: {!acc.ShippingPostalCode}</p>
                <p>Pais: {!acc.ShippingCountry}</p>
            </lightning:accordionSection>
        </aura:iteration>
    </lightning:accordion>   
</aura:component>
I would like to set the label of the accordionSection as: icon + text.
Is there any way to do this?
Thanks in advance.
 
Hi, I'm trying to pass values from a pageBlockTable to my custom controller, but something is not working properly and I don't what it is. I post my code below and I hope someone can help me.

Thanks in advance.

Visualforce code:
<div calss="modal-dialog" style="display:{!if(mostrarCitasPaciente,'block','none')};">
    <div class="tablemodal-container">
      <apex:form id="tabla">
        <apex:pageBlock >
          <apex:pageBlockTable value="{!lstCitas}" var="citas" styleClass="table table-hover">
            <apex:column value="{!citas.Name}"/>
            <apex:column value="{!citas.CloseDate}"/>
            <apex:column value="{!citas.Doctor__c}"/>
            <apex:column value="{!citas.Doctor__r.Especialidad__c}"/>
            <apex:column>
              <apex:commandButton value="Ver cita" action="{!mostrarCitaIndividualPaciente}">
                  <apex:param name="doctor" value="{!citas.Doctor__c}" assignTo="{!doctorCita}"/>
            	  <apex:param name="especialidad"  value="{!citas.Doctor__r.Especialidad__c}" assignTo="{!especialidadCita}"/>
                  <apex:param name="fecha" value="{!citas.CloseDate}" assignTo="{!fechaCita}"/>
              </apex:commandButton>
            </apex:column>
          </apex:pageBlockTable>
          <table class="table borderless" align="center">
            <tr>
              <td align="center">
                <apex:commandButton styleClass="btn btn-secondary" value="Primera pagina" reRender="tabla" action="{!primeraPagina}" disabled="{!Ant}"/>
                <apex:commandButton styleClass="btn btn-secondary" value="Pagina anterior" reRender="tabla" action="{!anterior}" disabled="{!Ant}"/>
                <apex:commandButton styleClass="btn btn-secondary" value="Pagina siguiente" reRender="tabla" action="{!siguiente}" disabled="{!Sig}"/>
              </td>
            </tr>
          </table>
        </apex:pageBlock>
      </apex:form>
    </div>
  </div>

<div class="modal-dialog" >
    <div class="tablemodal-container">
      <table align="center" id="RID">
        <tr>
          <td align="left"><apex:outputLabel value="Doctor"/></td>
          <td align="center"><apex:outputLabel value="Especialidad"/></td>
          <td align="right"><apex:outputLabel value="Fecha"/></td>
        </tr>
        <tr>
          <td>{!doctorC}</td>
          <td>{!especialidadC}</td>
          <td>{!fechaC}</td>
        </tr>
      </table>
    </div>
  </div>

Controller code:
 
public class controlador{

    public String doctorCita{ get; set; }
    public String especialidadCita{ get; set; }
    public String fechaCita{ get; set; }
    public String doctorC{ get; set; }
    public String especialidadC{ get; set; }
    public String fechaC{ get; set; }

public void obtenerCitaIndiviudalPaciente(){
        
        doctorC = this.doctorCita;
        especialidadC = this.especialidadCita;
        fechaC = this.fechaCita;

//My logic

 }

}

My second div is displayed but I always get null in my params. If I put a reRender attribute on the command button I get the correct values in my params but the second div is not displayed.
Hi everyone, I am working on a Lightning Component which has a lightning select with its values fetched dynamically from a picklist field.
 
<lightning:select aura:id="select" label="Estado de la cita" name="source" onchange="{!c.handleSelect}" class="slds-m-bottom_medium">
     <option value="" disabled="true" text="-- Selecciona Estado --"/>
     <option value="Todos" text="Todos"/>
     <aura:iteration var="stat" items="{!v.statusList}">
          <option value="{!stat}" text="{!stat}"/>
     </aura:iteration>
 </lightning:select>

I found on the Internet this solution but it's not working for me
doInit: function(cmp){
        
        var action = cmp.get("c.getStatus");
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            var statusList = response.getReturnValue();
            if(state == "SUCCESS"){
                cmp.set("v.statusList",statusList);
                window.setTimeout(
                $A.getCallback( function() {
                    cmp.find("select").set("v.statusList", statusList[1]);
                }));
            }
        });
        
        $A.enqueueAction(action);
    },
The cmp.find recover the value I want but then that value it's not setted as default.

Someone can help me?

Regards and thanks in advance
 
Hi everyone.

I hope you can help me. I'm working with a lightning component which has an aura iteration with another component inside.

My code:
 
<aura:iteration var="event" items="{!v.events}">
       <c:LC_Events event="{!event}"/>                
 </aura:iteration>

I would like to know if there is any way to limit the number of records displayed and make a kind of button to load more or show more like in list views or related lists because when I have very few records I have no problem but when I have many records I get a very long vertical scroll and this is I want to avoid.

Regards
 
Hi, I'm new in Salesforce and I'm making a visualforce:
I have this summarized visualforce code:
<!--The code is summarized, this is not my complete code-->

<div>
<apex:form id="tabla2">
        <apex:pageBlock >
          <apex:pageBlockTable value="{!lstCitas}" var="citas" styleClass="table table-hover">
            <apex:column value="{!citas.Name}"/>
            <apex:column value="{!citas.CloseDate}"/>
            <apex:column >
              <apex:commandButton value="My button" styleClass="btn btn-primary" action="{!mostrarCitaIndividualDoctor}" rerender="p1">
                  <apex:param name="nombre" value="{!citas.Name}" assignTo="{!nombre}"/>
                  <apex:param name="fecha" value="{!citas.CloseDate}" assignTo="{!fecha}"/>
              </apex:commandButton>
            </apex:column>
          </apex:pageBlockTable>
        </apex:pageBlock>
</apex:form>
</div>

<!--More code-->

<div id="p1">
<apex:form >
              <label>Nombre: {!nombreC}</label>
              <label>Fecha de cierre: {!fechaC}</label>
</apex:form>
</div>

And my summarized controller code:
 
public class controlador{

    public String nombre {get; set;}
    public String fecha {get; set;}
    public String nombreC {get; set;}
    public String fechaC{get; set;}
   
    /*More code*/

    public void mostrarCitaIndividualDoctor(){
        nombreC = this.nombre;
        fechaC = this.fecha;
    }

    /*More code*/
}
The table shows the values properly, when I click the button, I get the name and the date, and I show this values in the other div(p1). It works for the name but in the date I always get a null value.
I have tried to change to Date the varaible in the controller but it still doesn't work for me.

How can I get the date?

Thanks in advance.

 
Hi, I am new in Salesforce and now I am learning about lightning components.
I have this code:
<aura:component controller="AcordeonControlador"> 
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> 
    <aura:attribute name="lstAcc" type="List"/>
    <lightning:accordion>
        <aura:iteration items="{!v.lstAcc}" var="acc">
            <lightning:accordionSection name="{!acc.Name}" label="{!acc.Name}">
                <lightning:icon iconName="standard:account"/>
                <p>Telefono: {!acc.Phone}</p>
                <p>Dirección: {!acc.ShippingStreet}</p>
                <p>Ciudad: {!acc.ShippingCity}</p>
                <p>Estado: {!acc.ShippingState}</p>
                <p>Codigo postal: {!acc.ShippingPostalCode}</p>
                <p>Pais: {!acc.ShippingCountry}</p>
            </lightning:accordionSection>
        </aura:iteration>
    </lightning:accordion>   
</aura:component>
I would like to set the label of the accordionSection as: icon + text.
Is there any way to do this?
Thanks in advance.
 
Hi, I'm trying to pass values from a pageBlockTable to my custom controller, but something is not working properly and I don't what it is. I post my code below and I hope someone can help me.

Thanks in advance.

Visualforce code:
<div calss="modal-dialog" style="display:{!if(mostrarCitasPaciente,'block','none')};">
    <div class="tablemodal-container">
      <apex:form id="tabla">
        <apex:pageBlock >
          <apex:pageBlockTable value="{!lstCitas}" var="citas" styleClass="table table-hover">
            <apex:column value="{!citas.Name}"/>
            <apex:column value="{!citas.CloseDate}"/>
            <apex:column value="{!citas.Doctor__c}"/>
            <apex:column value="{!citas.Doctor__r.Especialidad__c}"/>
            <apex:column>
              <apex:commandButton value="Ver cita" action="{!mostrarCitaIndividualPaciente}">
                  <apex:param name="doctor" value="{!citas.Doctor__c}" assignTo="{!doctorCita}"/>
            	  <apex:param name="especialidad"  value="{!citas.Doctor__r.Especialidad__c}" assignTo="{!especialidadCita}"/>
                  <apex:param name="fecha" value="{!citas.CloseDate}" assignTo="{!fechaCita}"/>
              </apex:commandButton>
            </apex:column>
          </apex:pageBlockTable>
          <table class="table borderless" align="center">
            <tr>
              <td align="center">
                <apex:commandButton styleClass="btn btn-secondary" value="Primera pagina" reRender="tabla" action="{!primeraPagina}" disabled="{!Ant}"/>
                <apex:commandButton styleClass="btn btn-secondary" value="Pagina anterior" reRender="tabla" action="{!anterior}" disabled="{!Ant}"/>
                <apex:commandButton styleClass="btn btn-secondary" value="Pagina siguiente" reRender="tabla" action="{!siguiente}" disabled="{!Sig}"/>
              </td>
            </tr>
          </table>
        </apex:pageBlock>
      </apex:form>
    </div>
  </div>

<div class="modal-dialog" >
    <div class="tablemodal-container">
      <table align="center" id="RID">
        <tr>
          <td align="left"><apex:outputLabel value="Doctor"/></td>
          <td align="center"><apex:outputLabel value="Especialidad"/></td>
          <td align="right"><apex:outputLabel value="Fecha"/></td>
        </tr>
        <tr>
          <td>{!doctorC}</td>
          <td>{!especialidadC}</td>
          <td>{!fechaC}</td>
        </tr>
      </table>
    </div>
  </div>

Controller code:
 
public class controlador{

    public String doctorCita{ get; set; }
    public String especialidadCita{ get; set; }
    public String fechaCita{ get; set; }
    public String doctorC{ get; set; }
    public String especialidadC{ get; set; }
    public String fechaC{ get; set; }

public void obtenerCitaIndiviudalPaciente(){
        
        doctorC = this.doctorCita;
        especialidadC = this.especialidadCita;
        fechaC = this.fechaCita;

//My logic

 }

}

My second div is displayed but I always get null in my params. If I put a reRender attribute on the command button I get the correct values in my params but the second div is not displayed.