• Amidou Cisse
  • NEWBIE
  • 55 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 4
    Likes Given
  • 9
    Questions
  • 15
    Replies
User-added image
//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 == '');
    }
   //*************************************************************************************************************************************************
}

 
User-added image
Hello everyone, I hope you are well.
I have this array of data to develop by lightning component, this table allows me to show some data from my campaign as you can see below. If someone has already developed a simulare lightning component, I would like to have their code as a model to adapt my table.

Thank you in advance.
Sales Target: a trigger can be set to disable modification possibilities on the Sales Target fields.
Trigger possibilities:
Time trigger: after a predefined period;
Validation trigger: after Central CRM Manager validation.
Hello everyone,

How to manage the objectives of sales people in salesforce ?
//BlockContentLinkTrigger
trigger BlockContentLinkTrigger on ContentDocumentLink (before insert) {  
    for(ContentDocumentLink  contDocL : Trigger.new) {
            contDocL.addError('Pièce joint bloquée depuis objet ContentDocumentLink');
   }  
}

 
//BlockContentLinkTrigger
trigger BlockContentLinkTrigger on ContentDocumentLink (before insert) {  
    for(ContentDocumentLink  contDocL : Trigger.new) {
      if (CDLHelper.isSharingAllowed(contDocL)) {  
          contDocL.addError('Pièce joint bloquée depuis objet ContentDocumentLink');
     } 
   }  
}

//CDLHelper
public class CDLHelper {
    public static boolean isSharingAllowed(ContentDocumentLink cdl) {
        //String docId = cdl.ContentDocumentId;        
        ContentVersion version = [select PublishStatus, FileExtension from ContentVersion
                                  where ContentDocumentId =: cdl.ContentDocumentId limit 5];              
        if (version.PublishStatus.equals('P') && (version.FileExtension != 'null')) {
            return false;
        }
        return true;
    }
}

 
error
//Trigger
trigger BlockContentLtrigger on ContentDocumentLink (before insert) 
{  
    for(ContentDocumentLink  contDocL : Trigger.new)
    {
      if (CDLHelper.isSharingAllowed(contDocL))
     {
          contDocL.addError('stop3 ');        
     }
   }  
}

//Class
public class CDLHelper {
    public static boolean isSharingAllowed(ContentDocumentLink cdl) {
        String docId = cdl.ContentDocumentId;  
        
        ContentVersion version = [select PublishStatus, FileExtension from ContentVersion where ContentDocumentId =: docId].get(0);        
       
        if (version.PublishStatus.equals('P') && (version.FileExtension != null)) {
            return false;
        }
        return true;
    }
}

 
Hello everybody !
Someone could help me to resolve this problem please ?
 
trigger DateDeCompteRendu on Event (after insert, after update){
    
    Date dateCompteRendu;
    Datetime dateCompteRendunew;
    
    for(Event rdv : trigger.new){
    
        if (rdv.Date_de_compte_rendu__c != NULL) {
           
          dateCompteRendunew = rdv.StartDateTime;  
          dateCompteRendu = date.NewInstance(dateCompteRendunew.year(), dateCompteRendunew.month(),dateCompteRendunew.day());
        
          list<Account> acc = [SELECT Id, Date_de_derniere_visite__c FROM Account WHERE Id = :rdv.WhatId];
          list<Account> accUpdate = new list<Account>();
            
          for(Account a: acc){
             
              a.Date_de_compte_rendu__c = dateCompteRendu;
              accUpdate.add(a);
            }
         
        if (accUpdate.size()>0) {       
            update accUpdate;
            }               
      }
    } 
}
User-added image
//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 == '');
    }
   //*************************************************************************************************************************************************
}

 
User-added image
Hello everyone, I hope you are well.
I have this array of data to develop by lightning component, this table allows me to show some data from my campaign as you can see below. If someone has already developed a simulare lightning component, I would like to have their code as a model to adapt my table.

Thank you in advance.
//BlockContentLinkTrigger
trigger BlockContentLinkTrigger on ContentDocumentLink (before insert) {  
    for(ContentDocumentLink  contDocL : Trigger.new) {
            contDocL.addError('Pièce joint bloquée depuis objet ContentDocumentLink');
   }  
}

 
//BlockContentLinkTrigger
trigger BlockContentLinkTrigger on ContentDocumentLink (before insert) {  
    for(ContentDocumentLink  contDocL : Trigger.new) {
      if (CDLHelper.isSharingAllowed(contDocL)) {  
          contDocL.addError('Pièce joint bloquée depuis objet ContentDocumentLink');
     } 
   }  
}

//CDLHelper
public class CDLHelper {
    public static boolean isSharingAllowed(ContentDocumentLink cdl) {
        //String docId = cdl.ContentDocumentId;        
        ContentVersion version = [select PublishStatus, FileExtension from ContentVersion
                                  where ContentDocumentId =: cdl.ContentDocumentId limit 5];              
        if (version.PublishStatus.equals('P') && (version.FileExtension != 'null')) {
            return false;
        }
        return true;
    }
}

 
error
//Trigger
trigger BlockContentLtrigger on ContentDocumentLink (before insert) 
{  
    for(ContentDocumentLink  contDocL : Trigger.new)
    {
      if (CDLHelper.isSharingAllowed(contDocL))
     {
          contDocL.addError('stop3 ');        
     }
   }  
}

//Class
public class CDLHelper {
    public static boolean isSharingAllowed(ContentDocumentLink cdl) {
        String docId = cdl.ContentDocumentId;  
        
        ContentVersion version = [select PublishStatus, FileExtension from ContentVersion where ContentDocumentId =: docId].get(0);        
       
        if (version.PublishStatus.equals('P') && (version.FileExtension != null)) {
            return false;
        }
        return true;
    }
}

 
trigger DateDeCompteRendu on Event (after insert, after update){
    
    Date dateCompteRendu;
    Datetime dateCompteRendunew;
    
    for(Event rdv : trigger.new){
    
        if (rdv.Date_de_compte_rendu__c != NULL) {
           
          dateCompteRendunew = rdv.StartDateTime;  
          dateCompteRendu = date.NewInstance(dateCompteRendunew.year(), dateCompteRendunew.month(),dateCompteRendunew.day());
        
          list<Account> acc = [SELECT Id, Date_de_derniere_visite__c FROM Account WHERE Id = :rdv.WhatId];
          list<Account> accUpdate = new list<Account>();
            
          for(Account a: acc){
             
              a.Date_de_compte_rendu__c = dateCompteRendu;
              accUpdate.add(a);
            }
         
        if (accUpdate.size()>0) {       
            update accUpdate;
            }               
      }
    } 
}
Hello everyone I could use some help on the using future Methods trailhead. Please keep in mind I am not an Apex coder at all but I am trying to learn as much as I can.

Here is the Task

Create an Apex class with a method using the @future annotation that accepts a List of Account IDs and updates a custom field on the Account object with the number of contacts associated to the Account. Write unit tests that achieve 100% code coverage for the class.
Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
Create an Apex test class called 'AccountProcessorTest'.
The unit tests must cover all lines of code included in the AccountProcessor class, resulting in 100% code coverage.
Run your test class at least once (via 'Run All' tests the Developer Console) before attempting to verify this challenge.

I have written an Apex class and a Test class but I think I am doing them both Wrong: because when I try to check the challenge i Get this error

Challenge Not yet complete... here's what's wrong: 
The 'AccountProcessorTest' test class doesn't appear to be calling the 'AccountProcessor.countContacts' method between Test.startTest() and Test.stopTest().


When I run the Test class I get this error :

System.QueryException: List has no rows for assignment to SObject

Here is the CLASS:
 
public class AccountProcessor {
     @future

  public static void someFutureMethod(List<id> scope) {

   Account[] updates = new Account[] {};
        for (AggregateResult ar : [
                select AccountId a, count(Id) c
                from Contact
                where AccountId in :scope
                group by AccountId
                ]) {
            updates.add(new Account(
                    Id = (Id) ar.get('a'),
                    Number_of_Contacts__c = (Decimal) ar.get('c')
                    ));
        }
        update updates;
    }

}

Here is the Test Class:
 
@IsTest
public class AccountProcessorTest {
  public static testmethod void TestAccountProcessorTest() {
 
Test.startTest();
     Account a = new Account();
        a.Name = 'Test Account';
        Insert a;
      
      Contact cont = New Contact();
      
      cont.FirstName ='Bob';
      cont.LastName ='Masters';
      cont.AccountId = a.Id;
      Insert cont;

    Test.stopTest() ;
     Contact ACC = [select AccountId from Contact where id = :a.id LIMIT 1];

 
        System.assert(Cont.AccountId != null);
        System.assertequals(cont.id, ACC.AccountId);

  }}

I have used alot or diffrent google searches to get me this far. But I have not Idea if Im even remotly close to the right answer or not.


 
Did not seem difficult at all, however got 18% and failed on it after a month of learning on trailhead getting up to 75 badges and 1 superbadge before taking the exam.
Things I noticed, before I took exam I watched https://www.youtube.com/watch?v=lIZk8cKOFHk&t=6613s the person teaching is teaching in classic while a lot of trailhead is in lightning. He did help me visualize a  few questions on the test I would've had no clue on.
Things I would recommend studying is going to every profiles, user, permission sets, validation rule, object and flow and look at what you can and cannot do, and the default settings.
In object such and such pick 2 of 4 things you can do. In this thing what is true?

I'm thinking about retaking it in a week, its a good test, just wasnt ready for that. Thought it would be more scenarios rather than 'what are your options, what is default settings, what went wrong, what things could have not been done right'. It will get you if you are a second guesser or overthinker because you have a lot of options, a lot of questions I noticed you have to pick 2 out of 4 choices, meaning 2 times to second guess yourself in 1 question.

Definitely not easy, but felt like I was closer to passing score of 65% or around there, I felt like I had small chance to pass before hitting the submit answers. I had feeling I did have a feeling I wasn't going to pass before I started the exam but I took it anyways because I kept seeing the message "FAILURE IS AN OPTION". So I'm not too upset I failed, but disappointed. 

I'd say my reason for failure was that I was having too much fun in trailhead rather than specifically studying for subjects relating to ADMIN exam. I had over 35 minutes left after answering questions and went back to check answers too for 20 minutes, which I felt good with, but all in all, 18%.

My 2 cents. Good luck to anyone taking it, also look at the flashcards, I didn't look at them but now thinking I would've passed it if I did http://www.sfdc99.com/2014/10/02/guide-to-passing-all-salesforce-certifications/

 
public class SendMailController {

    public String z { get; set; }

    public String y { get; set; }

    public String x { get; set; }

    public void saveMethod() {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        string[] xyz =new string[] {x};  
        mail.setToAddresses(xyz);
        mail.setSubject(y);
        mail.setHtmlBody(z);    
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
    }
   
  }

As Admin can not prevent directly some profile based user to add comment. I have develope small trigger which can help you for this validation.

 

trigger RistrictUser on FeedComment (Before Insert) 
/*This trigger will restirct user to add comment on chatter*/
{
for(FeedComment FC: trigger.new)
    {
    /*Following Code will get Current User information*/
    User u = [SELECT id,ProfileId,Profile.Name  FROM User WHERE id = :UserInfo.getUserId()];

    /*We are going to restrict user from 'Non-Chatter Users' profile */
        if(u.Profile.Name == 'Non-Chatter Users')
        {
            FC.adderror('You can not post comment'); //You can Customize the error message here 
        }

    }
}/*EOF*/

 

 

Let me know your feedback