Day 3 Assignment
Dec28

Day 3 Assignment

I have created 5 days Salesforce based assignment this is third 3rd day I hope you have already finished 1st and 2nd day. If not it is highly recommended to finish the blog-1, and blog-2 part 1 & part 2  first. The assignment is in format of a typical Salesforce requirement, comparable to a small size project. Please go through the requirements which are well defined and should be easily understood if you have a basic understanding of Salesforce sales and service cloud. Your data model design or solution approach to the requirements might be different from the answers provided here. Every solution is correct if you are fulfilling all the requirements. Requirement: We have a university “St Judes” which wants its salesforce account to get configured by us. Following are the requirement of this client.   1. Since Student and Course are having a many to many relationship, the Junction object will have several fields representing the Student’s performance in those Courses. A Student will have the Status of PASS or FAIL and MARKS OBTAINED for each of its Course as well. Click here to learn more For this solution make a picklist having name Status and values PASS or FAIL and a number field named Marks Obtained in the junction object this will do the trick.   2. All the Professor will get an email 2 days before the Course completion asking the Professors to provide marks to those Students in its Course. Click here to learn more For this what i have done is first create a email field in in Professor and Course object and made the email field mandatory. Than I have created a trigger on Course to auto update the email field in the Course object with Professors email. I hope you have done part-1 and part-2 already and you have already created a trigger on course the best practices tells us that we should not make more than one trigger on a single object. So update this part also in your trigger and this part will auto update the email field in Course object with the email field in Professor.   Trigger: Map<Id, Course__c> profCourseMap = new Map<Id, Course__c>(); List<Course__c> fullCourseList = [SELECT Id, Name, Professor_del__c, Professor_Email__c FROM Course__c WHERE Id IN: Trigger.newMap.keySet()]; for (Course__c course : fullCourseList) { if (Trigger.isInsert) { profCourseMap.put(course.Professor_del__c, course); } if (Trigger.isUpdate && Trigger.oldMap.get(course.Id).Professor_del__c != course.Professor_del__c && course.Professor_del__c != NULL) { profCourseMap.put(course.Professor_del__c, course); } } System.debug(‘profCourseMap————–‘ + profCourseMap); System.debug(‘profCourseMap————–‘ + profCourseMap); List<Course__c> listToBeUpdated = new List<Course__c>(); List<Professor__c> mainProfList = [SELECT Name, Email__c FROM Professor__c WHERE Id IN: profCourseMap.keySet()]; for (Course__c course : profCourseMap.values()) { for (Integer i = 0;...

Read More
Day 2 Assignment  Part-2
Dec22

Day 2 Assignment Part-2

I have created a 5 Days Salesforce based programming and configuration assignments for practice and improving your skills. This blog have the second day assignment part-2. The assignment is in format of a typical salesforce requirement, comparable to a small size project. To design and develop this project it is recommended that you register a fresh salesforce developer org. Please go through the requirements which are well defined and should be easily understood if you have a basic understanding of salesforce sales and service cloud. Your data model design or solution approach to the requirements might be different from the answers provided here. Every solution is correct if you are fulfilling all the requirements. It is highly recommended before working on this blog you must have completed the part-1 blog. Requirement: We have a university “St Judes” which wants its Salesforce account to get configured by us. Following are the requirement of this client.   2.1. A Course will have list of all the Students in it enrolled. Click here to learn more You don’t know it yet that you have already completed it. You just need to make them viewable from page layout and you know it now how to do it.   2.2.  Professor fields “DOB” “Years of Experience”, “Expertise”        Multipicklist(Java,English,Mechanical,..etc) Click here to learn more It is again a data model configuration question to create fields.   2.3. The University will display all the Professors experties. Hint: In University detail page your new section must look like—>   Click here to learn more We have to create a Inline Visualforce page to solve this problem. And here is the controller class for this problem: Class: public with sharing class ListOfProfessorInUniversity { public boolean flag{get; set;} public string ids{get; set;} public ListOfProfessorInUniversity(ApexPages.StandardController controller){ ids = controller.getId(); } public List<Professor__c> getAllProfessor() { List<Course__c> allCourses = [SELECT Name, Professor_del__c, Select_University__c FROM Course__c WHERE Professor_del__c != NULL AND Select_University__c =: ids]; Set<Id> CourseIdList = new Set<Id>(); for (Course__c courses : allCourses) { CourseIdList.add(courses.Professor_del__c); } system.debug(‘>>>>>>>>>>’ +CourseIdList); List<Class__c> allClass = [SELECT Name, Class_Teacher__c FROM Class__c WHERE Class_Teacher__c !=: CourseIdList OR Id IN : CourseIdList]; Set<Id> classIdList = new set<Id>(); for (Class__c classes : allClass){ classIdList.add(classes.Class_Teacher__c); } system.debug(‘>>>>>>>>>>’ +classIdList); List<Professor__c> professors = [SELECT Name, email__c, Experience__c, Expertise__c FROM Professor__c WHERE Id IN : CourseIdList OR Id IN : classIdList]; system.debug(‘*****************’ +professors); Set<Professor__c> IdSet = new Set<Professor__c>(); idSet.addAll(professors); system.debug(‘>>>>>>>>>>>’ + idSet); if (NULL != IdSet){ flag = true; } else{ flag = false; } return professors; } }   and here is the Visualforce page for this controller:   <apex:page standardController=”St_Judes_University__c” extensions=”ListOfProfessorInUniversity”> <apex:sectionHeader title=”All Professors Related to University”/> <apex:outputpanel rendered=”{!flag}” > These are the students which are teached by teacher. </apex:outputpanel> <apex:pageBlock > <apex:pageBlockTable value=”{!AllProfessor}” var=”professor”> <apex:column value=”{!professor.Name}”/> <apex:column value=”{!professor.email__c}”/> <apex:column value=”{!professor.Experience__c}”/> <apex:column value=”{!professor.Expertise__c}”/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>   Now your work is done and now you just need to add the Visualforce page in the page layout section.   2.4. When ever a new student is added he is supposed to be registered at-least in a Course and a Class. Click here to learn more For this you must create the field on Student of Course mandatory and in Course the Class field make it mandatory too. That’s it your work is done.   2.5. When a new...

Read More
Day 2 Assignment Part-1
Dec08

Day 2 Assignment Part-1

I have created a 5 Days Salesforce based programming and configuration assignments for practice and improving your skills. This blog have the second day assignment. The assignment is in format of a typical salesforce requirement, comparable to a small size project. To design and develop this project it is recommended that you register a fresh salesforce developer org. Please go through the requirements which are well defined and should be easily understood if you have a basic understanding of salesforce sales and service cloud. You data model design or solution approach to the requirements might be different from the answers provided here. Every solution is correct if you are fulfilling all the requirements. Requirement: We have a university “St Judes” which wants its salesforce account to get configured by us. Following are the requirement of this client.   1.1. A Student can register to multiple courses and A Class can have multiple Courses and each Course can have multiple Students. Hint: It can easily be done by simple Datamodel configuration. For this you have to create some custom objects like University, Class, Student, Course, etc. Click here to learn more For creating custom object the procedure is like: Go to setup, click on the search bar and type objects or go to setup, then go to Create than select objects   than create the required objects. Here is one example of creating a custom object:   Than click on new button you’ll able to see the page shown below. After creating all the required objects you do need to create a flow diagram or Datamodel for further implementation. Here is one with which i have created you can design it in your style and in your own way. For more information on master-detail realtionship and junction object please follow the Link. Junction Object For creating field in your dev org you have to follow these steps: Go to setup>search objects than click on the the custom object in which you want to create the field. Let us go to Course object which you must have created by following the datamodel. Now when we go to our object we will find custom field and relationship extention there now click on the new button. Now select the type of field which you want to create what we are going to do is to create a lookup field in Course object. Than you will get a page to select a related to object in which you have to pick your related object in it like i have picked professor as my related to object. now click next button than write a name and...

Read More