• Chaitanya_v
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Need help to write a trigger on Class_Allocation__c to concantenate Level_Code__c from multiple related records into the 'Allocated_Levels__c' on Student__c seperated by semi colon.  The total number of Class_Allocation__c records related to the Student__c is mentioned in Number_of_Confirmed_Class__c on Student__c object.  (Need to remove duplicate values as well)

Student__c (Master)
    Allocated_Levels__c (Text Field)
    Number_of_Confirmed_Class__c (Numeric Field)
    Student_Name__c
Class_Alloction__c (Related to Student v/a master relationship)
    Level_Code__c (P1, P2, P3 etc)
    Student_Name__c

Below is my trigger, currently it show only one value.  I am not sure on how to get the value into Student__c field as P1;P2;P3 etc

trigger UpdateStudent on Class_Allocation__c (after insert, after Update)
{
    set<id> noteIds = new SET<id>();
        for(Class_Allocation__c note : Trigger.new )
        {
            noteIds.add(note.Student_Name__c);
        }
    List<Student__c> bigList = [select id, Allocated_Levels__c, Number_of_Confirmed_Class__c from Student__c where Id In: noteIds];
        for(Class_Allocation__c note : Trigger.new )
        {
            for(Student__c big : bigList)
            {
                if(note.Student_Name__c == big.id)
                {
                    big.Allocated_Levels__c = note.Level_Code__c + ';';
                }
            }
        }
        if(bigList.Size() > 0)
        {
            update bigList;
        }
}
  • October 12, 2016
  • Like
  • 0
Hello Experts, 

I am trying to figure out how to get the DATE/TIME format to look like this: MM-DD-YYY HH:MM AM/PM. Currently it is all wrong, looking like this: 2016-10-11 19:20:33

Here is my code currently.

if(updateTask.Description != null){
                            updateTask.Description += '\n' + newTask.CreatedDate + ' ' + newTask.Description;
                        }
                        else{
                            updateTask.Description = newTask.CreatedDate + ' ' + newTask.Description;