+ Start a Discussion
Radhika pawar 5Radhika pawar 5 

How to retrives the Lookupdata using List

Hey Friends,
I have One Issused which i m facing saved the Multipicklist value present in UP_Library_book__c Object Name
I m using Three Object 
Name like :

Relation ship are :Relationship with book assignment

I m doing:Look

But after saving :It will showingAfter inserting data its shown like
Its not saved Multi picklist value 
My code:
public with sharing class testctrlUPLBAssig{
  public UP_Batch__c Batch{get;set;}
  private final UP_Batch__c Batchc;
  private List<Student> lstStudents;
  private List<UP_Library_book__c> lstBooks; 
  public List<SelectOption> book_options{get;set;}
  public testctrlUPLBAssig(ApexPages.StandardController controller) {
    Batchc = (UP_Batch__c)controller.getRecord();
    book_options = new List<SelectOption>();
    lstStudents = new List<Student>();
    if(this.Batchc.Id != null) {
      Batch = [SELECT Id, Name, Address__c, program__c, Academic_Year__c, Start_date__c, community__r.Name, community__c from UP_Batch__c where Id=: this.Batchc.Id];
  private void LoadExistingTask() {
    List<up_student__c> tempstu = [Select id, Contact__r.Name from up_student__c where Batch__c =: this.batch.id Order by CreatedDate];
    List <UP_Library_book__c>temp_book = [SELECT id, Age_Group__c, community__c, title__c FROM UP_Library_book__c WHERE community__c =: batch.community__c order by title__c];
      Map<id, UP_Library_book__c> mbook = new map<id, UP_Library_book__c>();
      for(UP_Library_book__c temp : temp_book) {
        mbook.put(temp.id, temp);
      List<UP_Book_Assignment__c> temp_assign = [SELECT Book__c FROM UP_Book_Assignment__c WHERE returned__c = false and student__c =: tempstu];
    temp_assign = [SELECT Issued_Month__c,Student__c,Book__c,Book__r.Book_List__c,Book__r.Title__c FROM UP_Book_Assignment__c WHERE student__c =: tempstu order by createddate desc];
    Map<id, List<UP_Book_Assignment__c>> massign = new Map<id, List<UP_Book_Assignment__c>>();
    List<UP_Book_Assignment__c> swap;
    for(UP_Book_Assignment__c temp : temp_assign) {
      swap = massign.get(temp.student__c);
      if (swap == null) {
        swap = new List<UP_Book_Assignment__c>();
      massign.put(temp.student__c, swap);
    for(up_student__c stu : tempstu) {
      lststudents.add(new student(stu, massign.get(stu.id)));
  public pageReference Save() {
    List<UP_Book_Assignment__c> lst_assign = new List<UP_Book_Assignment__c>();
    try {
      for (Student st : lstStudents) {
        for(UP_Book_Assignment__c temp : st.assign) {
      upsert lst_assign;
    catch(DmlException ex) {
      return null;
    PageReference prPage;
    prPage = new PageReference('/apex/up_l_assignment?id=' + this.Batchc.Id);
    return prPage;
    public List<Student> getOppTask() {
      return lstStudents;

    public class Student {
      public List<UP_Book_Assignment__c> assign {get;set;}
      public UP_Student__c stu {get;set;}
      public Student(UP_student__c student, List<UP_Book_Assignment__c> assign) {
        this.stu = student;
        if (assign == null)
          assign = new List<UP_Book_Assignment__c>();
        this.assign = assign;
    public PageReference addStudentPlacement() {
      this.assign.add(new UP_Book_Assignment__c(student__c = this.stu.id));
      return null;