• NSK000
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 11
    Replies
Hi guys,

I'm having issues calling an url from salesforce. 
Here is th code.
private final String clientId = 'xxxxxxxxx';
private final String clientSecret = 'xxxxxx';
String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret;
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setBody(reqbody);
request.setMethod('GET');
request.setEndpoint('http://xxxx/api/xx-xxx-xxxxxxx-api/v1.0/getEmplId?firstName=xxx&lastName=xxx&middleName=xx');
HttpResponse response = http.send(request);
if (response.getStatusCode() != 201) {
  System.debug('The status code returned was not expected: ' +
       response.getStatusCode() + ' ' + response.getStatus());
} else {
   System.debug(response.getBody());
}
I'm getting the following message - response|"System.HttpResponse[Status=Service Unavailable, StatusCode=503]".
I've added the site url in salesforce. 

Please let me what I'm doing wrong?!

Appreciate your help!

Thanks,
NSK
 
I need to get the data from JSON into salesforce object(custom object).  
Following is the JSON - 
{"EMPL_TYPE":" ","GRADE":"19","STD_HOURS":40.00,"EMPLID":"JCSD"}

I have a custom object in salesforce and I need to get the above values into their respective fields when i click a button on the custom object.
My code is as follows-

public class Empdetails {
public String EMPL_TYPE;
public String GRADE;
public Double STD_HOURS;
public String EMPLID;
public static Empdetails parse(String EMPLID) {
        Http httpProtocol = new Http();
        HttpRequest request = new HttpRequest(); 
        request.setEndpoint('xyz'+EMPLID);
        request.setMethod('GET'); 
        HttpResponse response = httpProtocol.send(request);
        system.debug(response.getBody());
        String jsonString = response.getBody();
        // Parse JSON response to get all the Employee record details
        JSONParser parser = JSON.createParser(response.getBody());
        return (Empdetails) System.JSON.deserialize(EMPLID, Empdetails.class);
    }
}

Actually I'm new to this concept. Am I doing correct ? Please suggest me some inputs.
Thank you
I need to get the data from JSON into salesforce object(custom object).  
Following is the JSON - 
{"EMPL_TYPE":" ","GRADE":"19","STD_HOURS":40.00,"EMPLID":"JCSD"}

I have a custom object in salesforce and I need to get the above values into their respective fields when i click a button on the custom object.
My code is as follows-

public class Empdetails {
public String EMPL_TYPE;
public String GRADE;
public Double STD_HOURS;
public String EMPLID;
public static Empdetails parse(String EMPLID) {
        Http httpProtocol = new Http();
        HttpRequest request = new HttpRequest(); 
        request.setEndpoint('xyz'+EMPLID);
        request.setMethod('GET'); 
        HttpResponse response = httpProtocol.send(request);
        system.debug(response.getBody());
        String jsonString = response.getBody();
        // Parse JSON response to get all the Employee record details
        JSONParser parser = JSON.createParser(response.getBody());
        return (Empdetails) System.JSON.deserialize(EMPLID, Empdetails.class);
    }
}

Actually I'm new to this concept. Am I doing correct ? Please suggest me some inputs.
Thank you 
I'm trying to create a vf page- its more like a review/feedback form. 

<apex:page standardController="Purchase_Order__C" extensions="PO_VendorPerformanceForm" >
<apex:form>
 <apex:pageBlock > 
                    <apex:outputPanel >
                <apex:pageBlockSection title="Submitted by:" showHeader="true" collapsible="false">
                    <apex:outputText value="Name: {!Purchase_Order__c.Requesitioner_Liaison__r.name}"/>
                    <apex:outputText value="Date: {!today()}"/>                    
                    <apex:outputText value="Division Name: {!Purchase_Order__c.Division_Name__c}"/> 
                    <apex:outputText value="Division No: {!Purchase_Order__c.Requesitioner_Liaison__r.DivisionNum__c}"/> 
                    <apex:outputText value="Title: {!Purchase_Order__c.Requesitioner_Liaison__r.Title}"/>
                </apex:pageBlockSection>
                    </apex:outputPanel> 
            </apex:pageBlock>
            <apex:pageBlock >
                <apex:pageBlockSection title="1. Contract Designation:" collapsible="false">
                    <apex:pageBlockSectionItem > 
                        <apex:selectcheckboxes >
                            <apex:selectOption itemLabel="Commodities" itemValue="f"/>
                            <apex:selectOption itemLabel="Services" itemValue="cpp"/>    
                        </apex:selectcheckboxes>     
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>
            </apex:pageBlock>
</apex:form>
</apex:page>

Controller: 
public class PO_VendorPerformanceForm {
 public PO_VendorPerformanceForm(ApexPages.StandardController controller) {
        Purchase_Order__c po = (Purchase_Order__c)controller.getRecord();
        parentId = po.Id;
        pdfName = po.Name + '-VPR';
    }
 public ID parentId {get;set;}
    public String pdfName {get;set;}
    public string contentType {get;set;}
    
    /*    SAVE PDF     */
    public PageReference savePdf() {
        // ATTACH VPR TO PO
        // Get PDF of Vendor Perf. Form
        PageReference pdf = Page.POVendorPerfForm;
        pdf.getParameters().put('id',parentId);
        // Initialize attachment
        Attachment attach = new Attachment();
        // the contents of the attachment from the pdf
        Blob body;
        try {
            body = pdf.getContentAsPDF(); // PDF body
        } catch (VisualforceException e) {
            body = Blob.valueOf('Some Text');
        }
        
        attach.Body = body;
        attach.Name = pdfName + '.pdf';
        attach.IsPrivate = false;
        attach.ParentId = parentId; // PO's Id
       
        insert attach;
        
        // (Future) Send Email
        sendEmail(attach.Id);
        return page.POVPRSuccessPage;
    }
    
    /* SEND EMAIL    */
    @future(callout=true)
    public static void sendEmail(Id vprFormId) {
        // Get VPR
        Attachment vprAttachment = [SELECT Id,Name,ParentId,Body,BodyLength 
                                    FROM Attachment 
                                    WHERE Id = :vprFormId];
        
        // Get Template
        EmailTemplate ev = [select id,name,Subject,Body 
                            from EmailTemplate 
                            where name='VPR_Email_template'];

        // Create Email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        List<Messaging.EmailFileAttachment> emailAttachments = new List<Messaging.EmailFileAttachment>();
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName(vprAttachment.Name);
        efa.setBody(vprAttachment.Body);
        emailAttachments.add(efa);
        email.setFileAttachments(emailAttachments);
        // Set "To" address
        List<String> toAddresses = new List<String>();
        toAddresses.add('xyz@gmail.com');
        email.setToAddresses(toAddresses);
        // Set "From" address (not applicable in this case)
        /*(OrgWideEmailAddress[] owea = [select Id 
                                      from OrgWideEmailAddress 
                                      where Address = ''];
        if (owea.size() > 0 ) {
            email.setOrgWideEmailAddressId(owea.get(0).Id);
        }*/
        email.subject = ev.Subject;
        email.setSaveAsActivity(True);
        email.setHtmlBody(ev.Body);
        List<Messaging.SendEmailResult> results = new List<Messaging.SendEmailResult>();
        results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
    }
}

The problem is I'm able to save the vf page as pdf but I'm not able to see the checkboxes in that pdf. Can some one help me with this ? 
I appreciate your help.  Thank you in advance!
  • December 15, 2017
  • Like
  • 0
Hi guys,
I need some help with the following code. I'm trying to write an apex class but getting errors. Please help me out with this. Thank you in advance.


Purchase_Order__c  po=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c where id= :ApexPages.currentPage().getParameters().get('id')];
    id myid=po.Original_Purchase_Order__c;
    if(po.POCN__c==0){
        system.debug('This is the original po');
        }
        if(po.POCN__c==1){
        purchase_order__c po1=[select Purchase_Order__c.Name, Purchase_Order__c.status__c, (select Name,id from Expenditures__r) from Purchase_Order__c  where id=:myid];
        List<Expenditures__c> e1 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po1.id];
        //return e1;
        system.debug('original po expenditure list '+e1);
        }
        if(po.POCN__c==2){
       purchase_order__c po1=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid];
        id myid1=po1.Original_Purchase_Order__c;
        purchase_order__c po2=[select Purchase_Order__c.Name from Purchase_Order__c  where id=:myid1];
        List<Expenditures__c> e2 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po2.id];
        system.debug('original po expenditure list '+e2);  
        } 
        if(po.POCN__c==3){
        purchase_order__c po1=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid];
        id myid1=po.Original_Purchase_Order__c;
        purchase_order__c po2=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid1];
        id myid2=po.Original_Purchase_Order__c;
        purchase_order__c po3=[select Purchase_Order__c.Name, Purchase_Order__c.status__c, (select Name,id from Expenditures__r) from Purchase_Order__c  where id=:myid2];
        List<Expenditures__c> e3 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po3.id];
        system.debug('original po expenditure list '+e3);   
        }
        if(po.POCN__c==4){
        purchase_order__c po1=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid];
        id myid1=po.Original_Purchase_Order__c;
        purchase_order__c po2=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid1];
        id myid2=po.Original_Purchase_Order__c;
        purchase_order__c po3=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid2];
        id myid3=po.Original_Purchase_Order__c;
        purchase_order__c po4=[select Purchase_Order__c.Name, Purchase_Order__c.status__c, (select Name,id from Expenditures__r) from Purchase_Order__c  where id=:myid3];    
        List<Expenditures__c> e4 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po4.id];
        system.debug('original po expenditure list '+e4);   
        }
        if(po.POCN__c==5){
        purchase_order__c po1=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid];
        id myid1=po.Original_Purchase_Order__c;
        purchase_order__c po2=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid1];
        id myid2=po.Original_Purchase_Order__c;
        purchase_order__c po3=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid2];
        id myid3=po.Original_Purchase_Order__c;
        purchase_order__c po4=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid3]; 
        id myid4=po.Original_Purchase_Order__c;
        purchase_order__c po5=[select Purchase_Order__c.Name, Purchase_Order__c.status__c, (select Name,id from Expenditures__r) from Purchase_Order__c  where id=:myid4];     
        List<Expenditures__c> e5 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po5.id];
        system.debug('original po expenditure list '+e5);   
        }
  • September 18, 2017
  • Like
  • 0
Hi guys,
Need some help with the test class. 
The controller class is below. Need to write test class for this one.

public class exp{
    public exp(ApexPages.StandardController controller)
{
    }
Purchase_Order__c  po=[select Original_Purchase_Order__c from Purchase_Order__c where id= :ApexPages.currentPage().getParameters().get('id')];
//Purchase_Order__c  po=[select Original_Purchase_Order__c from Purchase_Order__c where id='a4R7A000000S7Cm'];
id myid=po.Original_Purchase_Order__c;
purchase_order__c po1=[select Purchase_Order__c.Name, Purchase_Order__c.status__c, (select Name,id from Expenditures__r) from Purchase_Order__c  where id=:myid];
List<Expenditures__c> e1 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po1.id];
public List<Expenditures__c> getexpenditures()
{
return e1;
}
}
 
Hi guys, 
please take a look.
I have two objects expenditures and purchase orders(PO). They both have lookup relationship between them. And whenever a PO status is completed, it can't be edited. So whenever we want to edit the existing PO- we need to create another po with in the original po. So the newely created po has POCN__c=1 and original po has POCN__C = 0. Every po has its own expenditure list. Now, I need to display the list of expenditures of POCN__C= 0 on POCN__C = 1. I wrote the following code. I'm not that good at coding. i got the output but whenever i tried to click on the link it says URL no longer exists,,
Apex - 
public class ListOfExpenditures
{
public string  previousExp{get;set;}
public string  currentExp{get;set;}
public List<string> listOfStringName{get;set;}


public ListOfExpenditures(ApexPages.StandardController controller) 

Id prId = null;
        
//prId = ApexPages.CurrentPage().getparameters().get('id');
//Purchase_Order__c  po=[select Original_Purchase_Order__c from Purchase_Order__c where id='a4R7A000000S7E4'];

Purchase_Order__c  po=[select Original_Purchase_Order__c from Purchase_Order__c where id= :ApexPages.currentPage().getParameters().get('id')];


id myid=po.Original_Purchase_Order__c;
purchase_order__c po1=[select name,(select id,Name from Expenditures__r) from Purchase_Order__c  where id=:myid];

//System.debug(po1.name);
Id expId = null;
List<id> listOfIds;
listOfIds = new List<Id>();
for(Expenditures__c e:po1.Expenditures__r)
{
//System.debug(e.id);
expId = e.id;
listOfIds.add(expId);
}
listOfStringName = new List<string>();
List<Expenditures__c> exp = [select id,Name,Amount__c from Expenditures__c where id in :listOfIds];
for (Expenditures__c el : exp)
{
previousExp = string.valueOf(el.name);
listOfStringName.add(previousExp);
}
}
}
vf - 
<apex:page standardcontroller="Purchase_Order__c" extensions="ListOfExpenditures" >
    <apex:pageBlock title="List"  >    
        <apex:form >
       
        
                       
                           <apex:outputLink > {!listOfStringName}</apex:outputLink>
                      
                        
        </apex:form>
    </apex:pageBlock>
</apex:page>
 
Hi guys,
please help me out. i'm unable to understand what's causing the error.

Error element myWaitEvent_myWait_myRule_3_event_0_SA1 (FlowRecordUpdate).
The flow tried to update these records: null. This error occurred: CANNOT_EXECUTE_FLOW_TRIGGER: The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3017A0000004X7T. Flow error messages: An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.. For details, see API Exceptions.

This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Accounting_Process_When_PO_Status_is_Closed_Issued_to_Vendor
Type: Workflow
Version: 5
Status: Active
Flow Interview Details
Interview Label: Accounting_Process_When_PO_Status_is_Closed_Issued_to_Vendor-5_InterviewLabel
Current User: Siva Kishore Nandyala (0057A000001aFk1)
Start time: 6/1/2017 9:26 AM
Duration: 3,575 seconds
How the Interview Started
Siva Kishore Nandyala (0057A000001aFk1) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = a4R7A000000S7CmUAK
myVariable_current = a4R7A000000S7CmUAK
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "6/1/2017 9:26 AM"
DECISION: myPreWaitDecision_myWait_myRule_5
ASSIGNMENT: myWaitAssignment_myWait_myRule_5
{!cancelWaits} Add myWait_myRule_5
Result
{!cancelWaits} = "[myWait_myRule_5]"
DECISION: myPreWaitDecision_myWait_myRule_3
Executed this outcome: myPreWaitRule_myWait_myRule_3
Outcome conditions: and
1. {!myVariable_current.Advance_Payment_Required__c} (false) Equals false
2. {!myVariable_current.Status__c} (Closed - Issued to Vendor) Equals Closed - Issued to Vendor
3. {!myVariable_current.PO_Final__c} (false) Equals false
4. {!myVariable_current.Invoice_Included__c} (false) Equals false
5. {!myVariable_current.Employee_Reimbursement__c} (false) Equals false
Logic: All conditions must be true (AND)
DECISION: myDecision
DECISION: myDecision2
Executed this outcome: myRule_3
Outcome conditions: and
1. {!myVariable_current.Advance_Payment_Required__c} (false) Equals false
2. {!myVariable_current.Status__c} (Closed - Issued to Vendor) Equals Closed - Issued to Vendor
3. {!myVariable_current.PO_Final__c} (false) Equals false
4. {!myVariable_current.Invoice_Included__c} (false) Equals false
5. {!myVariable_current.Employee_Reimbursement__c} (false) Equals false
Logic: All conditions must be true (AND)
DECISION: myRule_3_pmetdec
WAIT: myWait_myRule_3
The waiting conditions for the following wait events were met.
Wait Event: myWaitEvent_myWait_myRule_3_event_0
Waiting Conditions:
1. {!myWaitEvent_myWait_myRule_3_event_0_postActionExecutionVariable} (false) Equals false
Logic: All conditions must be true (AND)

Event Type: Alarm: Absolute Time
Base Time = {!myVariable_waitStartTimeVariable} (6/1/2017 9:26 AM)
Offset Unit = Hours
Offset Number = 1
Result
Started waiting at 6/1/2017 9:26 AM.

The interview started waiting at 6/1/2017 9:26 AM.
The interview was resumed at 6/1/2017 10:26 AM by Siva Kishore Nandyala (0057A000001aFk1).

WAIT: myWait_myRule_3
Wait event myWaitEvent_myWait_myRule_3_event_0 occurred.
The following values from the event were assigned to flow variables.
None.
RECORD UPDATE: myWaitEvent_myWait_myRule_3_event_0_SA1
Find all Purchase_Order__c records where:
Id Equals {!myVariable_current.Id} (a4R7A000000S7CmUAK)
Update the records’ field values.
PO_Final__c = true
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: CANNOT_EXECUTE_FLOW_TRIGGER: The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3017A0000004X7T. Flow error messages: An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.. For details, see API Exceptions.
 
Hi,
Guys please look into this.
I have custom objects named Purchase order(PO) and Expenditures.Expenditure has a lookup to PO. When ever a PO status is 'completed' we can't edit the PO. If we need to edit an existing PO,we need to create another po with in the original or existing PO. So the newly created PO has POCN=1 where as the original po has POCN__c=0.  Every po has its expenditure related list. Now, I need to display the Expenditure list of POCN__c = 0 in POCN__c=1.
 
Hi,
Guys please take a look at this scenario.
I have a custom object named Purchase Order(PO). Once the status in this PO is updated to completed we can't edit it. So, if we need to edit any PO then we need to create another po with in the Original po. For the OriginalPO - pocn__c = 0 and for the newly created po- pocn__c=1. 
There is another object called Expenditure which has a lookup to the PO.
Now, I need to create a link on pocn>0 to display expenditure list of the original po.
Hi guys,

I'm having issues calling an url from salesforce. 
Here is th code.
private final String clientId = 'xxxxxxxxx';
private final String clientSecret = 'xxxxxx';
String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret;
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setBody(reqbody);
request.setMethod('GET');
request.setEndpoint('http://xxxx/api/xx-xxx-xxxxxxx-api/v1.0/getEmplId?firstName=xxx&lastName=xxx&middleName=xx');
HttpResponse response = http.send(request);
if (response.getStatusCode() != 201) {
  System.debug('The status code returned was not expected: ' +
       response.getStatusCode() + ' ' + response.getStatus());
} else {
   System.debug(response.getBody());
}
I'm getting the following message - response|"System.HttpResponse[Status=Service Unavailable, StatusCode=503]".
I've added the site url in salesforce. 

Please let me what I'm doing wrong?!

Appreciate your help!

Thanks,
NSK
 
I need to get the data from JSON into salesforce object(custom object).  
Following is the JSON - 
{"EMPL_TYPE":" ","GRADE":"19","STD_HOURS":40.00,"EMPLID":"JCSD"}

I have a custom object in salesforce and I need to get the above values into their respective fields when i click a button on the custom object.
My code is as follows-

public class Empdetails {
public String EMPL_TYPE;
public String GRADE;
public Double STD_HOURS;
public String EMPLID;
public static Empdetails parse(String EMPLID) {
        Http httpProtocol = new Http();
        HttpRequest request = new HttpRequest(); 
        request.setEndpoint('xyz'+EMPLID);
        request.setMethod('GET'); 
        HttpResponse response = httpProtocol.send(request);
        system.debug(response.getBody());
        String jsonString = response.getBody();
        // Parse JSON response to get all the Employee record details
        JSONParser parser = JSON.createParser(response.getBody());
        return (Empdetails) System.JSON.deserialize(EMPLID, Empdetails.class);
    }
}

Actually I'm new to this concept. Am I doing correct ? Please suggest me some inputs.
Thank you
I need to get the data from JSON into salesforce object(custom object).  
Following is the JSON - 
{"EMPL_TYPE":" ","GRADE":"19","STD_HOURS":40.00,"EMPLID":"JCSD"}

I have a custom object in salesforce and I need to get the above values into their respective fields when i click a button on the custom object.
My code is as follows-

public class Empdetails {
public String EMPL_TYPE;
public String GRADE;
public Double STD_HOURS;
public String EMPLID;
public static Empdetails parse(String EMPLID) {
        Http httpProtocol = new Http();
        HttpRequest request = new HttpRequest(); 
        request.setEndpoint('xyz'+EMPLID);
        request.setMethod('GET'); 
        HttpResponse response = httpProtocol.send(request);
        system.debug(response.getBody());
        String jsonString = response.getBody();
        // Parse JSON response to get all the Employee record details
        JSONParser parser = JSON.createParser(response.getBody());
        return (Empdetails) System.JSON.deserialize(EMPLID, Empdetails.class);
    }
}

Actually I'm new to this concept. Am I doing correct ? Please suggest me some inputs.
Thank you 
I'm trying to create a vf page- its more like a review/feedback form. 

<apex:page standardController="Purchase_Order__C" extensions="PO_VendorPerformanceForm" >
<apex:form>
 <apex:pageBlock > 
                    <apex:outputPanel >
                <apex:pageBlockSection title="Submitted by:" showHeader="true" collapsible="false">
                    <apex:outputText value="Name: {!Purchase_Order__c.Requesitioner_Liaison__r.name}"/>
                    <apex:outputText value="Date: {!today()}"/>                    
                    <apex:outputText value="Division Name: {!Purchase_Order__c.Division_Name__c}"/> 
                    <apex:outputText value="Division No: {!Purchase_Order__c.Requesitioner_Liaison__r.DivisionNum__c}"/> 
                    <apex:outputText value="Title: {!Purchase_Order__c.Requesitioner_Liaison__r.Title}"/>
                </apex:pageBlockSection>
                    </apex:outputPanel> 
            </apex:pageBlock>
            <apex:pageBlock >
                <apex:pageBlockSection title="1. Contract Designation:" collapsible="false">
                    <apex:pageBlockSectionItem > 
                        <apex:selectcheckboxes >
                            <apex:selectOption itemLabel="Commodities" itemValue="f"/>
                            <apex:selectOption itemLabel="Services" itemValue="cpp"/>    
                        </apex:selectcheckboxes>     
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>
            </apex:pageBlock>
</apex:form>
</apex:page>

Controller: 
public class PO_VendorPerformanceForm {
 public PO_VendorPerformanceForm(ApexPages.StandardController controller) {
        Purchase_Order__c po = (Purchase_Order__c)controller.getRecord();
        parentId = po.Id;
        pdfName = po.Name + '-VPR';
    }
 public ID parentId {get;set;}
    public String pdfName {get;set;}
    public string contentType {get;set;}
    
    /*    SAVE PDF     */
    public PageReference savePdf() {
        // ATTACH VPR TO PO
        // Get PDF of Vendor Perf. Form
        PageReference pdf = Page.POVendorPerfForm;
        pdf.getParameters().put('id',parentId);
        // Initialize attachment
        Attachment attach = new Attachment();
        // the contents of the attachment from the pdf
        Blob body;
        try {
            body = pdf.getContentAsPDF(); // PDF body
        } catch (VisualforceException e) {
            body = Blob.valueOf('Some Text');
        }
        
        attach.Body = body;
        attach.Name = pdfName + '.pdf';
        attach.IsPrivate = false;
        attach.ParentId = parentId; // PO's Id
       
        insert attach;
        
        // (Future) Send Email
        sendEmail(attach.Id);
        return page.POVPRSuccessPage;
    }
    
    /* SEND EMAIL    */
    @future(callout=true)
    public static void sendEmail(Id vprFormId) {
        // Get VPR
        Attachment vprAttachment = [SELECT Id,Name,ParentId,Body,BodyLength 
                                    FROM Attachment 
                                    WHERE Id = :vprFormId];
        
        // Get Template
        EmailTemplate ev = [select id,name,Subject,Body 
                            from EmailTemplate 
                            where name='VPR_Email_template'];

        // Create Email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        List<Messaging.EmailFileAttachment> emailAttachments = new List<Messaging.EmailFileAttachment>();
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName(vprAttachment.Name);
        efa.setBody(vprAttachment.Body);
        emailAttachments.add(efa);
        email.setFileAttachments(emailAttachments);
        // Set "To" address
        List<String> toAddresses = new List<String>();
        toAddresses.add('xyz@gmail.com');
        email.setToAddresses(toAddresses);
        // Set "From" address (not applicable in this case)
        /*(OrgWideEmailAddress[] owea = [select Id 
                                      from OrgWideEmailAddress 
                                      where Address = ''];
        if (owea.size() > 0 ) {
            email.setOrgWideEmailAddressId(owea.get(0).Id);
        }*/
        email.subject = ev.Subject;
        email.setSaveAsActivity(True);
        email.setHtmlBody(ev.Body);
        List<Messaging.SendEmailResult> results = new List<Messaging.SendEmailResult>();
        results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
    }
}

The problem is I'm able to save the vf page as pdf but I'm not able to see the checkboxes in that pdf. Can some one help me with this ? 
I appreciate your help.  Thank you in advance!
  • December 15, 2017
  • Like
  • 0
Hi guys,
I need some help with the following code. I'm trying to write an apex class but getting errors. Please help me out with this. Thank you in advance.


Purchase_Order__c  po=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c where id= :ApexPages.currentPage().getParameters().get('id')];
    id myid=po.Original_Purchase_Order__c;
    if(po.POCN__c==0){
        system.debug('This is the original po');
        }
        if(po.POCN__c==1){
        purchase_order__c po1=[select Purchase_Order__c.Name, Purchase_Order__c.status__c, (select Name,id from Expenditures__r) from Purchase_Order__c  where id=:myid];
        List<Expenditures__c> e1 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po1.id];
        //return e1;
        system.debug('original po expenditure list '+e1);
        }
        if(po.POCN__c==2){
       purchase_order__c po1=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid];
        id myid1=po1.Original_Purchase_Order__c;
        purchase_order__c po2=[select Purchase_Order__c.Name from Purchase_Order__c  where id=:myid1];
        List<Expenditures__c> e2 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po2.id];
        system.debug('original po expenditure list '+e2);  
        } 
        if(po.POCN__c==3){
        purchase_order__c po1=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid];
        id myid1=po.Original_Purchase_Order__c;
        purchase_order__c po2=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid1];
        id myid2=po.Original_Purchase_Order__c;
        purchase_order__c po3=[select Purchase_Order__c.Name, Purchase_Order__c.status__c, (select Name,id from Expenditures__r) from Purchase_Order__c  where id=:myid2];
        List<Expenditures__c> e3 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po3.id];
        system.debug('original po expenditure list '+e3);   
        }
        if(po.POCN__c==4){
        purchase_order__c po1=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid];
        id myid1=po.Original_Purchase_Order__c;
        purchase_order__c po2=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid1];
        id myid2=po.Original_Purchase_Order__c;
        purchase_order__c po3=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid2];
        id myid3=po.Original_Purchase_Order__c;
        purchase_order__c po4=[select Purchase_Order__c.Name, Purchase_Order__c.status__c, (select Name,id from Expenditures__r) from Purchase_Order__c  where id=:myid3];    
        List<Expenditures__c> e4 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po4.id];
        system.debug('original po expenditure list '+e4);   
        }
        if(po.POCN__c==5){
        purchase_order__c po1=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid];
        id myid1=po.Original_Purchase_Order__c;
        purchase_order__c po2=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid1];
        id myid2=po.Original_Purchase_Order__c;
        purchase_order__c po3=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid2];
        id myid3=po.Original_Purchase_Order__c;
        purchase_order__c po4=[select Original_Purchase_Order__c,POCN__c from Purchase_Order__c  where id=:myid3]; 
        id myid4=po.Original_Purchase_Order__c;
        purchase_order__c po5=[select Purchase_Order__c.Name, Purchase_Order__c.status__c, (select Name,id from Expenditures__r) from Purchase_Order__c  where id=:myid4];     
        List<Expenditures__c> e5 = [select id,Name,Amount__c from Expenditures__c where PurchaseOrder__r.id= :po5.id];
        system.debug('original po expenditure list '+e5);   
        }
  • September 18, 2017
  • Like
  • 0
I have below JSON ,How can I send in my request using apex:

"objects":[
{
"fieldsToNull":["DefaultPaymentMethodId"],
"AccountNumber":"A00000036",
"Id":"2c92c0f95a4085a8015a41f4012d183e"
}
]
, "type":"Account"
I have a simple process which updates all child records when the parent is updated. The problem I'm having is that occassionally a child record will have some data that was entered prior to a validation rule being created - when the process runs this child record fails validation, and in turn, causes the process to fail - returning a pretty cryptic error to the user. Is there a way to gracefully handle errors like these in Process Builder?
Hi there, I 'm trying to complete the "Automating Processes with the Lightning Process Builder" challenge in TrailHead but I get the following error :
Encountered unhandled fault when running process Update_contact_adress/
301240000004FXO exception by user/organization: 00D24000000JsNt/{4}

The flow failed to access the value for myVariable_current.Account.ShippingCountry because it hasn't been set or assigned.
caused by element : FlowRecordUpdate.myRule_1_A1
caused by: The flow failed to access the value for myVariable_current.Account.ShippingCountry because it hasn't been set or assigned.
Salesforce Error ID: 490660201-42718 (736882147)

Any idea what could be could wrong ?
 

Hi,

 

When I run the flow in the desktop flow designer it works fine but when i run the same flow from SFDC UI (Flows->run) i get this error

"An unhandled fault has occurred in this flow. An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information."

 

Has anyone else faced this issue. Can anyone provide some help to overcome this issue.

 

Thanks,