• Brian Cherry FWI
  • NEWBIE
  • 85 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 36
    Replies
I need to Query the Last notes and attachments that was added in a Quote, into a PDF, I dont now how to query that , any suggestions?
I am trying to create a List structure that contains this type of structure

Master Record Install
List of Related Project_Tasks to the Install
List of Related Users to the Project Task
List of Detail Records related to the Project Task.

This is related to being able to approve approval process instance ids. Since it's not really related, I'm having to try to build it backwards. Here's my code so far, I'm not sure who to get an SObject that has a List within a List within a List. Each List relates to one record within the the list.
public class JsonStructure
    {
        public SFDC_Project__c theInstall;
        public List<Project_Task__c> thePTs;
        public List<User> theUsers;
        public List<Details> detailList;
        
    
    }
    
   
    
    
    public class Details
    {
        public id theProcessId;
        public id TimeEntryId;
        public id Userid;
        public id InstallId;
        public string InstallName;
        public string Notes;
        public double Hours;
        public string UserName;
        public string TaskName;
        public string TaskId;
        public string theDate;
        public string reasonCode;
        public string theType;
        
        public Details()
        {
            
        }
    }
    public class PendingApproval{
         public final Id processId;
         public final Details Detail;
            public PendingApproval(Id processId, Details detail){
            this.processId = processId;
            this.detail = detail;
        }
    }
 
@remoteAction
    public static List<PendingApproval> getPendingApprovalsJson(){
                transient List<PendingApproval> pendingApprovals;
                List<ProcessInstanceWorkitem> unapprovedItems =
                [SELECT
                    ProcessInstanceId,
                    ProcessInstance.TargetObjectId
                 FROM ProcessInstanceWorkitem
                 WHERE ActorId = '00580000005ScLr'
                 AND ProcessInstance.TargetObject.Type = 'Time_Entry_Day__c'];
             Map<Id, ID> workItems = new Map<Id, ID>();
        for (ProcessInstanceWorkItem i : unapprovedItems)
        {
            workItems.put(i.ProcessInstance.TargetObjectId, i.ProcessInstanceId);
        }
        
        List<Time_Entry_Day__c> timeEntriesForApproval = new List<Time_Entry_Day__c>(
            [SELECT
                Id,
                User__c,
                User_Full_Name__c,
                Date__c,
                Install__c,
                Install_Name__c,
                Billable_Hours__c,
                Billable_Notes__c,
                Non_Billable_Hours__c,
                Non_Billable_Notes__c,
                Project_Task__c,
                Task_Name__c,
                Approved_Time__c,
			    Budgeted_Hours__c,
				Remaining_Time__c,
                Non_Bill_Reason_Code__c
             FROM Time_Entry_Day__c 
             WHERE Id IN :Pluck.ids('ProcessInstance.TargetObjectId', unapprovedItems)]);
        map<Id, Details> theDetails = new Map<id, Details>();
        list<SFDC_Project__c> installList = new List<SFDC_Project__c>();
        installList = [SELECT ID, SFDC_Project_Name__c from SFDC_Project__c where Id IN :Pluck.ids('Install__c', timeEntriesForApproval)];
        list<Project_Task__c> PTList = new List<Project_Task__c>();
        PTList = [SELECT ID, Approved_Billable_Time__c, Task__c from Project_Task__c where Id IN :Pluck.ids('project_task__c', timeEntriesForApproval)];
        List<User> userList = new List<User>();
        userList = [SELECT ID, Name from User where ID IN :Pluck.ids('User__c', timeEntriesForApproval)];

        
        
        
        
        for(Time_Entry_Day__c day :TimeEntriesForApproval)
        {
        Details d = new Details();
        d.theProcessId = workItems.get(day.id);    
        d.TimeEntryId = day.Id;    
        d.Userid = day.User__c;
        d.InstallId = day.Install__c;
        d.InstallName = day.Install_Name__c;
         if(day.Non_Billable_Notes__c != NULL || day.Non_Billable_Notes__c != '')
         {
         d.Notes = day.Non_Billable_Notes__c;  
         }
         else
         {
             d.Notes = day.Billable_Notes__c;
         }         
 
    
            if(day.Non_Billable_Hours__c == 0 || day.Non_Billable_Hours__c == NULL)
            {
        d.Hours = day.Billable_Hours__c;
        d.theType = 'Billable';        
            }
            else
            {
            d.Hours = day.Non_Billable_Hours__c;
            d.theType = 'Non-billable';    
            }
        d.reasonCode =  day.Non_Bill_Reason_Code__c;  
        d.UserName = day.User_Full_Name__c;
        d.TaskName = day.Task_Name__c;
        d.TaskId = day.Project_Task__c;
        d.theDate = day.Date__c.format();
        thedetails.put(d.TimeEntryId, d);
        }
        pendingApprovals = new List<PendingApproval>();
        for(ProcessInstanceWorkitem workItem : unapprovedItems){
            pendingApprovals.add(new PendingApproval(workItem.Id, theDetails.get(workItem.ProcessInstance.TargetObjectId)));
        }
        return pendingApprovals;
    }


 
I have a lookup field and a extenstion to convert the lookup as a select list. Debug log is showing options, but the VF page is not... Any ideas of why the select options aren't populating? 
 
public class BIWorkOrder {
    public Work_Order__c wo {get; set;}  
    public list<Deployment_Cycle__c> Deployments {get;set;}
    public List<SelectOption> options {get; set;}
    public BiWorkOrder(ApexPages.StandardController stdcontroller)
    {
        this.wo = (Work_Order__c)stdcontroller.getRecord();
        getItems();

    }
     public List<SelectOption> getItems() {
        Deployments = [SELECT ID, Deployment_Date__c from Deployment_cycle__c where Deployment_Date__c > :system.Today() and Active__c = true order By Deployment_date__c ASC];
        list<selectOption> options = new List<selectOption>(); 
        for(Deployment_Cycle__c d :deployments)
        {
           string newDate = d.Deployment_date__c.month() + '/' + d.deployment_date__c.day() + '/' + d.deployment_date__c.year();
           options.add(new selectOption (d.id, newDate));
        }
         system.debug(options);
 return options;
         
    }
}
 
<apex:pageBlockSection title="BI Fields" columns="2">
                <apex:inputField value="{!Work_Order__c.Resource__c}" required="false"/>
                <apex:selectList value="{!Work_Order__c.Deployment_Cycle__c}" > ---> Lookup field
                <apex:selectOptions value="{!Options}"></apex:selectOptions>  ---> Options 
                </apex:selectList>
                <apex:inputField value="{!Work_Order__c.Due_Date__c}" required="false"/>
                <apex:inputField value="{!Work_Order__c.Notes__c}" required="false"/>
                <apex:inputField value="{!Work_Order__c.Date_Complete__c}" required="false"/>
                         
            </apex:pageBlockSection>
Debug:

16:48:39:015 USER_DEBUG [20]|DEBUG|(System.SelectOption[value="aBv1b00000000EiCAI", label="2/3/2017", disabled="false"])
 
Hey Everyone -

I have a callout in my constructor and trying to avoid having to do a remote action and javascript processing. I would like to have the processing done server side and just display the results from the call. The problem is, the page loads before the call is complete so I'm left with a blank page. Dev console shows that the call out was a success and the object was populated. Here's the page and class. Any ideas on how to get this to work or am I stuck with remote action and js processing?
 
//
// Generated by JSON2Apex http://json2apex.herokuapp.com/
//

public class StatushubJSON {
	public static void consumeObject(JSONParser parser) {
		Integer depth = 0;
		do {
			JSONToken curr = parser.getCurrentToken();
			if (curr == JSONToken.START_OBJECT || 
				curr == JSONToken.START_ARRAY) {
				depth++;
			} else if (curr == JSONToken.END_OBJECT ||
				curr == JSONToken.END_ARRAY) {
				depth--;
			}
		} while (depth > 0 && parser.nextToken() != null);
	}

	public class Services {
		public Integer id {get;set;} 
		public String name {get;set;} 
		public String updated_at {get;set;} 
		public Boolean up {get;set;} 
		public Services(JSONParser parser) {
			while (parser.nextToken() != JSONToken.END_OBJECT) {
				if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
					String text = parser.getText();
					if (parser.nextToken() != JSONToken.VALUE_NULL) {
						if (text == 'id') {
							id = parser.getIntegerValue();
						} else if (text == 'name') {
							name = parser.getText();
						} else if (text == 'updated_at') {
							updated_at = parser.getText();
						} else if (text == 'up') {
							up = parser.getBooleanValue();
						} else {
							System.debug(LoggingLevel.WARN, 'Services consuming unrecognized property: '+text);
							consumeObject(parser);
						}
					}
				}
			}
		}
	}
	
	public Integer id {get;set;} 
	public String name {get;set;} 
	public String updated_at {get;set;} 
	public String logo {get;set;} 
	public Integer services_count {get;set;} 
	public Integer down_services_count {get;set;} 
	public String subdomain {get;set;} 
	public List<Services> services {get;set;} 

	public StatushubJSON(JSONParser parser) {
		while (parser.nextToken() != JSONToken.END_OBJECT) {
			if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
				String text = parser.getText();
				if (parser.nextToken() != JSONToken.VALUE_NULL) {
					if (text == 'id') {
						id = parser.getIntegerValue();
					} else if (text == 'name') {
						name = parser.getText();
					} else if (text == 'updated_at') {
						updated_at = parser.getText();
					} else if (text == 'logo') {
						logo = parser.getText();
					} else if (text == 'favicon') {
						
					} else if (text == 'services_count') {
						services_count = parser.getIntegerValue();
					} else if (text == 'down_services_count') {
						down_services_count = parser.getIntegerValue();
					} else if (text == 'subdomain') {
						subdomain = parser.getText();
					} else if (text == 'services') {
						services = new List<Services>();
						while (parser.nextToken() != JSONToken.END_ARRAY) {
							services.add(new Services(parser));
						}
					} else {
						System.debug(LoggingLevel.WARN, 'Root consuming unrecognized property: '+text);
						consumeObject(parser);
					}
				}
			}
		}
	}
	
	
	public static StatushubJSON parse(String json) {
		return new StatushubJSON(System.JSON.createParser(json));
	}
}
public class StatusHub {
   public string result {get;set;}
   public List <StatusHubJSON > parse {get;set;}  
    
    public statusHub()
    {
        Http h=new  Http();
        HttpRequest req=new  HttpRequest();
        req.setMethod('GET');
        req.setHeader('api-key','xxxxxx');
        req.setEndPoint('https://app.statushub.io/api/status_pages/fwi-status');
        HttpResponse res = h.send(req);
        string json = res.getBody();
        StatusHubJSON parse=new StatusHubJSON(System.JSON.createParser(json));
     }
    
    

}


 
trigger NAICSUpdate on Account (before insert, before update) {
List<NAICS_Code__c> codes = [SELECT Name, Description__c from NAICS_CODE__C];
Set<NAICS_CODE__C> setcodes = new set <NaICS_code__c>();
setcodes.addAll(codes);    
for (Account acct :Trigger.new)
 {
   if(acct.NaicsCode != NULL)
   {
       try {
     string twoDigit =  acct.NaicsCode.left(2);
     string threeDigit =  acct.NaicsCode.left(3);
     NAICS_Code__c nCode2desc = [SELECT Name, Description__c from NAICS_CODE__C where Name = :twoDigit limit 1]; 
     NAICS_Code__c nCode3desc = [SELECT Name, Description__c from NAICS_CODE__C where Name = :threeDigit limit 1]; 
     acct.NAICS_2_Digit_Desc__c = nCode2desc.Description__c;
     acct.NAICS_3_Digit_Desc__c = nCode3desc.Description__c;           
}
       catch (Exception e) {
           system.debug('Failed');
       }
   }
       
     
     
 }
}

I'm trying to remove the two queries in the for loop. I can't use a map since I'm searching by name and not ID. I'm not really sure how to utilize set to return the right description if I use contains. Any help would greatly be appreciated.
 
So I'm parsing a Http repsonse and I keep getting a nullpointer exception when I know a child element is there. This is my first XML rodeo so I was hoping for suggestions.

My Debug log before adding the getchildelement is this:
 
15:22:10:905 USER_DEBUG [27]|DEBUG|nodeXMLNode[ELEMENT,createCustomerProfileResponse,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,[common.apex.api.dom.XmlNode$NamespaceDef@21526738, common.apex.api.dom.XmlNode$NamespaceDef@582ef6d5, common.apex.api.dom.XmlNode$NamespaceDef@61835476],[XMLNode[ELEMENT,messages,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[ELEMENT,resultCode,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[TEXT,null,null,null,null,null,Error,]],null,], XMLNode[ELEMENT,message,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[ELEMENT,code,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[TEXT,null,null,null,null,null,E00039,]],null,], XMLNode[ELEMENT,text,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[TEXT,null,null,null,null,null,A duplicate record with ID 40545008 already exists.,]],null,]],null,]],null,], XMLNode[ELEMENT,customerPaymentProfileIdList,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,null,null,], XMLNode[ELEMENT,customerShippingAddressIdList,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,null,null,], XMLNode[ELEMENT,validationDirectResponseList,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,null,null,]],null,]


But when I add the getChildElement('resultCode',null).getText(); I'm getting a Null Pointer Exception even though the value is in the XML document. Any advice on what I'm missing?
 
public void process()
{
isSuccess = false;
string xml = getxmlRes();
Http h = new http();
HttpRequest req = new HttpRequest(); 
req.setEndpoint('https://apitest.authorize.net/xml/v1/request.api');
req.setMethod('POST');
req.setbody(xml);
HttpResponse res = h.send(req);
isSuccess = true;
Dom.Document doc = res.getBodyDocument();
status = res.getStatusCode();
Dom.XMLNode node = doc.getRootElement();
profilename = node.getChildElement('resultCode', null).gettext();
System.debug('ukpostcode: ' + node); 
body = res.getBody();
}

 
So I'm parsing a Http repsonse and I keep getting a nullpointer exception when I know a child element is there. This is my first XML rodeo so I was hoping for suggestions.

My Debug log before adding the getchildelement is this:
 
15:22:10:905 USER_DEBUG [27]|DEBUG|nodeXMLNode[ELEMENT,createCustomerProfileResponse,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,[common.apex.api.dom.XmlNode$NamespaceDef@21526738, common.apex.api.dom.XmlNode$NamespaceDef@582ef6d5, common.apex.api.dom.XmlNode$NamespaceDef@61835476],[XMLNode[ELEMENT,messages,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[ELEMENT,resultCode,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[TEXT,null,null,null,null,null,Error,]],null,], XMLNode[ELEMENT,message,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[ELEMENT,code,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[TEXT,null,null,null,null,null,E00039,]],null,], XMLNode[ELEMENT,text,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[TEXT,null,null,null,null,null,A duplicate record with ID 40545008 already exists.,]],null,]],null,]],null,], XMLNode[ELEMENT,customerPaymentProfileIdList,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,null,null,], XMLNode[ELEMENT,customerShippingAddressIdList,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,null,null,], XMLNode[ELEMENT,validationDirectResponseList,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,null,null,]],null,]
But when I add the getChildElement('resultCode',null).getText(); I'm getting a Null Pointer Exception even though the value is in the XML document. Any advice on what I'm missing?
 
public void process()
{
isSuccess = false;
string xml = getxmlRes();
Http h = new http();
HttpRequest req = new HttpRequest(); 
req.setEndpoint('https://apitest.authorize.net/xml/v1/request.api');
req.setMethod('POST');
req.setbody(xml);
HttpResponse res = h.send(req);
isSuccess = true;
Dom.Document doc = res.getBodyDocument();
status = res.getStatusCode();
Dom.XMLNode node = doc.getRootElement();
profilename = node.getChildElement('resultCode', null).gettext();
System.debug('ukpostcode: ' + node); 
body = res.getBody();
}

 
Here is my code:
public expenseController(ApexPages.StandardController controller) { this.proj = (Expense_Report__c) controller.getSubject(); this.delivers = '[SELECT d.Name, d.Billable__c, d.Comments__c, d.Travel_type__c, d.Purchase_type__c, d.Expense_Report__c, d.Id, d.Purchase_Date__c, d.Quantity__c, d.Sales_Tax__c, d.Shipping__c, d.total__c, d.type__c, d.unit_price__c, d.Description__c,d.Price_Override__c,d.Override_Price__c'+ 'FROM Expense_Line_Items__c d' + 'WHERE d.Expense_Report__c = : proj.id' + 'Order by' + 'sortOrder' + 'DESC' + ']'; }


Any thoughts why I'm getting this error?
 
I'm writing a test class for my controller but I'm having issues with the attachment portion. Here is the error:

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name, Body]: [Name, Body]
Stack Trace: Class.expenseController.upload: line 82, column 1 Class.TestExpenseController.testAddAttachmentToObject: line 38, column 1

Here is the Test Class:
@istest
public class TestExpenseController{

    static Expense_Line_Items__c setupServiceLineItem(final Expense_Report__c partner) {
        Expense_Line_Items__c lineItem = new Expense_Line_Items__c();
        lineItem.Expense_Report__c = partner.Id;
        insert lineItem;
        return lineItem;
    }

    static Expense_Report__c setupServicePartner() {
        Purchase_Request__c project = (Purchase_Request__c)new SObjectBuilder(Purchase_Request__c.SObjectType).buildAndInsert()[0];
        Expense_Report__c partner = new Expense_Report__c();
        partner.Purchase_Request__c = project.Id;
        insert partner;
        return partner;
    }

    static Attachment setupAttachment(final Expense_Report__c partner) {
        Purchase_Request__c project = (Purchase_Request__c)new SObjectBuilder(Purchase_Request__c.SObjectType).buildAndInsert()[0];
     Blob b = Blob.valueOf('Test Data');
     Attachment attachment = new Attachment();
     attachment.ParentId = partner.Id;
     attachment.Name = 'Test Attachment for Parent';
     attachment.Body = b;
     insert attachment;
     return attachment;

    }

static testmethod void testAddAttachmentToObject() {

Expense_Report__c aBasicPartner = setupServicePartner();
Attachment associatedAttachment  = setupAttachment(aBasicPartner); 
Test.startTest();
Test.setCurrentPage(Page.PSview);
 ExpenseController deliverablesCnt = new ExpenseController(new ApexPages.StandardController(aBasicPartner));
  deliverablesCnt.upload();
    Test.stopTest(); 
     List<Attachment> attachments=[select id, name from Attachment where parent.id=: aBasicpartner.Id];
     System.assertEquals(1, attachments.size());

    }


    static testmethod void deliverablesCnt_Should_QueryPartnerLineItemsOnCreate(){
        //Given
        Expense_Report__c aBasicPartner = setupServicePartner();
        Expense_Line_Items__c associatedPartnerLineItem  = setupServiceLineItem(aBasicPartner);
        //when
        Test.startTest();
            Test.setCurrentPage(Page.PSview);
            expenseController deliverablesCnt = new expenseController(new ApexPages.StandardController(aBasicPartner));
        Test.stopTest();
        //then
        System.assertEquals(1, deliverablesCnt.getDeliverables().size(), 'Should have one line item in delivers');
     
    }

    static testmethod void deliverablesCnt_Should_InsertNewLineItem(){
        //Given
        Expense_Report__c aBasicPartner = setupServicePartner();
        Expense_Line_Items__c associatedPartnerLineItem  = setupServiceLineItem(aBasicPartner);
        //when
        Test.startTest();
            Test.setCurrentPage(Page.PSview);
            ExpenseController deliverablesCnt = new ExpenseController(new ApexPages.StandardController(aBasicPartner));
            deliverablesCnt.insertmethod();
        Test.stopTest();
        //then
        List<Expense_Line_Items__c> associatedLineItems = [
            SELECT Expense_Report__c
            FROM Expense_Line_Items__c
            WHERE Expense_Report__c = :aBasicPartner.Id
        ];
        System.assertEquals(2, associatedLineItems.size(), 'A new service partner line item should have been created and associated');
    }

    static testmethod void deliverablesCnt_Should_SaveLineItemChanges() {
        //Given
        Expense_Report__c aBasicPartner = setupServicePartner();
        Expense_Line_Items__c unsavedLineItem = new Expense_Line_Items__c();
        unsavedLineItem.Expense_Report__c = aBasicPartner.Id;
        //when
        Test.startTest();
            Test.setCurrentPage(Page.PSview);
            ExpenseController deliverablesCnt = new ExpenseController(new ApexPages.StandardController(aBasicPartner));
            deliverablesCnt.getDeliverables().add(unsavedLineItem);
            PageReference pageRef = deliverablesCnt.saveChanges();
        Test.stopTest();
        //then
        List<Expense_Line_Items__c> associatedLineItems = [
            SELECT Expense_Report__c
            FROM Expense_Line_Items__c
            WHERE Expense_Report__c = :aBasicPartner.Id
        ];
        System.assertEquals(1, associatedLineItems.size(), 'The unsaved service partner line item should have been saved');
        System.assertEquals(true, pageRef.getRedirect(), 'Page should redirect');
    }

    static testmethod void deliverablesCnt_Should_DeleteSelectedServiceLineItem() {
        //Given
        final Expense_Report__c aBasicPartner = setupServicePartner();
        final Expense_Line_Items__c associatedPartnerLineItem  = setupServiceLineItem(aBasicPartner);
        final String nonExistingLineItemId = aBasicPartner.Id;

        Test.setCurrentPage(Page.PSview);
        ExpenseController deliverablesCntSelectedLineItem = new ExpenseController(new ApexPages.StandardController(aBasicPartner));
        ExpenseController deliverablesCntNoSelectedLineItem = new ExpenseController(new ApexPages.StandardController(aBasicPartner));
        ExpenseController deliverablesCntNotFoundSelectedLineItem = new ExpenseController(new ApexPages.StandardController(aBasicPartner));

        //when
        Test.startTest();
            PageReference noSelectedLineItemPageRef = deliverablesCntNoSelectedLineItem.DeleteAccount();
            deliverablesCntNotFoundSelectedLineItem.SelectedAccountId = nonExistingLineItemId;
            PageReference notFoundLineItemPageRef = deliverablesCntNotFoundSelectedLineItem.DeleteAccount();
            deliverablesCntSelectedLineItem.SelectedAccountId = associatedPartnerLineItem.Id;
            PageReference selectedLineItemPageRef = deliverablesCntSelectedLineItem.DeleteAccount();
        Test.stopTest();

        //then
        System.assertEquals(true, selectedLineItemPageRef.getRedirect(), 'Page should redirect when selected it is found');
        System.assertEquals(true, notFoundLineItemPageRef.getRedirect(), 'Page should still redirect if selected id was not found');
        System.assertEquals(null, noSelectedLineItemPageRef, 'Page should be null');

        List<Expense_Line_Items__c> associatedLineItems = [
            SELECT Expense_Report__c
            FROM Expense_Line_Items__c
            WHERE Expense_Report__c = :aBasicPartner.Id
        ];
        System.assertEquals(0, associatedLineItems.size(), 'The service partner line item should have been deleted');
    }

    static testmethod void deliverablesCnt_Should_CreateNewLineItem(){
        //Given
        Expense_Report__c aBasicPartner = setupServicePartner();
        Expense_Line_Items__c associatedPartnerLineItem  = setupServiceLineItem(aBasicPartner);
        //when
        Test.startTest();
            Test.setCurrentPage(Page.PSview);
            ExpenseController deliverablesCnt = new ExpenseController(new ApexPages.StandardController(aBasicPartner));
            deliverablesCnt.newDeliverable();
        Test.stopTest();
        //then
        System.assertEquals(2, deliverablesCnt.getDeliverables().size(), 'Should have two line items in delivers as a new one should have been appended');
        System.assertEquals(aBasicPartner.Id, deliverablesCnt.getDeliverables().get(1).Expense_Report__c, 'Id should have been set');
    }


}

Here is the class:
ublic class expenseController {
    // class variables
    PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl());
    Expense_Report__c proj;
    Expense_Line_Items__c[] delivers;
    public string SelectedAccountId {get;set;}

    // Constructor
    public expenseController(ApexPages.StandardController controller) {
        this.proj = (Expense_Report__c) controller.getSubject();
        this.delivers = [SELECT
            d.Name, d.Billable__c, d.Comments__c, d.Travel_type__c, d.Purchase_type__c,
            d.Expense_Report__c, d.Id, d.Purchase_Date__c, 
            d.Quantity__c, d.Sales_Tax__c, d.Shipping__c, 
            d.total__c, d.type__c, d.unit_price__c, d.Description__c,d.Price_Override__c,d.Override_Price__c
            FROM Expense_Line_Items__c d
            WHERE d.Expense_Report__c = : proj.id
        ];
    }

    public pagereference insertmethod() {
        Expense_Line_Items__c cc = new Expense_Line_Items__c();
        cc.Expense_Report__c = proj.id;
        insert cc;
        return null;
    }

    public Expense_Line_Items__c[] getDeliverables() {
        return this.delivers;
    }

    // Action Method called from page button
    public pagereference saveChanges() {
        upsert this.delivers;
        pageRef.setRedirect(true);
        return pageRef;
    }

    // Action Method called from page link
    public pagereference newDeliverable() {
       Expense_Line_Items__c d = new Expense_Line_Items__c();
        d.Expense_Report__c = this.proj.id;
        delivers.add(d);
        getDeliverables();
        return null;
    }

    public pagereference DeleteAccount() {
        // if for any reason we are missing the reference
        if (SelectedAccountId == null) {
            return null;
        }
        // find the account record within the collection
        Expense_Line_Items__c tobeDeleted = null;
        for (Expense_Line_Items__c a: this.delivers)
            if (a.Id == SelectedAccountId) {
                tobeDeleted = a;
                break;
            }
            //if account record found delete it
        if (tobeDeleted != null) {
            Delete tobeDeleted;
        }
        pageRef.setRedirect(true);
        return pageRef;
    }
 //Attachments
   public Attachment attachment {
  get {
      if (attachment == null)
        attachment = new Attachment();
      return attachment;
    }
  set;
  }

  public PageReference upload() {

    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId =  proj.id;
    attachment.IsPrivate = false;
      insert attachment;
      pageRef.setRedirect(true);
      return pageRef;
    }


  }

Any help would be greatly appreciated!
 

My first controller, can anyone help creating a test class for this?

public class deliverablesController {
  
  // Constructor
 public deliverablesController(ApexPages.StandardController controller) {
  this.proj = (Professional_Services_Partner__c)controller.getSubject();
  
     this.delivers = [ SELECT 
     d.Name, 
      d.Partner_Package__c, d.Price__c, d.Price_Override__c, 
      Professional_Services_Partner_Contract__c, d.Id, d.QTY__c
      FROM 
      Professional_Services_Partner_Line_Items__c d 
      WHERE 
      d.Professional_Services_Partner_Contract__c = :proj.id ];
 }
 
 
public pagereference insertmethod()
                {
                Professional_Services_Partner_Line_Items__c cc= new Professional_Services_Partner_Line_Items__c();
                cc.Professional_Services_Partner_Contract__c = proj.id;
                insert cc;
                return null;
                }
                    
  public Professional_Services_Partner_Line_Items__c[] getDeliverables() { 
  return this.delivers; 
  
 } 
 
 // Action Method called from page button
 public pagereference saveChanges() { 
  upsert this.delivers;
  pageRef.setRedirect(true); 
return pageRef;
 }
 
 // Action Method called from page link
 public pagereference newDeliverable() { 
  Professional_Services_Partner_Line_Items__c d = new Professional_Services_Partner_Line_Items__c();
  d.Professional_Services_Partner_Contract__c =this.proj.id; 
  delivers.add( d );
  getDeliverables();
  return null;
 } 
 
 public pagereference DeleteAccount()   
{      
// if for any reason we are missing the reference       
if (SelectedAccountId == null) 
{               
return null;      
}           
// find the account record within the collection      
Professional_Services_Partner_Line_Items__c tobeDeleted = null;      
for(Professional_Services_Partner_Line_Items__c a : this.delivers)       
if (a.Id == SelectedAccountId) 
{         
tobeDeleted = a;          
break;       
}            
//if account record found delete it      
if (tobeDeleted != null) 
{       
Delete tobeDeleted;      
}
pageRef.setRedirect(true); 
return pageRef;
}        

  
 // class variables

PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl()); 
 

 Professional_Services_Partner__c proj;
 Professional_Services_Partner_Line_Items__c[] delivers; 
 public string SelectedAccountId { get; set; }
}


Best,
Brian
 

This is my first controller, how would I go about testing this?
 
public class deliverablesController {
  
  // Constructor
 public deliverablesController(ApexPages.StandardController controller) {
  this.proj = (Professional_Services_Partner__c)controller.getSubject();
  
     this.delivers = [ SELECT 
     d.Name, 
      d.Partner_Package__c, d.Price__c, d.Price_Override__c, 
      Professional_Services_Partner_Contract__c, d.Id, d.QTY__c
      FROM 
      Professional_Services_Partner_Line_Items__c d 
      WHERE 
      d.Professional_Services_Partner_Contract__c = :proj.id ];
 }
 
 
public pagereference insertmethod()
                {
                Professional_Services_Partner_Line_Items__c cc= new Professional_Services_Partner_Line_Items__c();
                cc.Professional_Services_Partner_Contract__c = proj.id;
                insert cc;
                return null;
                }
                    
  public Professional_Services_Partner_Line_Items__c[] getDeliverables() { 
  return this.delivers; 
  
 } 
 
 // Action Method called from page button
 public pagereference saveChanges() { 
  upsert this.delivers;
  pageRef.setRedirect(true); 
return pageRef;
 }
 
 // Action Method called from page link
 public pagereference newDeliverable() { 
  Professional_Services_Partner_Line_Items__c d = new Professional_Services_Partner_Line_Items__c();
  d.Professional_Services_Partner_Contract__c =this.proj.id; 
  delivers.add( d );
  getDeliverables();
  return null;
 } 
 
 public pagereference DeleteAccount()   
{      
// if for any reason we are missing the reference       
if (SelectedAccountId == null) 
{               
return null;      
}           
// find the account record within the collection      
Professional_Services_Partner_Line_Items__c tobeDeleted = null;      
for(Professional_Services_Partner_Line_Items__c a : this.delivers)       
if (a.Id == SelectedAccountId) 
{         
tobeDeleted = a;          
break;       
}            
//if account record found delete it      
if (tobeDeleted != null) 
{       
Delete tobeDeleted;      
}
pageRef.setRedirect(true); 
return pageRef;
}        

  
 // class variables

PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl()); 
 

 Professional_Services_Partner__c proj;
 Professional_Services_Partner_Line_Items__c[] delivers; 
 public string SelectedAccountId { get; set; }
}

 
public class AddingLineItemsController {
    public List<Professional_Services_Partner_Line_Items__C> LineItems {get;set;}
    public Integer rowNum{get;set;}
    public  AddingLineItemsController (){
        LineItems = new List<Professional_Services_Partner_Line_Items__c>();  
        LineItems.add(new Professional_Services_Partner_Line_Items__c());      
    }
    
    public void insertLineItems(){
        LineItems.Professional_Services_Partner_Contract__c = ApexPages.currentPage().getParameters().get('cid');
        insert LineItems;
    }
    
    public void insertRow(){
        LineItems.add(new Professional_Services_Partner_Line_Items__c()); 
    }
    
    public void delRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        LineItems.remove(rowNum);   
    }
}

Above is my class. What I'm trying to accomplish is for the url parameter cid = Professional_Services_Partner_Contract__c for every row that is inserted. I keep getting this error: Error: Compile Error: Initial term of field expression must be a concrete SObject: List<Professional_Services_Partner_Line_Items__c> at line 10 column 9. Can anyone point me in the right direction?

Best,
Brian
 
I have a lookup field and a extenstion to convert the lookup as a select list. Debug log is showing options, but the VF page is not... Any ideas of why the select options aren't populating? 
 
public class BIWorkOrder {
    public Work_Order__c wo {get; set;}  
    public list<Deployment_Cycle__c> Deployments {get;set;}
    public List<SelectOption> options {get; set;}
    public BiWorkOrder(ApexPages.StandardController stdcontroller)
    {
        this.wo = (Work_Order__c)stdcontroller.getRecord();
        getItems();

    }
     public List<SelectOption> getItems() {
        Deployments = [SELECT ID, Deployment_Date__c from Deployment_cycle__c where Deployment_Date__c > :system.Today() and Active__c = true order By Deployment_date__c ASC];
        list<selectOption> options = new List<selectOption>(); 
        for(Deployment_Cycle__c d :deployments)
        {
           string newDate = d.Deployment_date__c.month() + '/' + d.deployment_date__c.day() + '/' + d.deployment_date__c.year();
           options.add(new selectOption (d.id, newDate));
        }
         system.debug(options);
 return options;
         
    }
}
 
<apex:pageBlockSection title="BI Fields" columns="2">
                <apex:inputField value="{!Work_Order__c.Resource__c}" required="false"/>
                <apex:selectList value="{!Work_Order__c.Deployment_Cycle__c}" > ---> Lookup field
                <apex:selectOptions value="{!Options}"></apex:selectOptions>  ---> Options 
                </apex:selectList>
                <apex:inputField value="{!Work_Order__c.Due_Date__c}" required="false"/>
                <apex:inputField value="{!Work_Order__c.Notes__c}" required="false"/>
                <apex:inputField value="{!Work_Order__c.Date_Complete__c}" required="false"/>
                         
            </apex:pageBlockSection>
Debug:

16:48:39:015 USER_DEBUG [20]|DEBUG|(System.SelectOption[value="aBv1b00000000EiCAI", label="2/3/2017", disabled="false"])
 
I have a lookup field and a extenstion to convert the lookup as a select list. Debug log is showing options, but the VF page is not... Any ideas of why the select options aren't populating? 
 
public class BIWorkOrder {
    public Work_Order__c wo {get; set;}  
    public list<Deployment_Cycle__c> Deployments {get;set;}
    public List<SelectOption> options {get; set;}
    public BiWorkOrder(ApexPages.StandardController stdcontroller)
    {
        this.wo = (Work_Order__c)stdcontroller.getRecord();
        getItems();

    }
     public List<SelectOption> getItems() {
        Deployments = [SELECT ID, Deployment_Date__c from Deployment_cycle__c where Deployment_Date__c > :system.Today() and Active__c = true order By Deployment_date__c ASC];
        list<selectOption> options = new List<selectOption>(); 
        for(Deployment_Cycle__c d :deployments)
        {
           string newDate = d.Deployment_date__c.month() + '/' + d.deployment_date__c.day() + '/' + d.deployment_date__c.year();
           options.add(new selectOption (d.id, newDate));
        }
         system.debug(options);
 return options;
         
    }
}
 
<apex:pageBlockSection title="BI Fields" columns="2">
                <apex:inputField value="{!Work_Order__c.Resource__c}" required="false"/>
                <apex:selectList value="{!Work_Order__c.Deployment_Cycle__c}" > ---> Lookup field
                <apex:selectOptions value="{!Options}"></apex:selectOptions>  ---> Options 
                </apex:selectList>
                <apex:inputField value="{!Work_Order__c.Due_Date__c}" required="false"/>
                <apex:inputField value="{!Work_Order__c.Notes__c}" required="false"/>
                <apex:inputField value="{!Work_Order__c.Date_Complete__c}" required="false"/>
                         
            </apex:pageBlockSection>
Debug:

16:48:39:015 USER_DEBUG [20]|DEBUG|(System.SelectOption[value="aBv1b00000000EiCAI", label="2/3/2017", disabled="false"])
 
I am in the process of creating a custom javascript that appears on a opportunity list view. However when I test the button, I recieve the following error: Error in Opportunity Creation = Type Error:sforce.connection.insert is not a function?

The code I am using, I found in the forum and I modified. I am not sure how to resolve the error. I am not a developer. I appeciate the help. 
 
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")};
var url = parent.location.href;
var records = {!GETRECORDIDS($ObjectType.Opportunity)};
var CreateNewRecords = []; 
try
{

if (records[0] == null)
{
	alert("Please select at least one record to update.");
} 
else
 {
	for (var a=0; a<records.length; a++) 
	{
		var create_new_opportunity = new sforce.SObject("opportunity");
		create_new_opportunity.RecordTypeId = "012a0000001ZUXg"; 
		create_new_opportunity.AccountId = "{!Opportunity.Account}"; 
		create_new_opportunity.Closedate =new Date("{TODAYY()}");
		create_new_opportunity.OwnerId = "{!Opportunity.OwnerId}";   
		create_new_opportunity.StageName= "Info Gathering/Investigation";
                create_new_opportunity.Strategy_Type__c= "Full Launch Target";
		CreateNewRecords.push(create_new_opportunity);
	}
var result = sforce.connection.insert(CreateNewRecords);
if (result[0].success=='false')
{
	alert(result[0].errors.message);
}
elese
{
	location.reload(true);
}

}
}
catch(error)
{
alert("Error In Opportunity creation  = "+error);
}

 
Hey Everyone -

I have a callout in my constructor and trying to avoid having to do a remote action and javascript processing. I would like to have the processing done server side and just display the results from the call. The problem is, the page loads before the call is complete so I'm left with a blank page. Dev console shows that the call out was a success and the object was populated. Here's the page and class. Any ideas on how to get this to work or am I stuck with remote action and js processing?
 
//
// Generated by JSON2Apex http://json2apex.herokuapp.com/
//

public class StatushubJSON {
	public static void consumeObject(JSONParser parser) {
		Integer depth = 0;
		do {
			JSONToken curr = parser.getCurrentToken();
			if (curr == JSONToken.START_OBJECT || 
				curr == JSONToken.START_ARRAY) {
				depth++;
			} else if (curr == JSONToken.END_OBJECT ||
				curr == JSONToken.END_ARRAY) {
				depth--;
			}
		} while (depth > 0 && parser.nextToken() != null);
	}

	public class Services {
		public Integer id {get;set;} 
		public String name {get;set;} 
		public String updated_at {get;set;} 
		public Boolean up {get;set;} 
		public Services(JSONParser parser) {
			while (parser.nextToken() != JSONToken.END_OBJECT) {
				if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
					String text = parser.getText();
					if (parser.nextToken() != JSONToken.VALUE_NULL) {
						if (text == 'id') {
							id = parser.getIntegerValue();
						} else if (text == 'name') {
							name = parser.getText();
						} else if (text == 'updated_at') {
							updated_at = parser.getText();
						} else if (text == 'up') {
							up = parser.getBooleanValue();
						} else {
							System.debug(LoggingLevel.WARN, 'Services consuming unrecognized property: '+text);
							consumeObject(parser);
						}
					}
				}
			}
		}
	}
	
	public Integer id {get;set;} 
	public String name {get;set;} 
	public String updated_at {get;set;} 
	public String logo {get;set;} 
	public Integer services_count {get;set;} 
	public Integer down_services_count {get;set;} 
	public String subdomain {get;set;} 
	public List<Services> services {get;set;} 

	public StatushubJSON(JSONParser parser) {
		while (parser.nextToken() != JSONToken.END_OBJECT) {
			if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
				String text = parser.getText();
				if (parser.nextToken() != JSONToken.VALUE_NULL) {
					if (text == 'id') {
						id = parser.getIntegerValue();
					} else if (text == 'name') {
						name = parser.getText();
					} else if (text == 'updated_at') {
						updated_at = parser.getText();
					} else if (text == 'logo') {
						logo = parser.getText();
					} else if (text == 'favicon') {
						
					} else if (text == 'services_count') {
						services_count = parser.getIntegerValue();
					} else if (text == 'down_services_count') {
						down_services_count = parser.getIntegerValue();
					} else if (text == 'subdomain') {
						subdomain = parser.getText();
					} else if (text == 'services') {
						services = new List<Services>();
						while (parser.nextToken() != JSONToken.END_ARRAY) {
							services.add(new Services(parser));
						}
					} else {
						System.debug(LoggingLevel.WARN, 'Root consuming unrecognized property: '+text);
						consumeObject(parser);
					}
				}
			}
		}
	}
	
	
	public static StatushubJSON parse(String json) {
		return new StatushubJSON(System.JSON.createParser(json));
	}
}
public class StatusHub {
   public string result {get;set;}
   public List <StatusHubJSON > parse {get;set;}  
    
    public statusHub()
    {
        Http h=new  Http();
        HttpRequest req=new  HttpRequest();
        req.setMethod('GET');
        req.setHeader('api-key','xxxxxx');
        req.setEndPoint('https://app.statushub.io/api/status_pages/fwi-status');
        HttpResponse res = h.send(req);
        string json = res.getBody();
        StatusHubJSON parse=new StatusHubJSON(System.JSON.createParser(json));
     }
    
    

}


 
Hi,
A salesforce newbie here.  We are using PersonAccount in our Salesforce org. We have also installed and configured the Marketing Cloud Connector. Our website inserts records into Salesforce whenever someone purchases a subscription to our product. Because of technical limitations of the third party we are using for managing subscription, we have to run a nightly job to update Salesforce with subscription related information. Now, we want to send a triggered email whenever the field "subscription status" gets updated. I have a couple of questions:
  1. We want to avoid having to send duplicate emails. We only want to send the email the first time the "subscription status" field gets updated. Our nightly job updates all records every time. Knowing this, what is the best way to achieve this using the triggered send configuration in Salesforce.
  2. Below are the "trigger" and "Apex Test Class" that I have created to get this going. Do I need to do anything else?
Trigger:
trigger Trig_Account on Account (after insert, after update) {
et4ae5.triggerUtility.automate('Account');
}
Apex Test Class:
@isTest
private class Trig_AccountTest {
static testMethod void myUnitTest() {
    Account testAccount = new Account(LastName = 'Test Account', PersonEmail = 'testclass@crtv.com');
    insert testAccount;
    testAccount = [select Id, LastName from Account where id = :testAccount.Id];
    System.assertEquals(testAccount.LastName, 'Test Account');
}


 
Did anyone facing this error,any idea about it
"NetworkError: 404 Not Found - https://c.cs61.visual.force.com/resource/1476441040000/jQuery181/jquery/images/ui-bg_flat_75_ffffff_40x100.png"
  • October 19, 2016
  • Like
  • 0
I currently have a standard approval process with different levels of approvals which are not on the same level and if incase at any level an approval is rejected then on resubmission the record goes to the person who has rejected the record and the intial approval steps gets autoapproved (I currently have code written in apex for the auto approval).

But my issue is when the record is getting auto approved on resubmission it is also sending the email notifications too. Is there a way to stop sending those notifications using Apex? Thanks.
I am attempting to create a custom object within a flow.  When I run it I receive the following error

"An error occurred at element Create_RMG_RMA_Number (FlowRecordCreate).
INSERT --- INSERT FAILED --- ERRORS : (INVALID_ID_FIELD) Record ID: id value of incorrect type:"

I am able to create a standard object (account) without receiving this error.  Any guidance would be helpful.
trigger NAICSUpdate on Account (before insert, before update) {
List<NAICS_Code__c> codes = [SELECT Name, Description__c from NAICS_CODE__C];
Set<NAICS_CODE__C> setcodes = new set <NaICS_code__c>();
setcodes.addAll(codes);    
for (Account acct :Trigger.new)
 {
   if(acct.NaicsCode != NULL)
   {
       try {
     string twoDigit =  acct.NaicsCode.left(2);
     string threeDigit =  acct.NaicsCode.left(3);
     NAICS_Code__c nCode2desc = [SELECT Name, Description__c from NAICS_CODE__C where Name = :twoDigit limit 1]; 
     NAICS_Code__c nCode3desc = [SELECT Name, Description__c from NAICS_CODE__C where Name = :threeDigit limit 1]; 
     acct.NAICS_2_Digit_Desc__c = nCode2desc.Description__c;
     acct.NAICS_3_Digit_Desc__c = nCode3desc.Description__c;           
}
       catch (Exception e) {
           system.debug('Failed');
       }
   }
       
     
     
 }
}

I'm trying to remove the two queries in the for loop. I can't use a map since I'm searching by name and not ID. I'm not really sure how to utilize set to return the right description if I use contains. Any help would greatly be appreciated.
 
Hi all

Is there a simple way to add in a few lines of code to existing Apex triggers to prevent them running rather than having to go into all 45 of them when Im performing various admin tasks.

The triggers when executed send various emails to internal and external customers and amend or create records that I would usually disable before starting my tasks.

Can code be added to reference a value in a table or selected drop down that then allows or disallows the remainder of the code to be ran

thanks in advance
James
All,
Noob, untrained, in wolf territory. I have a question on triggers and transactions. I am looking at existing code so here's an example of what I need to understand:
1. trigger on case does a DML insert or update to a case comment inside the trigger code
2. there is also a trigger on the case comment and that does some DML 

Now I understand that the terms transaction and context are interchangeable. So my question is: Are #1 and #2 in the same transaction (thru the commit of #2)??? Or is the transaction boundary of #1 at some point in #2 before the commit of #2 occurs?

I am having a problem with callouts where triggers and handlers and a mix of furure and sync calls are made. I follow it all but I really need to understand where the boundary is. The code below from the SF docs suggests to be that the transaction (in my case) would include thru the commit of #2. But what bugs me on this is that I have read that trigger calls are batched by the system up to 200 calls.

"For example, consider the following chain of operations: a custom Apex Web service method causes a trigger to fire, which in turn calls a method in a class. In this case, all changes are committed to the database only after all operations in the transaction finish executing and don’t cause any errors. If an error occurs in any of the intermediate steps, all database changes are rolled back and the transaction isn’t committed."
So I'm parsing a Http repsonse and I keep getting a nullpointer exception when I know a child element is there. This is my first XML rodeo so I was hoping for suggestions.

My Debug log before adding the getchildelement is this:
 
15:22:10:905 USER_DEBUG [27]|DEBUG|nodeXMLNode[ELEMENT,createCustomerProfileResponse,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,[common.apex.api.dom.XmlNode$NamespaceDef@21526738, common.apex.api.dom.XmlNode$NamespaceDef@582ef6d5, common.apex.api.dom.XmlNode$NamespaceDef@61835476],[XMLNode[ELEMENT,messages,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[ELEMENT,resultCode,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[TEXT,null,null,null,null,null,Error,]],null,], XMLNode[ELEMENT,message,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[ELEMENT,code,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[TEXT,null,null,null,null,null,E00039,]],null,], XMLNode[ELEMENT,text,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,[XMLNode[TEXT,null,null,null,null,null,A duplicate record with ID 40545008 already exists.,]],null,]],null,]],null,], XMLNode[ELEMENT,customerPaymentProfileIdList,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,null,null,], XMLNode[ELEMENT,customerShippingAddressIdList,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,null,null,], XMLNode[ELEMENT,validationDirectResponseList,AnetApi/xml/v1/schema/AnetApiSchema.xsd,null,null,null,null,]],null,]
But when I add the getChildElement('resultCode',null).getText(); I'm getting a Null Pointer Exception even though the value is in the XML document. Any advice on what I'm missing?
 
public void process()
{
isSuccess = false;
string xml = getxmlRes();
Http h = new http();
HttpRequest req = new HttpRequest(); 
req.setEndpoint('https://apitest.authorize.net/xml/v1/request.api');
req.setMethod('POST');
req.setbody(xml);
HttpResponse res = h.send(req);
isSuccess = true;
Dom.Document doc = res.getBodyDocument();
status = res.getStatusCode();
Dom.XMLNode node = doc.getRootElement();
profilename = node.getChildElement('resultCode', null).gettext();
System.debug('ukpostcode: ' + node); 
body = res.getBody();
}

 
Helloo,

Can anybody please tell how to set bootstrap for my vf page.I have tried in many ways but am not finding the exact way how to use bootstrap in my vf.
<apex:page id="page" controller="LiveChatTranscriptController" sidebar="false" docType="html-5.0" tabStyle="AccountInfo__c" >
    <apex:pageMessages id="msgs" />
    <apex:form id="form" >
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"/>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
          <apex:outputText value="From Date:" /> 
        <apex:input type="date" id="fromDate" value="{!fromDate}" style="display:none;"  />
        <input type="text" id="fromDatePicker"/>&nbsp;
        <apex:outputText value="To Date:" />
        <apex:input type="date" id="toDate" value="{!toDate}" style="display:none;" /> 
        <input type="text" id="toDatePicker"/>&nbsp;
        <script type="text/javascript">
        var $j = jQuery.noConflict();
        $j( "#fromDatePicker" ).datepicker({
            altField: "#page\\:form\\:fromDate",
            altFormat: "yy-mm-dd"
        });
        $j( "#toDatePicker" ).datepicker({
            altField: "#page\\:form\\:toDate",
            altFormat: "yy-mm-dd"
        });
        $j("#fromDatePicker").value($j("#page\\:form\\:fromDate").value());
        $j("#toDatePicker").value($j("#page\\:form\\:toDate").value());
        </script>
       <apex:outputText value="Select User:" />
        <apex:selectlist value="{!Users}" size="1" >
        <apex:selectOptions value="{!userList}"/>   
        </apex:selectlist> &nbsp;&nbsp; 
         <apex:outputText value="Select Status:" />
        <apex:selectlist value="{!Status}" size="1" >
        <apex:selectOptions value="{!statusList}"/>   
        </apex:selectlist> &nbsp;&nbsp;  
        <apex:commandButton Id="btnSearch" action="{!Search}" reRender="msgs,renderBlock,form" value="Search" /><br/>
        <apex:commandLink value="Export" action="{!export}" style="float:Right;color:#0080ff;" /><br/><br/>
        <apex:pageBlock id="renderBlock" >
            <apex:pageBlockSection title="LiveAgent Visitor and Transcript details ">
            <apex:pageblockTable value="{!liveAgent}" var="item" rendered="{!NOT(ISNULL(liveAgent))}">
                <apex:column value="{!item.VisitorObj.name}"></apex:column>
                <apex:column value="{!item.VisitorObj.SessionKey}"></apex:column>
                <apex:column value="{!item.TranscriptObj.name}"></apex:column>
                <apex:column value="{!item.TranscriptObj.LiveChatVisitorId}"></apex:column>
                <apex:column value="{!item.TranscriptObj.AccountId}"></apex:column>
                <apex:column value="{!item.TranscriptObj.ContactId}"></apex:column>
                <apex:column value="{!item.TranscriptObj.CaseId}"></apex:column>
                <apex:column value="{!item.TranscriptObj.Browser}"></apex:column>
                <apex:column value="{!item.TranscriptObj.IpAddress}"></apex:column>
                <apex:column value="{!item.TranscriptObj.Location}"></apex:column>
                <apex:column value="{!item.TranscriptObj.EndedBy}"></apex:column>
                <apex:column value="{!item.TranscriptObj.UserAgent}"></apex:column>
                <apex:column value="{!item.TranscriptObj.Platform}"></apex:column>
                <apex:column value="{!item.TranscriptObj.CreatedById}"></apex:column>
                <apex:column value="{!item.TranscriptObj.CreatedDate}"></apex:column>
                <apex:column value="{!item.TranscriptObj.Status}"></apex:column>
            </apex:pageblockTable>
                </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
My Vf Page screen shot



 
We have two Salesforce appexchange product for developers. We need sharp developers on a part-time basis. You will spend 3-4 hours everyday responding to customer requests.

It is okay to have another job.

We are looking for A players. If you are just starting out with Salesforce, please feel free to pass this offer.
Your main task will be:
1. Test our product
2. Respond to customer support requests.

You will not be responsible for development.

We need someone with the following qualities:
1. You are a fast learner.
2. You must have good communication skills.
3. You are great at Salesforce.
Here is my code:
public expenseController(ApexPages.StandardController controller) { this.proj = (Expense_Report__c) controller.getSubject(); this.delivers = '[SELECT d.Name, d.Billable__c, d.Comments__c, d.Travel_type__c, d.Purchase_type__c, d.Expense_Report__c, d.Id, d.Purchase_Date__c, d.Quantity__c, d.Sales_Tax__c, d.Shipping__c, d.total__c, d.type__c, d.unit_price__c, d.Description__c,d.Price_Override__c,d.Override_Price__c'+ 'FROM Expense_Line_Items__c d' + 'WHERE d.Expense_Report__c = : proj.id' + 'Order by' + 'sortOrder' + 'DESC' + ']'; }


Any thoughts why I'm getting this error?
 
Capture Name below choose file when inserted
<apex:page controller="Fileattachment1">
    <apex:form >
    <apex:pageBlock >
        <b><u><i>Attachment:</i></u></b><apex:inputCheckbox value="{!abool}">
        <apex:actionSupport action="{!upload}" event="onchange"/>
        </apex:inputCheckbox>
        <br/><br/>
        <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file" rendered="{!abool}"/>
        <br/><br/>
        <apex:commandButton value="Save" action="{!Save}" rendered="{!abool}"/>
    </apex:pageBlock>
    </apex:form>
</apex:page>
 
public with sharing class Fileattachment1 {

    public boolean abool{set;get;}
    public boolean bbool{set;get;}
    
    public Attachment attachment {
    get {
    if (attachment == null)
    attachment = new Attachment();
    return attachment;
    }
    set;
    }
    
    
    public void check()
    {
      if(abool == true)
      {
      abool=true;
      }
    }
    
    
    public pagereference save()
    {   
    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = '0012800000JAVhi';
    try {
    insert attachment;
    } catch (DMLException e) {
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));  
    } finally {
    attachment = new Attachment(); 
    }   
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
    }
    
        
    public PageReference upload() {
    if(abool == true)
      {
       check();
      }  
    return null;
  }
}