• Ignacio de la Torre 3
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
Hi all !

I need to beautify this VF page so that the 'Nombre de Pago' output field is above the 'Importe' field but in the same line, not like now see? I need the fields to be nicely aligned and I'm not being able to do so. I've added some <br></br> tags but still ugly:

User-added image

When the user clicks the Add Row button a new record row is added but not aligned with the rest of the lines.

Any idea how to fix it ?

Here's the VF page code:
 
<apex:page standardController="Cuadre__c" extensions="insertParentChildCon" lightningStylesheets="true" showHeader="false" sidebar="false">
    
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton action="{!QuikSave}" value="Quik Save"/>
                <apex:commandButton action="{!Save}" value="Save"/>
                <apex:commandButton action="{!Cancel}" value="Cancel"/>                
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Cuadre">
                <apex:outputField value="{!Cuadre__c.Name}"/>
                <apex:outputField value="{!Cuadre__c.PendienteCobro__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Agregar pagos al cuadre">                   
                <apex:repeat value="{!pagoList}" var="pg" id="table">
                    <br></br>
                    <br></br>                    
                    <apex:inputField value="{!pg.Name}"/>                    
                    <apex:inputField value="{!pg.Tipo__c}"/>
                    <apex:inputField value="{!pg.Importe__c}"/>
                    <apex:inputField value="{!pg.FormaPago__c}"/>
                    <br></br>
                    <br></br>
                    <br></br>
                </apex:repeat>                
            </apex:pageBlockSection>
            <apex:commandButton value="Add Row" Action="{!AddRow}" immediate="true" id="button"/> 
            
        </apex:pageBlock>
    </apex:form>

</apex:page>

 
Hi all !

I have this two related object Cuadre__c and Pago__c being Cuadre the parent of Pago in a master detail relationship.

I have a requirement where the user needs to click a button from the Cuadre layout and a Visualforce page will launch showing all the related Pago__c to that Cuadre__c object.

Then if the user clicks and 'Add Line' button a new Pago__c record line appears so the user can create a new Pago__c record.

The user can the click a 'Save' button to save one or many created Pago__c records in the above "table" and insert those Pago__c records that should be related to the Cuadre__c object from where the page was launched.

This last part is not working .... when the user clicks the save button the Pago__c record is not created or related to the Cuadre__c record where the page was launched and I need help solving this.

This is my code:

VF page:
<apex:page standardController="Cuadre__c" extensions="insertParentChildCon" lightningStylesheets="true" showHeader="false" sidebar="false">
    
    <apex:form>
        <apex:pageBlock>
            <apex:pageBlockButtons location="top">
                <apex:commandButton action="{!Save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Agregar pagos al cuadre">
                <apex:repeat value="{!pagoList}" var="pg" id="table">
                    <br></br>
                	<br></br>
                    <apex:inputField value="{!pg.Name}"/>
                    <apex:inputField value="{!pg.Tipo__c}"/>
                    <apex:inputField value="{!pg.Importe__c}"/>
                    <apex:inputField value="{!pg.FormaPago__c}"/>
                    <br></br>
                	<br></br>
            		<br></br>
                </apex:repeat> 
            </apex:pageBlockSection>
            <apex:commandButton value="Add Row" Action="{!AddRow}" immediate="true" id="button"/> 
            
        </apex:pageBlock>
    </apex:form>

</apex:page>

and this is the controller:
 
public class insertParentChildCon { 
    
    ApexPages.StandardController sc;
    Id cuId;   
    public List<Pago__c> pagoList { get; set; }
    
    public insertParentChildCon(ApexPages.StandardController sc){
        this.sc = sc;
        cuId = sc.getId();
        
        pagoList = [SELECT ID, Tipo__c, Name, FormaPago__c, Importe__c FROM Pago__c WHERE Cuadre__c =: cuId ];
    }
    
    
    public PageReference AddRow(){
        pagoList.add(new Pago__c(Cuadre__c = cuId));
        return null;
    } 
    
    public PageReference Save(List<Pago__c> pagoList){
        
        for(Pago__c pago : pagolist) {
            pago.Cuadre__c = cuId;
        }
        
        if(pagoList != null){ 
            upsert pagoList;
        }
        
        return null;
    } 
}

Please help me ;)
 
Hi all and thanks for reading!
I'm trying to test this class which uses some custom metadata and I'm having lots of trouble with it:
 
public class SendingSAPServices {
    
    public static final String SERVICE_SYNC_CLIENTE = 'SYNC_CLIENTE';
    public static final String SERVICE_SYNC_SEDE = 'SYNC_SEDE';
    public static final String SERVICE_SYNC_MATERIAL = 'SYNC_MATERIAL';
    public static final String SERVICE_SYNC_PEDIDO = 'SYNC_PEDIDO';
   
	public static void saveBy(List<Account> accounts){   
        
        List<SendingSAP__c> sendingsToInsert = new List<SendingSAP__c>();
        ConfiguracionServiceSAP__mdt confService = getConfiguracionService(SERVICE_SYNC_CLIENTE);
        //accounts.get(0).addError('error 1: ' + confService);
        if(confService != null){
            for(Account account : accounts){
                SendingSAP__c sending = getNew(confService, 'Account__c', account);
                sending.Request__c = SAPServices.getClienteSAPToSync(account);
                sendingsToInsert.add(sending);
            }
            insert sendingsToInsert;
            setLastSendingSAP(sendingsToInsert, accounts, 'Account__c');
        }
    }

This is the test class I've wrote so far:
 
@isTest
public class AccountTriggerHandlerTest {
    
    @testSetup public static void testSetup(){
        


        Account firstAccount = new Account();
        firstAccount.Name = 'First Account';
        firstAccount.SAPStatus__c = 'Pending SAP';
        firstAccount.CodigoCliente__c = '26000000';
        firstAccount.IsNew__c = true;
        insert firstAccount;
        
        Account secondAccount = new Account();
        secondAccount.Name = 'Second Account';
        secondAccount.SAPStatus__c = 'New';
        secondAccount.CodigoCliente__c = '66000000';
        secondAccount.IsNew__c = false;
        insert secondAccount;
    }
    
    @isTest public static void testAccount(){
        
        Test.startTest();
        
        ConfiguracionServiceSAP__mdt confService = [SELECT DeveloperName, MasterLabel, ServiceName__c 
                                                    FROM ConfiguracionServiceSAP__mdt 
                                                    WHERE ServiceName__c  = 'SYNC_CLIENTE' 
                                                    AND DeveloperName = 'DESARROLLO_SYN_CLIENTE'];
        
        Account firstAcc = [SELECT Name from Account WHERE Name = 'First Account'];
        Account secondAcc = [SELECT Name from Account WHERE Name = 'Second Account'];
        secondAcc.SAPStatus__c = 'Pending SAP';
        update secondAcc;
        
        Test.stopTest();

    }
}

This is the pictures of the Custom Metadata I'm using:

User-added imageUser-added image

but when I run the test the class get covered until here
 
if(confService != null){

and then it's all red ....

I need confService to be different to null so I can keep on testing but I don't know how to do this.
I've been googleing lots and lots and read heaps of documentation but I'm unable to solve it ... I'm new to Salesforce in general.

Any help would be more than appreciated.

Thanks for reading​​​​​​​