You need to sign in to do that
Don't have an account?
Amidou Cisse
Display a list of data then select a line (from object: LigneOffre__c) which updates the details (Object: Insertion__c) in line with the chosen line.
//VF page :: <apex:page standardController="Insertion__c" extensions="VC06_0_Insertion_TarifsPresse" Title="Tarifs Presse" showHeader="true" sidebar="true" showQuickActionVfHeader="false"> <script> function redirectToInsPage(errMessageParam){ if(errMessageParam == ''){ window.top.location = '/lightning/r/Insertion__c/' + '{!insertionRecord.id}' + '/view'; }else{ alert(errMessageParam); } } </script> <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="x-ua-compatible" content="ie=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <apex:slds /> </head> <body> <div class="slds-scope"> <apex:form styleClass="slds-form--stacked"> <apex:pageMessages id="pageMessageId"> </apex:pageMessages> <br/> <div class="slds-form-element"> <label class="slds-form-element__label slds-text-heading_small" for="select-01"> <abbr class="slds-required" title="required">*</abbr>Nom de la ligne d'offre</label> <div class="slds-select_container"> <apex:selectList id="LigneOffre" styleclass="slds-select" value="{!ligneOffreString}" size="4"> <apex:selectOptions value="{!ligneOffreSelectList}"/> </apex:selectList> <div class="slds-select_container"> <p> DATE DE PARUTION </p> <apex:outputField value="{!Insertion__c.DATE_DE_PARUTION__c}"/> <p> BRUT BASE ACHAT </p> <apex:outputField value="{!Insertion__c.BRUT_BASE_ACHAT__c}"/> </div> </div> </div> <br/> <br/> <div class="slds-modal__footer slds-container--small slds-align--absolute-center"> <div class="slds-align--absolute-center"> <apex:commandButton styleClass="slds-button slds-button--brand" value="Enregistrer" action="{!saveButton}" oncomplete="redirectToInsPage('{!errorMessage}')"/> </div> </div> </apex:form> </div> </body> </html> </apex:page>
// Apex Controller public class VC06_0_Insertion_TarifsPresse { public Insertion__c insertionRecord {get; set;} public String ligneOffreString {get; set;} public List<SelectOption> ligneOffreSelectList {get; set;} public String errorMessage {get; set;} public Map<String, Lignes_Offre__c> nomLigneOffreMap {get; set;} //************************************************************************************************************************************************ public VC06_0_Insertion_TarifsPresse(ApexPages.StandardController controller){ errorMessage = ''; insertionRecord = (Insertion__c)controller.getRecord(); queryInsertionRecord(); System.debug('DEBUGKS_1_0_0, insertionRecord.Name: ' + insertionRecord.Name); if((insertionRecord.SUPPORT_RESEAU__c != null)||(insertionRecord.SUPPORT_RESEAU__r.Name != null)){ System.debug('DEBUGKS_1_0_2, insertionRecord.SUPPORT_RESEAU__r.Name: ' + insertionRecord.SUPPORT_RESEAU__r.Name); populateLigneOffrePicklist(); } } //*********************************************************************************************************************************************** public void queryInsertionRecord() { insertionRecord = [SELECT Id, Name, DATE_DE_PARUTION__c, SUPPORT_RESEAU__c, BRUT_BASE_ACHAT__c, SUPPORT_RESEAU__r.Name FROM Insertion__c WHERE Id =: insertionRecord.Id LIMIT 500]; } //*********************************************************************************************************************************************** public void populateLigneOffrePicklist(){ List<Lignes_Offre__c> supportReseauAccsList = [SELECT Id, Name, Nom_du_support__c, Nom_de_la_ligne_d_offre__c, Tarif__c, DateParution__c, Format__c FROM Lignes_Offre__c WHERE Nom_du_support__c =: insertionRecord.Id LIMIT 50000]; ligneOffreSelectList = new List<SelectOption>(); nomLigneOffreMap = new Map<String, Lignes_Offre__c>(); for(Lignes_Offre__c ligneOffre1 : supportReseauAccsList){ nomLigneOffreMap.put(ligneOffre1.Nom_de_la_ligne_d_offre__c, ligneOffre1); } for(String ligneOffreUnique : nomLigneOffreMap.keySet()){ ligneOffreSelectList.add(new SelectOption(ligneOffreUnique, ligneOffreUnique)); } } //************************************************************************************************************************************************* public void saveButton(){ if(ligneOffreString != null){ errorMessage = ''; insertionRecord.FORMAT__c = ligneOffreString; insertionRecord.BRUT_BASE_ACHAT__c = nomLigneOffreMap.get(ligneOffreString).Tarif__c; update insertionRecord; } else{ errorMessage = 'Veuillez choisir une ligne d`offre'; System.debug('DEBUGKS_3_0_2, errorMessage: ' + errorMessage); } System.debug('DEBUGKS_3_0_3, errorMessage FINAL: ' + errorMessage); System.debug(errorMessage == ''); } //************************************************************************************************************************************************* }
Hello everyone, someone could help me solve this problem is very urgent !!!