• rakhi78
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies

Hi,

 

I have pdf document attached with Notes and attachment in a specific object. Is there a way to export those pdf documnet to external server. I cannot send those documnet attached in a mail because of security reason. Please advice if there is a way to export the pdf documnets without email attachment.

  • September 18, 2009
  • Like
  • 0
 
/*
 *  This class which extends the Dispense__c standard controller is utilized by the refillrequest
 *  Visualforce page to default values for the user from the related refill request Page during 
 *  the creation of a new refill requset.  It also provides an action that generates the PDF and creates 
 *  an attachment under the parent dispense record who's id is passed into the same Visualforce page 
 *  that can be accessed in the UI to generate the same PDF.
 */
public class refillrequestExt {

    /* The standard controller object which will be used later for navigation and to invoke
       it's save action method to create the new refill request. */
    ApexPages.StandardController controller;
    private final Dispense__c dispense;
    /* The quote property which is used by the quoteNew and quotePDF Pages and this controller
       to provide access to the relevant quote information. */
    public Dispense__c d {get;set;}
    
    /* The constructor to this extension class which takes the standard controller as its argument
       which allows this class to access the methods and information available in the instance for 
       the refill request.*/
    public refillrequestExt(ApexPages.StandardController c) 
    {
        controller = c;
        d      =  (Dispense__c) c.getRecord();
        
         /* If non-null, get the opportunity and contact role for appropriate defaulting of values. */
        String theId = ApexPages.currentPage().getParameters().get('id');
        If(theId!= null)
        {
        dispense = [select Id, Name, Dispense__c.Prescription_ID__r.Pharmacy__r.Name, Dispense__c.Prescription_ID__r.Pharmacy__r.Main_Referral_Phone__c, Dispense__c.Pharmacy_Fax__c, Dispense__c.Patient_First_Name__c,Dispense__c.Patient_MRN__r.Patient_Address_1__c,Dispense__c.Patient_MRN__r.Patient_Address_2__c
                    from Dispense__c
                    where id = :theId];
        }
        //
     }
    public Dispense__c getDispense() 
    {
        return dispense;
    }
    
    /* This save method will be called instead of the standard controller save method when bound
       to an action component in an associated page, (apex:commandButton on the quoteNew 
       Visualforce page in this example) */
    public PageReference save() {
    
        /* Invoke the standard controller save method which returns the pageReference class 
           that will be used in the navigation, i.e. send the user to the expected location based on
           standard navigation rules provided by salesforce.com */
        PageReference p = controller.save();
        
        /* The dispense's record Id */
        id did = controller.getId();
        
        
               
        /* Return the page reference generated by the standard controller save, which usually drops the user
           on the detail page for the newly created object. */
        return p;
        
    }
    
    /* The action method that will generate a PDF document from the RefillRequestPDF page and attach it to 
       the dispense provided by the standard controller. Called by the action binding for the attachQuote
       page, this will do the work and take the user back to the quote detail page. */
    public PageReference attachRefillRequest() {
        /* Get the page definition */
        PageReference pdfPage = Page.RefillRequest;
        
        /* set the dispense id on the page definition */
        pdfPage.getParameters().put('id',d.id);
        
        /* generate the pdf blob */
        Blob pdfBlob = pdfPage.getContent();
        
        /* create the attachment against the dispense */
        Attachment a = new Attachment(parentId = d.id, name=d.name + '.pdf', body = pdfBlob);
        
        /* insert the attachment */
        insert a;
        
        /* send the user back to the dispense detail page */
        return controller.view();
    }
}
 This is my visual force page. when user clicks save the page needs to get converted to pdf and attch as a attachment in dispense_c object particualr record.
<apex:page id="RefillApproval" standardController="Dispense__c"  Extensions="refillrequestExt" showHeader="false" sidebar="false" >


<apex:form >

<table width="100%" columns="1">
<tr><td align="center"><img width="200" height="50" src="/servlet/servlet.ImageServer?id=015Q00000004m7k&oid=00DQ00000008eNT"/></td></tr>
<tr><td align="center"><apex:outputText ><h4>{!Dispense__c.Prescription_ID__r.Pharmacy__r.Name}</h4></apex:outputText></td></tr>
<tr><td align="center"><apex:outputText value="Phone: {!Dispense__c.Prescription_ID__r.Pharmacy__r.Main_Referral_Phone__c}"/></td></tr>
<tr><td align="center"><apex:outputText value="Fax: {!Dispense__c.Pharmacy_Fax__c}"/></td></tr>
</table><br></br>

<table width="100%" columns="2">
<tr><td width="50%"><apex:outputText ><h4>Patient:</h4></apex:outputText></td>
<td width="50%"><apex:outputText ><h4>Physician:</h4></apex:outputText></td></tr>
<tr><td width="50%"><apex:outputText value="{!Dispense__c.Patient_First_Name__c} {!Dispense__c.Patient_Last_Name__c}"/></td>
<td width="50%"><apex:outputText value="{!Dispense__c.Prescription_ID__r.Physician_First_Name__c} {!Dispense__c.Prescription_ID__r.Physician_Last_Name__c}"/></td></tr>
<tr><td width="50%"><apex:outputText value="{!Dispense__c.Patient_MRN__r.Patient_Address_1__c} {!Dispense__c.Patient_MRN__r.Patient_Address_2__c}"/></td>
<td width="50%"><apex:outputText value="{!Dispense__c.Prescription_ID__r.Physician_Address_1__c} {!Dispense__c.Prescription_ID__r.Physician_Address_2__c}"/></td></tr>
<tr><td width="50%"><apex:outputText value="{!Dispense__c.Patient_MRN__r.Patient_City__c}, {!Dispense__c.Patient_MRN__r.Patient_State_Province__c} {!Dispense__c.Patient_MRN__r.Patient_Zip_Postal_Code__c}"/></td>
<td width="50%"><apex:outputText value="{!Dispense__c.Prescription_ID__r.Physician_City__c}, {!Dispense__c.Prescription_ID__r.Physician_State__c} {!Dispense__c.Prescription_ID__r.Physician_Zip_Code__c}"/></td></tr>
<tr><td width="50%"><apex:outputText value="DOB: {!Dispense__c.Patient_MRN__r.Birthdate__c}"/></td>
<td width="50%"><apex:outputText value="Phone: {!Dispense__c.Prescription_ID__r.Physician_Phone__c}"/></td></tr>
<tr><td width="50%"><apex:outputText value="Phone: {!Dispense__c.Patient_MRN__r.Primary_Phone__c}"/></td>
<td width="50%"><apex:outputText value="Fax: {!Dispense__c.Prescription_ID__r.Physician_Fax__c}"/></td></tr>
<tr><td width="50%"><apex:outputText value="Sex: {!Dispense__c.Patient_MRN__r.Gender__c}"/></td>
<td width="50%"><apex:outputText value="DEA No: {!Dispense__c.Prescription_ID__r.Physician_DEA__c}"/></td></tr>
<tr><td width="50%"><apex:outputText value="MRN: {!Dispense__c.Patient_MRN__r.Name}"/></td></tr>
</table><br></br>

<table width="100%" columns="1" align="center">
<tr><td align="center"><apex:outputText ><h4>REFILL REQUEST - {!Dispense__c.Drug_Compound_Name__c}</h4></apex:outputText></td></tr>
<tr><td align="center"><apex:outputText value="Patient has been receiving this medication and the last refill was {!Dispense__c.Last_Dispensed__c}."/></td></tr>
</table><br></br>

<table width="100%" columns="2">
<tr><td colspan="2"><apex:outputText ><h4>Prescription:</h4></apex:outputText></td>
<td></td></tr>
<tr><td><apex:outputText value="Medication:"/></td>
<td><apex:inputText id="Medication" size="50" style="border: 2px" value="{!Dispense__c.Drug_Compound_Name__c}"/></td></tr>
<tr><td><apex:outputText value="Sig:"/></td>
<td><apex:inputText id="Sig" size="50" style="border: 2px" value="{!Dispense__c.Rx_Type__c} {!Dispense__c.Dose__c} {!Dispense__c.Frequency__c}"/></td></tr>
<tr><td><apex:outputText value="Dispense #:"/></td>
<td><apex:inputText id="Number" size="50" style="border: 2px" value="{!Dispense__c.Referral_Item_Quantity__c}"/></td></tr>
<tr><td><apex:outputText value="Refill x's:"/></td>
<td><apex:inputText id="Refills" size="50" style="border: 2px" value="{!Dispense__c.Total_Refills_Authorized__c}"/></td></tr>
<tr><td height="10" /></tr>
<tr><td><apex:outputText ><h4>Comments:</h4></apex:outputText></td>
<td><apex:inputTextarea cols="52" style="border: 2px" rows="2"/></td></tr>
<tr><td height="10" /></tr>
<tr><td><apex:outputText ><h4>Submitted by: </h4></apex:outputText></td>
<td><apex:outputText value="{!$User.FirstName} {!$User.LastName}"/></td></tr>
<tr><td><apex:outputText ><h4>Phone: </h4></apex:outputText></td>
<td><apex:outputText value="{!$User.Phone}"/></td></tr>
<tr><td><apex:outputText ><h4>Date: </h4></apex:outputText></td>
<td><apex:outputText value=" {!Today()}"/></td></tr>
<tr><td height="10" /></tr>
<tr><td colspan="2"><apex:outputText ><h4><i>Submitted from US Bioservices Physician Portal.</i></h4></apex:outputText></td></tr>
<tr><td height="10" /></tr>
<tr><td colspan="2"><apex:outputText >Submission Terms - By clicking the "Submit" button below, you certify your authorization to prescribe
<br>for this patient, approve the electronic submission of this form, and understand that a pharmacist
<br>may also follow up with you via phone.</br></br>
</apex:outputText></td></tr>
</table>

<table align="center" width="100%"><tr><td align="center">
<apex:commandButton value="Submit" title="Submit" action="{!attachRefillRequest}"/>
<apex:commandButton value="Print" title="Print Copy" onclick="navigateToUrl('javascript&colon;window.print%28%29%3B')"/>
<apex:commandButton value="Close" title="Close Window" onclick="navigateToUrl('javascript&colon;window.close%28%29%3B')"/>
</td></tr></table>

</apex:form>

</apex:page>
  • September 14, 2009
  • Like
  • 0

trigger PhyPortalPatientApexSharing on Patient__c (after insert, after update)
{
    // CREATE A NEW LIST OF SHARING OBJECTS FOR PATIENT.
    List<Patient__Share> patientShrs  = new List<Patient__Share>();
  
    // DECLARE VARIABLES FOR PATIENT SHARING.
    Patient__Share physicianShr;
    Patient__Share patientShr;
      
    for(Patient__c p : Trigger.new)
    {
        // for associated prescription associated protal user.
       for(Prescription__c prescriptions : [Select id,Patient_MRN__c,r.Physician_Contact__r.Portal_User_ID__c   From Prescription__c r where r.Physician_Contact__r.Portal_User_ID__c!=null])
       {
       if(prescriptions != NULL)
       {
       // select the id of patient that needs to be shared with the user whcih is attched with prescription
          Patient__c Patient = [Select id, name From Patient__c Where name=:prescriptions.Patient_MRN__c];
           
            // INSTANTIATE THE SHARING OBJECTS.
          
            physicianShr = new Patient__Share();
           
            // SET THE ID OF THE RECORD BEING SHARED.
            physicianShr.ParentId = Patient.id;
           
            // GET THE ID OF THE RELATED USER BEING GRANTED ACCESS. THERE MAY BE MORE THAN 1
            // PHYSICIAN PORTAL USER TO SHARE TO.
           //Prescription__c pe = [Select Physician_Contact__r.Portal_User_ID__c From Prescription__c Where Id=:prescriptions.Id];
                             
            // SET THE ID OF THE USER BEING GRANTED ACCESS.
            physicianShr.UserOrGroupId = prescriptions.Physician_Contact__r.Portal_User_ID__c ;
                                   
            // SET THE ACCESS LEVEL.
            physicianShr.AccessLevel = 'read';
                       
            // SET THE APEX SHARING REASON FOR PHYSICIAN.
            physicianShr.RowCause = Schema.Patient__Share.RowCause.Physician_Portal_User__c;
                       
            // ADD OBJECTS TO LIST FOR INSERT.
            patientShrs.add(physicianShr);
                           }//end of for loop
       }//edn if loop
            }
                 
    // INSERT SHARING RECORDS AND CAPTURE SAVE RESULT.
    // FALSE PARAMETER ALLOWS FOR PARTIAL PROCESSING OF MULTIPLE RECORDS.
    Database.SaveResult[] lsr = Database.insert(patientShrs,false);
    // CREATE COUNTER
    Integer i=0;
       
    // PROCESS SAVE RESULTS
    for(Database.SaveResult sr : lsr)
    {
        if(!sr.isSuccess())
        i++;  
    }
}

 

 

 

Can some one please tell me why I am getting no rows for assignment to SObject: Trigger

// WHEN NEW PATIENT IS ADDED OR UPDATED, TRIGGER CREATES A PATIENT__SHARE IF AN ASSOCIATED PORTAL
// USER EXISTS.  IF NOT, PATIENT SHOULD BE ADDED WITHOUT SHARING OR ERROR.

trigger PhyPortalPatientApexSharing on Patient__c (after insert, after update)
{

    // CREATE A NEW LIST OF SHARING OBJECTS FOR PATIENT.
    List<Patient__Share> patientShrs  = new List<Patient__Share>();
     //Map<ID,Patient__c> posIdToPatientMap = new Map<ID,Patient__c>(); // Map of PositionId-->Patient__c record  
    // DECLARE VARIABLES FOR PATIENT SHARING.
    Patient__Share physicianShr;
    Patient__Share patientShr;
      
    for(Patient__c p : Trigger.new)
    {
        // FOR ASSOCIATD REFERRALS FIND ASSOCIATED PORTAL USER.
       for(List<Prescription__c> prescriptions : [Select id,Patient_MRN__c,r.Physician_Contact__r.Portal_User_ID__c,Patient_MRN__r.id   From Prescription__c r where r.Physician_Contact__r.Portal_User_ID__c!=null])
       {
       if(prescriptions.Prescription__c != null)
       {
          for(List<Patient__c> Patients : [Select id, name From Patient__c Where name=:prescriptions.Patient_MRN__c])
            {
            // loop thru the list of interviewers and create sharing records
                for(Patient__c p1 : Patients)
                {
            // INSTANTIATE THE SHARING OBJECTS.
          
            physicianShr = new Patient__Share();
           
            // SET THE ID OF THE RECORD BEING SHARED.
            physicianShr.ParentId = p1.id;
           
            // GET THE ID OF THE RELATED USER BEING GRANTED ACCESS. THERE MAY BE MORE THAN 1
            // PHYSICIAN PORTAL USER TO SHARE TO.
           //Prescription__c pe = [Select Physician_Contact__r.Portal_User_ID__c From Prescription__c Where Id=:prescriptions.Id];
                             
            // SET THE ID OF THE USER BEING GRANTED ACCESS.
            physicianShr.UserOrGroupId = prescriptions.Physician_Contact__r.Portal_User_ID__c ;
                                   
            // SET THE ACCESS LEVEL.
            physicianShr.AccessLevel = 'read';
                       
            // SET THE APEX SHARING REASON FOR PHYSICIAN.
            physicianShr.RowCause = Schema.Patient__Share.RowCause.Physician_Portal_User__c;
                       
            // ADD OBJECTS TO LIST FOR INSERT.
            patientShrs.add(physicianShr);
            }//end of for loop
            }//end of for loop
       }//end of for loop
       }//edn if loop
            }

trigger PhyPortalPatientApexSharing on Patient__c (after insert, after update)
{
    // CREATE A NEW LIST OF SHARING OBJECTS FOR PATIENT.
    List<Patient__Share> patientShrs  = new List<Patient__Share>();
  
    // DECLARE VARIABLES FOR PATIENT SHARING.
    Patient__Share physicianShr;
    Patient__Share patientShr;
      
    for(Patient__c p : Trigger.new)
    {
        // for associated prescription associated protal user.
       for(Prescription__c prescriptions : [Select id,Patient_MRN__c,r.Physician_Contact__r.Portal_User_ID__c   From Prescription__c r where r.Physician_Contact__r.Portal_User_ID__c!=null])
       {
       if(prescriptions != NULL)
       {
       // select the id of patient that needs to be shared with the user whcih is attched with prescription
          Patient__c Patient = [Select id, name From Patient__c Where name=:prescriptions.Patient_MRN__c];
           
            // INSTANTIATE THE SHARING OBJECTS.
          
            physicianShr = new Patient__Share();
           
            // SET THE ID OF THE RECORD BEING SHARED.
            physicianShr.ParentId = Patient.id;
           
            // GET THE ID OF THE RELATED USER BEING GRANTED ACCESS. THERE MAY BE MORE THAN 1
            // PHYSICIAN PORTAL USER TO SHARE TO.
           //Prescription__c pe = [Select Physician_Contact__r.Portal_User_ID__c From Prescription__c Where Id=:prescriptions.Id];
                             
            // SET THE ID OF THE USER BEING GRANTED ACCESS.
            physicianShr.UserOrGroupId = prescriptions.Physician_Contact__r.Portal_User_ID__c ;
                                   
            // SET THE ACCESS LEVEL.
            physicianShr.AccessLevel = 'read';
                       
            // SET THE APEX SHARING REASON FOR PHYSICIAN.
            physicianShr.RowCause = Schema.Patient__Share.RowCause.Physician_Portal_User__c;
                       
            // ADD OBJECTS TO LIST FOR INSERT.
            patientShrs.add(physicianShr);
                           }//end of for loop
       }//edn if loop
            }
                 
    // INSERT SHARING RECORDS AND CAPTURE SAVE RESULT.
    // FALSE PARAMETER ALLOWS FOR PARTIAL PROCESSING OF MULTIPLE RECORDS.
    Database.SaveResult[] lsr = Database.insert(patientShrs,false);
    // CREATE COUNTER
    Integer i=0;
       
    // PROCESS SAVE RESULTS
    for(Database.SaveResult sr : lsr)
    {
        if(!sr.isSuccess())
        i++;  
    }
}

 

 

 

Can some one please tell me why I am getting no rows for assignment to SObject: Trigger

// WHEN NEW PATIENT IS ADDED OR UPDATED, TRIGGER CREATES A PATIENT__SHARE IF AN ASSOCIATED PORTAL
// USER EXISTS.  IF NOT, PATIENT SHOULD BE ADDED WITHOUT SHARING OR ERROR.

trigger PhyPortalPatientApexSharing on Patient__c (after insert, after update)
{

    // CREATE A NEW LIST OF SHARING OBJECTS FOR PATIENT.
    List<Patient__Share> patientShrs  = new List<Patient__Share>();
     //Map<ID,Patient__c> posIdToPatientMap = new Map<ID,Patient__c>(); // Map of PositionId-->Patient__c record  
    // DECLARE VARIABLES FOR PATIENT SHARING.
    Patient__Share physicianShr;
    Patient__Share patientShr;
      
    for(Patient__c p : Trigger.new)
    {
        // FOR ASSOCIATD REFERRALS FIND ASSOCIATED PORTAL USER.
       for(List<Prescription__c> prescriptions : [Select id,Patient_MRN__c,r.Physician_Contact__r.Portal_User_ID__c,Patient_MRN__r.id   From Prescription__c r where r.Physician_Contact__r.Portal_User_ID__c!=null])
       {
       if(prescriptions.Prescription__c != null)
       {
          for(List<Patient__c> Patients : [Select id, name From Patient__c Where name=:prescriptions.Patient_MRN__c])
            {
            // loop thru the list of interviewers and create sharing records
                for(Patient__c p1 : Patients)
                {
            // INSTANTIATE THE SHARING OBJECTS.
          
            physicianShr = new Patient__Share();
           
            // SET THE ID OF THE RECORD BEING SHARED.
            physicianShr.ParentId = p1.id;
           
            // GET THE ID OF THE RELATED USER BEING GRANTED ACCESS. THERE MAY BE MORE THAN 1
            // PHYSICIAN PORTAL USER TO SHARE TO.
           //Prescription__c pe = [Select Physician_Contact__r.Portal_User_ID__c From Prescription__c Where Id=:prescriptions.Id];
                             
            // SET THE ID OF THE USER BEING GRANTED ACCESS.
            physicianShr.UserOrGroupId = prescriptions.Physician_Contact__r.Portal_User_ID__c ;
                                   
            // SET THE ACCESS LEVEL.
            physicianShr.AccessLevel = 'read';
                       
            // SET THE APEX SHARING REASON FOR PHYSICIAN.
            physicianShr.RowCause = Schema.Patient__Share.RowCause.Physician_Portal_User__c;
                       
            // ADD OBJECTS TO LIST FOR INSERT.
            patientShrs.add(physicianShr);
            }//end of for loop
            }//end of for loop
       }//end of for loop
       }//edn if loop
            }

Hi,
 
I have textarea field and when I hit save button I need to send this value to save method inside controller.
Code:
<apex:inputTextarea id="personaltag_edit_area" rows="1"  cols="50100"/>

 when user hit save button I need to send this value (whatever user type in this textarea) to save method inside controller class and want to save this value in account tag table.
 
Can someone point me how to redirect value in controller?
 
-Thanks in advance