• Mohammed Ikram 7
  • NEWBIE
  • 30 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 8
    Replies
how to insert the record link.

The trigger is below , please give the code to add the hyper link of the record

-------

trigger DocLink on Contact (before insert) {
  // Step 0: Create a master list to hold the emails we'll send
  List<Messaging.SingleEmailMessage> mails =
  new List<Messaging.SingleEmailMessage>();
 
  for (Contact myContact : Trigger.new) {
    if (myContact.Email != null && myContact.FirstName != null) {
      // Step 1: Create a new Email
      Messaging.SingleEmailMessage mail =
      new Messaging.SingleEmailMessage();
   
      // Step 2: Set list of people who should get the email
      List<String> sendTo = new List<String>();
      sendTo.add(myContact.Email);
      mail.setToAddresses(sendTo);
   
      // Step 3: Set who the email is sent from
      mail.setReplyTo('ikrammohiuddin@gmail.com');
      mail.setSenderDisplayName('Mohammed Ikram Moinuddin');
   
      // (Optional) Set list of people who should be CC'ed
      List<String> ccTo = new List<String>();
      ccTo.add('ikrammohiuddin@gmail.com');
      mail.setCcAddresses(ccTo);
      // Step 4. Set email contents - you can use variables!
      mail.setSubject('Link of the Contact '+ myContact.FirstName);
       String body = 'Dear ' + myContact.FirstName + ', ';
      body += 'I confess this will come as a surprise to you.';
      body += 'I am good';
  
      body += 'to a persom. Please respond with ';
      body += 'your details.';
  
      mail.setHtmlBody(body);
   
      // Step 5. Add your email to the master list
      mails.add(mail);
    }
  }
  // Step 6: Send all emails in the master list
  Messaging.sendEmail(mails);
}
I have a VF page , in which the javascript is for firing for the inputext id   Input Here <apex:inputText value="{!select1}" id="body"  required="true"/>
 <apex:commandButton value="Get Value"  reRender="theTable" onclick="validateField();"/>

and the hyper link is not working for
      <apex:outputLink value="/{!Stud.Id}"> in VF page the , the OnChangeListDisplayByCountry class is also below the VF page code.



apex:page controller="OnChangeListDisplayByCountry">

    <!-- Pass parameters from visualforce page to controller -->
    <apex:form >
   
               <!-- Javascript -->
    <script type="text/javascript">
    function validateField()
    {
         if(document.getElementById('{!$Component.body}').value == '')
        {
            alert("Please select country");
            return false;
        }
        else
        {
        getStudents1();
        }
   
    
    }
   
    </script>
<!-- Javascript -->  

    <apex:actionRegion >&nbsp; <!-- "Select the Appropriate Breaker" (Picklist) /-->
    <apex:selectList multiselect="false"   title="Tipo" id="selectlist1" value="{!select1}" size="1" >
      <apex:actionSupport event="onchange" action="{!getStudents1}" reRender="theTable, messageBlock"/>
                <apex:selectOptions value="{!CountryNames}">
                </apex:selectOptions>
    </apex:selectList>
    </apex:actionRegion>
   
            <apex:pageblock >
                  Input Here <apex:inputText value="{!select1}" id="body"  required="true"/>
                  <!-- This is a comment -->
            <!--    <apex:commandButton value="Submit" reRender="theTable" action="{!getStudents1}"/> -->
                 <apex:commandButton value="Get Value"  reRender="theTable" onclick="validateField();"/>
                
            </apex:pageblock>
            <apex:pageblock >
           
           
           

               
                 <apex:dataTable value="{!Students1}" var="Stud" id="theTable"
        rowClasses="odd,even" styleClass="tableClass">
     
        <apex:facet name="caption">Students Details</apex:facet>
        <apex:facet name="header">Student data</apex:facet>
     <apex:facet name="footer">End Of Page</apex:facet>

         <apex:column >
            <apex:facet name="header">Name</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
         
           
           
                 <apex:outputLink value="/{!Stud.Id}">
                    <li>
                        <apex:outputText value="{!Stud.Student_Name__c}"/>
                    </li>
                </apex:outputLink>
          
        </apex:column>

        <apex:column >
            <apex:facet name="header">Email</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText id="myId2" value="{!Stud.Email__c}"/>
        </apex:column>

    <apex:column >
            <apex:facet name="header">Country</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText id="myId3" value="{!Stud.Country__c}"/>
        </apex:column>
<apex:column >
            <apex:facet name="header">Country1</apex:facet>
            <apex:facet name="footer">column footer1</apex:facet>
            <apex:outputText id="myId4" value="{!select1}"/>
        </apex:column>

      

    </apex:dataTable>
     
               
            </apex:pageblock>
    </apex:form>
  
</apex:page>


-----


public class OnChangeListDisplayByCountry {
Public string country{get;set;}
Public string select1{get;set;}

public list <Student_Data__c> Students1 {get;set;} 
    //List<Student_Data__c> Students1;
    
  
    public void getStudents1() {
        //if(Students1 == null)
            Students1 = [SELECT  Id,student_name__c, email__c,Country__c FROM student_data__c where Country__c =:select1 LIMIT 400];
        //return Students1 ;
    }
List<selectOption> options = new List<selectOption>();
Set<string>cntry = new set<string>();
public List<selectOption> getCountryNames() {
//for(student_data__c stdnt: [select Id,Country__c from student_data__c])
//{
//options.add(new selectOption(stdnt.Country__c ,stdnt.Country__c ));
//}
options.add(new selectOption('Select' ,'Select'));
 for (student_data__c listMapping : [select Id,Country__c from student_data__c])                                                            
          {

              //  if(!cntry.contains(listMapping.Country__c ))

             //   {

//options.add(new selectOption(listMapping.Country__c ,listMapping.Country__c ));

          //      }        
          
          
             if(cntry.contains(listMapping.Country__c ))
                {
                     // dont add duplicate, do nothing
                     system.debug('DUP PRESENT');
                }   
                else { 
                     cntry.add(listMapping.Country__c);
                     system.debug('DUP NOT PRESENT');
                     options.add(new selectOption(listMapping.Country__c ,listMapping.Country__c));
                }       
          
          
          }


return options;
}

 

}


Please help.
public class MixedObjectVFController {

    public static List<List<String>> getObjectList(){
    List<List<String>> strList = new List<List<String>>();
    List<Account> acc = [select name,phone,AccountNumber from account limit 100];

    for(account a : acc){
        List<String> tempList = new List<String>();
        tempList.add('account');
        tempList.add(a.name);
        tempList.add(a.phone);
         tempList.add(a.AccountNumber );
        strList.add(tempList);
    }
    List<contact> cList = [select name,phone,email from contact limit 100];
    for(contact a : cList){
        List<String> tempList = new List<String>();
        tempList.add('contact');
        tempList.add(a.name);
        tempList.add(a.phone);
         tempList.add(a.email );
        strList.add(tempList);
    }
    return strList;
}
}
I want to Display all child invoices of a customer , I created a class controller,

public class ListOfChildRecordsInvoices
{

  

public List<Invoice__c> ListOfInvoices {get;set;}

   
 
//List<Invoice__c> ListOfInvoices;

     public List<Invoice__c> getInvoices() {
         
        List<Customer__c> ListCustomers = [SELECT Name, Id, 
  (SELECT id, Name,Amount__c,Status__c FROM Invoice__r) FROM Customer__c WHERE Name = 'IBM'];
  
        if(ListOfInvoices == null)
         {
     List<Invoice__c> ListOfInvoices = ListCustomers[0].Invoice__r;
     }
     
     return ListOfInvoices;
   }
  
}

My visualForcepage is
 
<apex:page controller="ListOfChildRecordsInvoices" id="thePage">
    <apex:dataTable value="{!ListOfInvoices}" var="Stud" id="theTable"
        rowClasses="odd,even" styleClass="tableClass">
      
        <apex:facet name="caption">Invoices Details</apex:facet>
        <apex:facet name="header">Invoices data</apex:facet>
     <apex:facet name="footer">End Of Page</apex:facet>

         <apex:column >
            <apex:facet name="header">Name</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText value="{!Stud.Name}"/>
        </apex:column>
    <apex:column >
            <apex:facet name="header">Amount</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText value="{!Stud.Amount__c}"/>
        </apex:column>

        <apex:column >
            <apex:facet name="header">Email</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText value="{!Stud.Status__c}"/>
        </apex:column>

        

    </apex:dataTable>
    </apex:page>

I am not getting the results , please help
 
how to insert the record link.

The trigger is below , please give the code to add the hyper link of the record

-------

trigger DocLink on Contact (before insert) {
  // Step 0: Create a master list to hold the emails we'll send
  List<Messaging.SingleEmailMessage> mails =
  new List<Messaging.SingleEmailMessage>();
 
  for (Contact myContact : Trigger.new) {
    if (myContact.Email != null && myContact.FirstName != null) {
      // Step 1: Create a new Email
      Messaging.SingleEmailMessage mail =
      new Messaging.SingleEmailMessage();
   
      // Step 2: Set list of people who should get the email
      List<String> sendTo = new List<String>();
      sendTo.add(myContact.Email);
      mail.setToAddresses(sendTo);
   
      // Step 3: Set who the email is sent from
      mail.setReplyTo('ikrammohiuddin@gmail.com');
      mail.setSenderDisplayName('Mohammed Ikram Moinuddin');
   
      // (Optional) Set list of people who should be CC'ed
      List<String> ccTo = new List<String>();
      ccTo.add('ikrammohiuddin@gmail.com');
      mail.setCcAddresses(ccTo);
      // Step 4. Set email contents - you can use variables!
      mail.setSubject('Link of the Contact '+ myContact.FirstName);
       String body = 'Dear ' + myContact.FirstName + ', ';
      body += 'I confess this will come as a surprise to you.';
      body += 'I am good';
  
      body += 'to a persom. Please respond with ';
      body += 'your details.';
  
      mail.setHtmlBody(body);
   
      // Step 5. Add your email to the master list
      mails.add(mail);
    }
  }
  // Step 6: Send all emails in the master list
  Messaging.sendEmail(mails);
}
I have a VF page , in which the javascript is for firing for the inputext id   Input Here <apex:inputText value="{!select1}" id="body"  required="true"/>
 <apex:commandButton value="Get Value"  reRender="theTable" onclick="validateField();"/>

and the hyper link is not working for
      <apex:outputLink value="/{!Stud.Id}"> in VF page the , the OnChangeListDisplayByCountry class is also below the VF page code.



apex:page controller="OnChangeListDisplayByCountry">

    <!-- Pass parameters from visualforce page to controller -->
    <apex:form >
   
               <!-- Javascript -->
    <script type="text/javascript">
    function validateField()
    {
         if(document.getElementById('{!$Component.body}').value == '')
        {
            alert("Please select country");
            return false;
        }
        else
        {
        getStudents1();
        }
   
    
    }
   
    </script>
<!-- Javascript -->  

    <apex:actionRegion >&nbsp; <!-- "Select the Appropriate Breaker" (Picklist) /-->
    <apex:selectList multiselect="false"   title="Tipo" id="selectlist1" value="{!select1}" size="1" >
      <apex:actionSupport event="onchange" action="{!getStudents1}" reRender="theTable, messageBlock"/>
                <apex:selectOptions value="{!CountryNames}">
                </apex:selectOptions>
    </apex:selectList>
    </apex:actionRegion>
   
            <apex:pageblock >
                  Input Here <apex:inputText value="{!select1}" id="body"  required="true"/>
                  <!-- This is a comment -->
            <!--    <apex:commandButton value="Submit" reRender="theTable" action="{!getStudents1}"/> -->
                 <apex:commandButton value="Get Value"  reRender="theTable" onclick="validateField();"/>
                
            </apex:pageblock>
            <apex:pageblock >
           
           
           

               
                 <apex:dataTable value="{!Students1}" var="Stud" id="theTable"
        rowClasses="odd,even" styleClass="tableClass">
     
        <apex:facet name="caption">Students Details</apex:facet>
        <apex:facet name="header">Student data</apex:facet>
     <apex:facet name="footer">End Of Page</apex:facet>

         <apex:column >
            <apex:facet name="header">Name</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
         
           
           
                 <apex:outputLink value="/{!Stud.Id}">
                    <li>
                        <apex:outputText value="{!Stud.Student_Name__c}"/>
                    </li>
                </apex:outputLink>
          
        </apex:column>

        <apex:column >
            <apex:facet name="header">Email</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText id="myId2" value="{!Stud.Email__c}"/>
        </apex:column>

    <apex:column >
            <apex:facet name="header">Country</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText id="myId3" value="{!Stud.Country__c}"/>
        </apex:column>
<apex:column >
            <apex:facet name="header">Country1</apex:facet>
            <apex:facet name="footer">column footer1</apex:facet>
            <apex:outputText id="myId4" value="{!select1}"/>
        </apex:column>

      

    </apex:dataTable>
     
               
            </apex:pageblock>
    </apex:form>
  
</apex:page>


-----


public class OnChangeListDisplayByCountry {
Public string country{get;set;}
Public string select1{get;set;}

public list <Student_Data__c> Students1 {get;set;} 
    //List<Student_Data__c> Students1;
    
  
    public void getStudents1() {
        //if(Students1 == null)
            Students1 = [SELECT  Id,student_name__c, email__c,Country__c FROM student_data__c where Country__c =:select1 LIMIT 400];
        //return Students1 ;
    }
List<selectOption> options = new List<selectOption>();
Set<string>cntry = new set<string>();
public List<selectOption> getCountryNames() {
//for(student_data__c stdnt: [select Id,Country__c from student_data__c])
//{
//options.add(new selectOption(stdnt.Country__c ,stdnt.Country__c ));
//}
options.add(new selectOption('Select' ,'Select'));
 for (student_data__c listMapping : [select Id,Country__c from student_data__c])                                                            
          {

              //  if(!cntry.contains(listMapping.Country__c ))

             //   {

//options.add(new selectOption(listMapping.Country__c ,listMapping.Country__c ));

          //      }        
          
          
             if(cntry.contains(listMapping.Country__c ))
                {
                     // dont add duplicate, do nothing
                     system.debug('DUP PRESENT');
                }   
                else { 
                     cntry.add(listMapping.Country__c);
                     system.debug('DUP NOT PRESENT');
                     options.add(new selectOption(listMapping.Country__c ,listMapping.Country__c));
                }       
          
          
          }


return options;
}

 

}


Please help.
public class MixedObjectVFController {

    public static List<List<String>> getObjectList(){
    List<List<String>> strList = new List<List<String>>();
    List<Account> acc = [select name,phone,AccountNumber from account limit 100];

    for(account a : acc){
        List<String> tempList = new List<String>();
        tempList.add('account');
        tempList.add(a.name);
        tempList.add(a.phone);
         tempList.add(a.AccountNumber );
        strList.add(tempList);
    }
    List<contact> cList = [select name,phone,email from contact limit 100];
    for(contact a : cList){
        List<String> tempList = new List<String>();
        tempList.add('contact');
        tempList.add(a.name);
        tempList.add(a.phone);
         tempList.add(a.email );
        strList.add(tempList);
    }
    return strList;
}
}
I want to Display all child invoices of a customer , I created a class controller,

public class ListOfChildRecordsInvoices
{

  

public List<Invoice__c> ListOfInvoices {get;set;}

   
 
//List<Invoice__c> ListOfInvoices;

     public List<Invoice__c> getInvoices() {
         
        List<Customer__c> ListCustomers = [SELECT Name, Id, 
  (SELECT id, Name,Amount__c,Status__c FROM Invoice__r) FROM Customer__c WHERE Name = 'IBM'];
  
        if(ListOfInvoices == null)
         {
     List<Invoice__c> ListOfInvoices = ListCustomers[0].Invoice__r;
     }
     
     return ListOfInvoices;
   }
  
}

My visualForcepage is
 
<apex:page controller="ListOfChildRecordsInvoices" id="thePage">
    <apex:dataTable value="{!ListOfInvoices}" var="Stud" id="theTable"
        rowClasses="odd,even" styleClass="tableClass">
      
        <apex:facet name="caption">Invoices Details</apex:facet>
        <apex:facet name="header">Invoices data</apex:facet>
     <apex:facet name="footer">End Of Page</apex:facet>

         <apex:column >
            <apex:facet name="header">Name</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText value="{!Stud.Name}"/>
        </apex:column>
    <apex:column >
            <apex:facet name="header">Amount</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText value="{!Stud.Amount__c}"/>
        </apex:column>

        <apex:column >
            <apex:facet name="header">Email</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputText value="{!Stud.Status__c}"/>
        </apex:column>

        

    </apex:dataTable>
    </apex:page>

I am not getting the results , please help