• Nabeela Mubarak 9
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
The Guest user uploads the Attachment using Salesforce Sites , but we dont see a preview for this file
//controller
global class applicationcontrollernew
{
    
    public Wrapperhospital wrapper {get; set;}
    public List<Wrapperhospital> listWrappers {get;set;}
    public Wrapperpharm wrapperpharm {get; set;}
    public List<Wrapperpharm> listpharmWrappers {get;set;}
    
    public WrapperBillObject Wrapperbill {get; set;}
    public List<WrapperBillObject> listWrappersBill {get;set;}
    public List<WrapperBillObject> attachmentlist {get;set;}
    public Patient__c p {get; set;}
    public Contact c {get;set;}
    public Contact c1{get;set;}
    Public Contact c2{get;set;}
    public Application__c app {get;set;}
   
    Public Attachment adhaar{get;set;}
    
    Public Attachment fadhaar{get;set;}
   
    
    Public Attachment madhaar{get;set;}
    Public Attachment ration{get;set;}
  
    
    Public Attachment passport{get;set;}
   
    
    
    Public Attachment Supporting{get;set;}
   
    Public Attachment hospitalpoto {get;set;}
  
    Public Attachment familypoto {get;set;}
  
    
    
    
    public applicationcontrollernew()
    {
        p = new Patient__c();
        c=  new Contact();
        c1=  new Contact();
        c2=  new Contact();  
        app= new Application__c();
        
        adhaar= new Attachment();
        fadhaar= new Attachment();
        madhaar = new Attachment();
        ration = new Attachment();
        passport = new Attachment();
        hospitalpoto = new Attachment();
        familypoto = new Attachment();
        supporting = new Attachment();
        
        
        
        listWrappers = new List<Wrapperhospital>();
        wrapper = new Wrapperhospital();
        listWrappers.add(wrapper);
        listpharmWrappers = new List<Wrapperpharm>();             
        wrapperpharm = new Wrapperpharm();
        listpharmWrappers.add(wrapperpharm);
        listWrappersBill = new List<WrapperBillObject>(); 
       
        attachmentlist  = new  List<WrapperBillObject>();
        Wrapperbill = new WrapperBillObject();
        listWrappersBill.add(Wrapperbill);
        
       
    }
    public class Wrapperhospital 
    {
        public Medical_Facility__c hospital{get;set;} // our target hospital inside Wrapper
       
        public Wrapperhospital() 
        {
            hospital = new Medical_Facility__c(); 
           // every Wrapper have hospital
        }
    }
    
    public void  addhospital() 
    { // called from vf
        Wrapperhospital wrapper = new Wrapperhospital();
        
        
        listWrappers.add(wrapper); // vf render this list with new added wrapper
        
    }
    
    
    public class Wrapperpharm
    {
        public Pharmacy__c Pharmacy{get;set;} // our target Pharmacy inside Wrapper
        public Wrapperpharm() 
        {
            pharmacy = new Pharmacy__c (); // every Wrapper have Pharmacy
        }
    }
    public void  addpharmacy() 
    { // called from vf
        Wrapperpharm  wrapperpharm  = new Wrapperpharm();
        
        
        listpharmWrappers.add( wrapperpharm); // vf render this list with new added wrapper
        
    }
    public class WrapperBillObject
    {
        public Bills_And_Payments__c bill{get;set;} // our target hospital inside Wrapper
        public Attachment billattach{get;set;}

        public WrapperBillObject() 
        {
            bill = new  Bills_And_Payments__c();
            billattach = new Attachment();
           billattach.Name= billattach.name;
          billattach.Body= billattach.body;
          
        }
    }
    public void  addbills() 
    { // called from vf
        WrapperBillObject wrapperbill = new WrapperBillObject();
        listWrappersBill.add( wrapperbill);
        
    
    }
    
   
    public PageReference save() 
    {
          
        String cert = p.CertificateNumber__c;
        
        List<Patient__c> temp = new List<Patient__c>();
        temp = [SELECT Id, CertificateNumber__c FROM Patient__c where CertificateNumber__c =:cert];
        if(temp.size()==0)
        {
            insert p;
           
        }
        
        else
        {
            p.id=temp[0].id;
            update p;
        }
         
        system.debug('Patient' +p);
       
        List<Contact> contactlist = new List<Contact>();
        
            c.Patient__c=p.id;
            c.Contact_Type__c='Applicant';
            contactlist.add(c);
            c1.Patient__c=p.id;
            c1.Contact_Type__c='Emergency Contact';
            contactlist.add(c1);            
            c2.Patient__c=p.Id;
            c2.Contact_Type__c='Emergency Contact';
            contactlist.add(c2);  
        insert contactlist;
        system.debug('Contactlist'+ contactlist);
            app.Patient__c= p.Id;
         app.Applicant_Name__c=p.Applicant_Name__c;
            insert app;
           
        List<Attachment>  attachlist = new List <Attachment>();
       
        
        Attachment adhaar  = new Attachment(parentid=app.id, Name = adhaar.name , Body = adhaar.body);
        attachlist.add(adhaar);
        
        Attachment fadhaar  = new Attachment(parentid=app.id, Name = fadhaar.name , Body = fadhaar.body);
       
         if(fadhaar.name!=null)
             {
        attachlist.add(fadhaar);
             }
            Attachment madhaar  = new Attachment(parentid=app.id, Name = madhaar.name , Body = madhaar.body);
         if(madhaar.name!=null)
             {
        attachlist.add(madhaar);
             }
          
            Attachment passport  = new Attachment(parentid=app.id, Name = passport.name, Body = passport.body);
           attachlist.add(passport);
          
            Attachment hospitalpoto = new Attachment(parentid=app.id, Name = hospitalpoto.name, Body = hospitalpoto.body);
             if(hospitalpoto.name!=null)
             {
        attachlist.add(hospitalpoto);
             }
            Attachment ration =new Attachment(parentid=app.id, Name = ration.name, Body = ration.body);
                attachlist.add(ration);
            Attachment familypoto = new Attachment(parentid=app.id, Name = familypoto.name, Body = familypoto.body);
            if(familypoto.name!=null)
            {
                attachlist.add(familypoto);
            }
        
         Attachment Supporting = new Attachment(parentid=app.id, Name = Supporting.name, Body = Supporting.body);
           
       
        if(Supporting.name!=NULL)
        {
           attachlist.add(Supporting);
        }
            insert attachlist;
            List<Medical_Facility__c> listhospitals = new List<Medical_Facility__c>();
            for (Wrapperhospital wrapper : listWrappers) 
            { 
                wrapper.hospital.Application__c= app.id;
                listhospitals.add(wrapper.hospital);
                
            }
            if(wrapper.hospital.Hospital_Name__c != NULL)
            {
            insert listhospitals;
                system.debug('Hospitals'+listhospitals);
            }
  
        
            List<Pharmacy__c> listpharmacy = new List<Pharmacy__c>();
            for (Wrapperpharm  wrapperpharm  :  listpharmWrappers ) 
            { 
                wrapperpharm.pharmacy.Application__c= app.id;
                listpharmacy.add(wrapperpharm.pharmacy);
                
            }
            if(wrapperpharm.pharmacy.Pharmacy_Name__c != NULL)
            {
            insert listpharmacy;
               system.debug('Pharmcy'+listpharmacy);  
            }
            
            
            List<Bills_And_Payments__c> listofbills = new List <Bills_And_Payments__c>();
       
          
        for (WrapperBillObject wrapperbill : listWrappersBill) 
            { 
                wrapperbill.bill.Application__c= app.id;
               
                listofbills.add(wrapperbill.bill);
            }
          if(wrapperbill.bill.Total_Bill_Amount__c!= 0)
          {
            insert listofbills;
              system.debug('Bill Inserted' +listofbills);
          }
        
         List<Attachment> listattach= new List<Attachment>();
       
        system.debug('Attachment Lsit'+listWrappersBill);
        
     for (integer i=0;i< listWrappersBill.size();i++)
        { 
           Attachment billattachment = new Attachment();
            billattachment = listWrappersBill[i].billattach;
           listWrappersBill[i].billattach.parentid= listWrappersBill[i].bill.id;
            listattach.add(listWrappersBill[i].billattach);
            
            system.debug('Before Inserted' +listattach);
            
        }
        if(listattach.size()>0)
        {
           insert listattach;
            system.debug('Attached list'+listattach);
        }
          
        System.debug('Insert Done');
            PageReference PageRef = new PageReference('/apex/sucess');
            p.clear();
            app.clear();
            return PageRef;
     }




 
//controller
global class applicationcontrollernew
{
    
    public Wrapperhospital wrapper {get; set;}
    public List<Wrapperhospital> listWrappers {get;set;}
    public Wrapperpharm wrapperpharm {get; set;}
    public List<Wrapperpharm> listpharmWrappers {get;set;}
    
    public WrapperBillObject Wrapperbill {get; set;}
    public List<WrapperBillObject> listWrappersBill {get;set;}
    public List<WrapperBillObject> attachmentlist {get;set;}
    public Patient__c p {get; set;}
    public Contact c {get;set;}
    public Contact c1{get;set;}
    Public Contact c2{get;set;}
    public Application__c app {get;set;}
   
    Public Attachment adhaar{get;set;}
    
    Public Attachment fadhaar{get;set;}
   
    
    Public Attachment madhaar{get;set;}
    Public Attachment ration{get;set;}
  
    
    Public Attachment passport{get;set;}
   
    
    
    Public Attachment Supporting{get;set;}
   
    Public Attachment hospitalpoto {get;set;}
  
    Public Attachment familypoto {get;set;}
  
    
    
    
    public applicationcontrollernew()
    {
        p = new Patient__c();
        c=  new Contact();
        c1=  new Contact();
        c2=  new Contact();  
        app= new Application__c();
        
        adhaar= new Attachment();
        fadhaar= new Attachment();
        madhaar = new Attachment();
        ration = new Attachment();
        passport = new Attachment();
        hospitalpoto = new Attachment();
        familypoto = new Attachment();
        supporting = new Attachment();
        
        
        
        listWrappers = new List<Wrapperhospital>();
        wrapper = new Wrapperhospital();
        listWrappers.add(wrapper);
        listpharmWrappers = new List<Wrapperpharm>();             
        wrapperpharm = new Wrapperpharm();
        listpharmWrappers.add(wrapperpharm);
        listWrappersBill = new List<WrapperBillObject>(); 
       
        attachmentlist  = new  List<WrapperBillObject>();
        Wrapperbill = new WrapperBillObject();
        listWrappersBill.add(Wrapperbill);
        
       
    }
    public class Wrapperhospital 
    {
        public Medical_Facility__c hospital{get;set;} // our target hospital inside Wrapper
       
        public Wrapperhospital() 
        {
            hospital = new Medical_Facility__c(); 
           // every Wrapper have hospital
        }
    }
    
    public void  addhospital() 
    { // called from vf
        Wrapperhospital wrapper = new Wrapperhospital();
        
        
        listWrappers.add(wrapper); // vf render this list with new added wrapper
        
    }
    
    
    public class Wrapperpharm
    {
        public Pharmacy__c Pharmacy{get;set;} // our target Pharmacy inside Wrapper
        public Wrapperpharm() 
        {
            pharmacy = new Pharmacy__c (); // every Wrapper have Pharmacy
        }
    }
    public void  addpharmacy() 
    { // called from vf
        Wrapperpharm  wrapperpharm  = new Wrapperpharm();
        
        
        listpharmWrappers.add( wrapperpharm); // vf render this list with new added wrapper
        
    }
    public class WrapperBillObject
    {
        public Bills_And_Payments__c bill{get;set;} // our target hospital inside Wrapper
        public Attachment billattach{get;set;}

        public WrapperBillObject() 
        {
            bill = new  Bills_And_Payments__c();
            billattach = new Attachment();
           billattach.Name= billattach.name;
          billattach.Body= billattach.body;
          
        }
    }
    public void  addbills() 
    { // called from vf
        WrapperBillObject wrapperbill = new WrapperBillObject();
        listWrappersBill.add( wrapperbill);
        
    
    }
    
   
    public PageReference save() 
    {
          
        String cert = p.CertificateNumber__c;
        
        List<Patient__c> temp = new List<Patient__c>();
        temp = [SELECT Id, CertificateNumber__c FROM Patient__c where CertificateNumber__c =:cert];
        if(temp.size()==0)
        {
            insert p;
           
        }
        
        else
        {
            p.id=temp[0].id;
            update p;
        }
         
        system.debug('Patient' +p);
       
        List<Contact> contactlist = new List<Contact>();
        
            c.Patient__c=p.id;
            c.Contact_Type__c='Applicant';
            contactlist.add(c);
            c1.Patient__c=p.id;
            c1.Contact_Type__c='Emergency Contact';
            contactlist.add(c1);            
            c2.Patient__c=p.Id;
            c2.Contact_Type__c='Emergency Contact';
            contactlist.add(c2);  
        insert contactlist;
        system.debug('Contactlist'+ contactlist);
            app.Patient__c= p.Id;
         app.Applicant_Name__c=p.Applicant_Name__c;
            insert app;
           
        List<Attachment>  attachlist = new List <Attachment>();
       
        
        Attachment adhaar  = new Attachment(parentid=app.id, Name = adhaar.name , Body = adhaar.body);
        attachlist.add(adhaar);
        
        Attachment fadhaar  = new Attachment(parentid=app.id, Name = fadhaar.name , Body = fadhaar.body);
       
         if(fadhaar.name!=null)
             {
        attachlist.add(fadhaar);
             }
            Attachment madhaar  = new Attachment(parentid=app.id, Name = madhaar.name , Body = madhaar.body);
         if(madhaar.name!=null)
             {
        attachlist.add(madhaar);
             }
          
            Attachment passport  = new Attachment(parentid=app.id, Name = passport.name, Body = passport.body);
           attachlist.add(passport);
          
            Attachment hospitalpoto = new Attachment(parentid=app.id, Name = hospitalpoto.name, Body = hospitalpoto.body);
             if(hospitalpoto.name!=null)
             {
        attachlist.add(hospitalpoto);
             }
            Attachment ration =new Attachment(parentid=app.id, Name = ration.name, Body = ration.body);
                attachlist.add(ration);
            Attachment familypoto = new Attachment(parentid=app.id, Name = familypoto.name, Body = familypoto.body);
            if(familypoto.name!=null)
            {
                attachlist.add(familypoto);
            }
        
         Attachment Supporting = new Attachment(parentid=app.id, Name = Supporting.name, Body = Supporting.body);
           
       
        if(Supporting.name!=NULL)
        {
           attachlist.add(Supporting);
        }
            insert attachlist;
            List<Medical_Facility__c> listhospitals = new List<Medical_Facility__c>();
            for (Wrapperhospital wrapper : listWrappers) 
            { 
                wrapper.hospital.Application__c= app.id;
                listhospitals.add(wrapper.hospital);
                
            }
            if(wrapper.hospital.Hospital_Name__c != NULL)
            {
            insert listhospitals;
                system.debug('Hospitals'+listhospitals);
            }
  
        
            List<Pharmacy__c> listpharmacy = new List<Pharmacy__c>();
            for (Wrapperpharm  wrapperpharm  :  listpharmWrappers ) 
            { 
                wrapperpharm.pharmacy.Application__c= app.id;
                listpharmacy.add(wrapperpharm.pharmacy);
                
            }
            if(wrapperpharm.pharmacy.Pharmacy_Name__c != NULL)
            {
            insert listpharmacy;
               system.debug('Pharmcy'+listpharmacy);  
            }
            
            
            List<Bills_And_Payments__c> listofbills = new List <Bills_And_Payments__c>();
       
          
        for (WrapperBillObject wrapperbill : listWrappersBill) 
            { 
                wrapperbill.bill.Application__c= app.id;
               
                listofbills.add(wrapperbill.bill);
            }
          if(wrapperbill.bill.Total_Bill_Amount__c!= 0)
          {
            insert listofbills;
              system.debug('Bill Inserted' +listofbills);
          }
        
         List<Attachment> listattach= new List<Attachment>();
       
        system.debug('Attachment Lsit'+listWrappersBill);
        
     for (integer i=0;i< listWrappersBill.size();i++)
        { 
           Attachment billattachment = new Attachment();
            billattachment = listWrappersBill[i].billattach;
           listWrappersBill[i].billattach.parentid= listWrappersBill[i].bill.id;
            listattach.add(listWrappersBill[i].billattach);
            
            system.debug('Before Inserted' +listattach);
            
        }
        if(listattach.size()>0)
        {
           insert listattach;
            system.debug('Attached list'+listattach);
        }
          
        System.debug('Insert Done');
            PageReference PageRef = new PageReference('/apex/sucess');
            p.clear();
            app.clear();
            return PageRef;
     }




 
Hi Guys, 

Has anyone tried Cybersource silent order API integration with Salesforce? Looking for some help.
Thanks in advance.

Thanks,
Prashant.
Greetings - is there a way to roll up total "Total Price" to include the Subtotal and PM Fees, which is a formula custom field needed in each quote? Ideally, Total Price and Grand Total should read $3,003.00, and both are roll-up summary standard fields. 

Please advise.

-Cole

User-added image