• Denis O'Leary
  • NEWBIE
  • 65 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 9
    Replies
Hi,

I have a map which consists of an sObject and a custom class, i'm mapping objects that i need to process to a class.
map<service_call__c, JobResponse> scTaskList = new map<service_call__c, JobResponse>();
My issue is I perform an upsert on the Service call object before I send this scTaskList map into another method for some further processing. After I perform that upsert the Service_call__c object that is in the map will get an ID assigned to it (if it wasn't an exisiting record) but it then looses it's mapped Job response. 

Is there anything I can do to prevent this? 
Hi,

i have a detail button set on an Account page as an Execute JavaScript/On Click JavaScript button. 

The button has the following: (which i got from the salesforce documentation)
{!REQUIRESCRIPT("/soap/ajax/37.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/37.0/apex.js")}
var result = sforce.apex.execute("AccountToFACustomer","CreateCustomer",
{
Account.Name:"{! Account.Name}",
Account.Email__c: "{!Account.Email__c}",
Account.Phone:"{!Account.Phone}",
Account.Website: "{!Account.Website}",
Account.Sage_ID__c:"{!Account.SAGE_Id__c}",
Account.BillingStreet:"{!Account.BillingStreet}",
Account.BillingCity: "{!Account.BillingCity}",
Account.BillingState: "{!Account.BillingState}",
Account.BillingCountry: "{!Account.BillingCountry}"
}
);
alert(result);
window.location.reload();
and I have it calling a class i created below, should this work or am i totally missing the mark? 
public with sharing class AccountToFACustomer{ 

        public class Response {
        public integer code {get; set;}
        public String body {get; set;}
        public boolean success {get; set;}
        
        public Response (integer code, String body){
                this.code = code;
        		this.body = body;
        		this.success = (code == 200 || code == 201);
        }
    }
	
    public class CustomerResponse{     
        public string uuid {get; set;}
        public string link {get; set;}
        public string location {get; set;}
    }
  

    public Response CreateCustomer(){
        
        Response resp;
        
        string endpoint = 'https://apistaging.website.net/customer/';
        string token = 'Token XXXXXXXX';
        string method = 'POST';
        
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http h = new http();
        
        req.setEndpoint(endpoint);
        req.setMethod(method);
        req.setHeader('Authorization', token);
		req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept-Type', 'application/json');
        
        
        req.setBody(
            '{"name":"'+ Account.Name +'",' +
            '"email":"'+ Account.Email__c + '",'+
             '"phone":"'+ Account.Phone +'",'+
             '"website":"'+ Account.Website +'",'+
             '"location":{'+
                 	'"name":"Account No: '+ Account.Sage_ID__c +'",'+
                    '"streetName":"'+ Account.BillingStreet +'",'+
                    '"locality":"'+ Account.BillingCity +'",'+
                    '"postcode":"'+ Account.BillingState +'",'+
                    '"country":"'+ Account.BillingCountry +'" }}' 
        );
        

            
		res = h.send(req);
        resp = new Response(res.getStatusCode(), res.getBody());         
        return resp;   
    
    }
}


 
Hi,

Can some one help with my next steps on an Apex Rest Class? 

I have the following class: 
public with sharing class AccountToFACustomer {
    
    public class Response{
        public integer code {get; set;}
        public String body {get; set;}
        public boolean success {get; set;}
        public String errorText {get; set;}
        
        public Response (integer code, String body){
                this.code = code;
        		this.body = body;
        		this.success = (code == 200 || code == 201);
        }
    }
	
    public class customerResponse{
        
        public string uuid {get; set;}
        public string link {get; set;}
        public string location {get; set;}
    }
    
    public Response CreateCustomer (string description){
        
        Response resp;
        
        string endpoint = 'https://apistaging.website.net/';
        string token = 'Token XXXXXX';
        string method = 'POST';
        
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http h = new http();
        
        req.setEndpoint(endpoint);
        req.setMethod(method);
        req.setHeader('Autorization', token);
		req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept-Type', 'application/json');
        
        req.setBody(
            '{"name":"'+ Account.Name +'",' +
            '"email":"'+ Account.Email__c + '",'+
             '"phone":"'+ Account.Phone +'",'+
             '"website":"'+ Account.Website +'",'+
             '"location":{'+
                 	'"name":"Account No: '+ Account.Sage_ID__c +'",'+
                    '"streetName":"'+ Account.BillingStreet +'",'+
                    '"locality":"'+ Account.BillingCity +'",'+
                    '"postcode":"'+ Account.BillingState +'",'+
                    '"country":"'+ Account.BillingCountry +'" }}' 
        );
        try{
            
		res = h.send(req);
        resp = new Response(res.getStatusCode(), res.getBody()); 
            
            if (resp.success) {
                customerResponse custResp = (customerResponse)JSON.deserialize(res.getBody(), customerResponse.class);
            }
            
        }
        	 catch(System.CalloutException e) {
   				 System.debug('Callout error: '+ e);
           		 return resp;
        }        
        return resp;   
    
    }
}

And i'm using a blank visualforce page to run the class when a button is pushed: 
 
<apex:page standardController="Account" action="AccountToFACustomer" >
    
</apex:page>

When I push the button i get the following error: Formula Expression is required on the action attributes. 

Is the blank VF page ok, or should i have more detail in here? 
Hi,

I am trying to write my first Apex test class and I keep on getting an error: 

Non-void method might not return a value or might have statement after a return statement.

Can someone see what I have done wrong? 
public with sharing class AccountToFACustomer {
    
    public class Response{
        public integer code {get; set;}
        public String body {get; set;}
        public boolean success {get; set;}
        public String errorText {get; set;}
        
        public Response (integer code, String body){
                this.code = code;
        		this.body = body;
        		this.success = (code == 200 || code == 201);
        }
    }
	
    public class customerResponse{
        
        public string uuid {get; set;}
        public string link {get; set;}
        public string location {get; set;}
    }
    
    public Response CreateCustomer (string description){
        
        Response resp;
        
        string endpoint = 'https://apis.website.net/';
        string token = 'Token XXXXX';
        string method = 'POST';
        
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http h = new http();
        
        req.setEndpoint(endpoint);
        req.setMethod(method);
        req.setHeader('Autorization', token);
		req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept-Type', 'application/json');
        
        req.setBody(
            '{"name":"'+ Account.Name +'","email":"'+ Account.Email__c + '",'+
             '"phone":"'+ Account.Phone +'",'+
             '"website":"'+ Account.Website +'",'+
             '"location":{'+
                 	'"name":"Account No: '+ Account.Sage_ID__c +'",'+
                    '"streetName":"'+ Account.BillingStreet +'",'+
                    '"locality":"'+ Account.BillingCity +'",'+
                    '"postcode":"'+ Account.BillingState +'",'+
                    '"country":"'+ Account.BillingCountry +'" }}' 
        );
        try{
            
		res = h.send(req);
        resp = new Response(res.getStatusCode(), res.getBody()); 
            
            if (resp.success) {
                customerResponse custResp = (customerResponse)JSON.deserialize(res.getBody(), customerResponse.class);
            }
            
        }
        	 catch(System.CalloutException e) {
   				 System.debug('Callout error: '+ e);
           
        }        
          
    
    }
}

 
I have an apex Class that I've entered in my Sandbox, I'm trying to deploy this to my production Org but I'm getting an error saying that the code coverage is too low. I've read up on creating test classes but I'm still a bit lost. Is there any documentation not just on creating a test class but one that will show you how to create a test class that tests the code you have in the Class you are looking to deploy? 
Hi,

I'm trying to view a custom salesforce object as a PDF. I've an object that has object Line Items (Not too dissimalar to Opportunity -> Opportunity Products set up) I want to print the custom object with the line items attached but can't seem to see how to do this.

This works on the Opportunity object for printing the list of opporunity products on to a table-> 
<apex:repeat var="lineitem" value="{!opportunity.OpportunityLineItems}"> 

but when I try this on my custom object <apex:repeat var="lineitem" value="{!Estimate__c.Estimate_Product_Line_Item__c}"> 
I get an error "Invalid Field Estimate_Product_Line_Item__c for SObject Estimate__c"

There is a master detail relationship between my objects Estimate and Estimate products

Can any one help with something that might get me off the ground on this? 
Can anyone help with the below:

I'm trying to stop this trigger from creating an extra object every time the Opportunity page is updated.


trigger createPMPage on Opportunity (after update) {

    List <Project_Management__c> PMInsert  = new List <Project_Management__c> ();
  
 
for (Opportunity o : Trigger.new)
    {
         Project_Management__c p = new Project_Management__c ();


  if (o.Job_Type__c == '1' )
    
        {
   p.Project__c = o.Id;
         p.Name = o.Name;
         p.OwnerId = '005b0000000hZc9';  
         if( o.Stage_One__c != Null){
             p.Stage_five_Invoice__c = 'Ready to Invoice';}//end if
        }//end if
      
        if (o.Job_Type__c == '2'  )
        {
        p.Project__c = o.Id;
  p.Name = o.Name;
        p.OwnerId = '005b0000000hIRM';
        if( o.Stage_One__c != Null){
             p.Stage_five_Invoice__c = 'Ready to Invoice';}//end if
        }//end if
      
         if (o.Job_Type__c == '3'  )
        {
   p.Project__c = o.Id;
         p.Name = o.Name;
         p.OwnerId = '005b0000000jCjP';
         if( o.Stage_One__c != Null){
             p.Stage_five_Invoice__c = 'Ready to Invoice';}//end if
        }//end if

      
        if(trigger.newMap.get(o.name) != trigger.OldMap.get(p.Project__c)){
         PMInsert.add(p);
         }

  }//end for

  insert PMInsert;
     }//end trigger
Hi,

I wanted to Add a button to an Opp page that when clicked would be able to run a file on my server. Is something like this possible? 
Hi,

I have a map which consists of an sObject and a custom class, i'm mapping objects that i need to process to a class.
map<service_call__c, JobResponse> scTaskList = new map<service_call__c, JobResponse>();
My issue is I perform an upsert on the Service call object before I send this scTaskList map into another method for some further processing. After I perform that upsert the Service_call__c object that is in the map will get an ID assigned to it (if it wasn't an exisiting record) but it then looses it's mapped Job response. 

Is there anything I can do to prevent this? 
Hi,

i have a detail button set on an Account page as an Execute JavaScript/On Click JavaScript button. 

The button has the following: (which i got from the salesforce documentation)
{!REQUIRESCRIPT("/soap/ajax/37.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/37.0/apex.js")}
var result = sforce.apex.execute("AccountToFACustomer","CreateCustomer",
{
Account.Name:"{! Account.Name}",
Account.Email__c: "{!Account.Email__c}",
Account.Phone:"{!Account.Phone}",
Account.Website: "{!Account.Website}",
Account.Sage_ID__c:"{!Account.SAGE_Id__c}",
Account.BillingStreet:"{!Account.BillingStreet}",
Account.BillingCity: "{!Account.BillingCity}",
Account.BillingState: "{!Account.BillingState}",
Account.BillingCountry: "{!Account.BillingCountry}"
}
);
alert(result);
window.location.reload();
and I have it calling a class i created below, should this work or am i totally missing the mark? 
public with sharing class AccountToFACustomer{ 

        public class Response {
        public integer code {get; set;}
        public String body {get; set;}
        public boolean success {get; set;}
        
        public Response (integer code, String body){
                this.code = code;
        		this.body = body;
        		this.success = (code == 200 || code == 201);
        }
    }
	
    public class CustomerResponse{     
        public string uuid {get; set;}
        public string link {get; set;}
        public string location {get; set;}
    }
  

    public Response CreateCustomer(){
        
        Response resp;
        
        string endpoint = 'https://apistaging.website.net/customer/';
        string token = 'Token XXXXXXXX';
        string method = 'POST';
        
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http h = new http();
        
        req.setEndpoint(endpoint);
        req.setMethod(method);
        req.setHeader('Authorization', token);
		req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept-Type', 'application/json');
        
        
        req.setBody(
            '{"name":"'+ Account.Name +'",' +
            '"email":"'+ Account.Email__c + '",'+
             '"phone":"'+ Account.Phone +'",'+
             '"website":"'+ Account.Website +'",'+
             '"location":{'+
                 	'"name":"Account No: '+ Account.Sage_ID__c +'",'+
                    '"streetName":"'+ Account.BillingStreet +'",'+
                    '"locality":"'+ Account.BillingCity +'",'+
                    '"postcode":"'+ Account.BillingState +'",'+
                    '"country":"'+ Account.BillingCountry +'" }}' 
        );
        

            
		res = h.send(req);
        resp = new Response(res.getStatusCode(), res.getBody());         
        return resp;   
    
    }
}


 
Hi,

Can some one help with my next steps on an Apex Rest Class? 

I have the following class: 
public with sharing class AccountToFACustomer {
    
    public class Response{
        public integer code {get; set;}
        public String body {get; set;}
        public boolean success {get; set;}
        public String errorText {get; set;}
        
        public Response (integer code, String body){
                this.code = code;
        		this.body = body;
        		this.success = (code == 200 || code == 201);
        }
    }
	
    public class customerResponse{
        
        public string uuid {get; set;}
        public string link {get; set;}
        public string location {get; set;}
    }
    
    public Response CreateCustomer (string description){
        
        Response resp;
        
        string endpoint = 'https://apistaging.website.net/';
        string token = 'Token XXXXXX';
        string method = 'POST';
        
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http h = new http();
        
        req.setEndpoint(endpoint);
        req.setMethod(method);
        req.setHeader('Autorization', token);
		req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept-Type', 'application/json');
        
        req.setBody(
            '{"name":"'+ Account.Name +'",' +
            '"email":"'+ Account.Email__c + '",'+
             '"phone":"'+ Account.Phone +'",'+
             '"website":"'+ Account.Website +'",'+
             '"location":{'+
                 	'"name":"Account No: '+ Account.Sage_ID__c +'",'+
                    '"streetName":"'+ Account.BillingStreet +'",'+
                    '"locality":"'+ Account.BillingCity +'",'+
                    '"postcode":"'+ Account.BillingState +'",'+
                    '"country":"'+ Account.BillingCountry +'" }}' 
        );
        try{
            
		res = h.send(req);
        resp = new Response(res.getStatusCode(), res.getBody()); 
            
            if (resp.success) {
                customerResponse custResp = (customerResponse)JSON.deserialize(res.getBody(), customerResponse.class);
            }
            
        }
        	 catch(System.CalloutException e) {
   				 System.debug('Callout error: '+ e);
           		 return resp;
        }        
        return resp;   
    
    }
}

And i'm using a blank visualforce page to run the class when a button is pushed: 
 
<apex:page standardController="Account" action="AccountToFACustomer" >
    
</apex:page>

When I push the button i get the following error: Formula Expression is required on the action attributes. 

Is the blank VF page ok, or should i have more detail in here? 
Hi,

I am trying to write my first Apex test class and I keep on getting an error: 

Non-void method might not return a value or might have statement after a return statement.

Can someone see what I have done wrong? 
public with sharing class AccountToFACustomer {
    
    public class Response{
        public integer code {get; set;}
        public String body {get; set;}
        public boolean success {get; set;}
        public String errorText {get; set;}
        
        public Response (integer code, String body){
                this.code = code;
        		this.body = body;
        		this.success = (code == 200 || code == 201);
        }
    }
	
    public class customerResponse{
        
        public string uuid {get; set;}
        public string link {get; set;}
        public string location {get; set;}
    }
    
    public Response CreateCustomer (string description){
        
        Response resp;
        
        string endpoint = 'https://apis.website.net/';
        string token = 'Token XXXXX';
        string method = 'POST';
        
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http h = new http();
        
        req.setEndpoint(endpoint);
        req.setMethod(method);
        req.setHeader('Autorization', token);
		req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept-Type', 'application/json');
        
        req.setBody(
            '{"name":"'+ Account.Name +'","email":"'+ Account.Email__c + '",'+
             '"phone":"'+ Account.Phone +'",'+
             '"website":"'+ Account.Website +'",'+
             '"location":{'+
                 	'"name":"Account No: '+ Account.Sage_ID__c +'",'+
                    '"streetName":"'+ Account.BillingStreet +'",'+
                    '"locality":"'+ Account.BillingCity +'",'+
                    '"postcode":"'+ Account.BillingState +'",'+
                    '"country":"'+ Account.BillingCountry +'" }}' 
        );
        try{
            
		res = h.send(req);
        resp = new Response(res.getStatusCode(), res.getBody()); 
            
            if (resp.success) {
                customerResponse custResp = (customerResponse)JSON.deserialize(res.getBody(), customerResponse.class);
            }
            
        }
        	 catch(System.CalloutException e) {
   				 System.debug('Callout error: '+ e);
           
        }        
          
    
    }
}

 
I have an apex Class that I've entered in my Sandbox, I'm trying to deploy this to my production Org but I'm getting an error saying that the code coverage is too low. I've read up on creating test classes but I'm still a bit lost. Is there any documentation not just on creating a test class but one that will show you how to create a test class that tests the code you have in the Class you are looking to deploy? 
Hi,

I'm trying to view a custom salesforce object as a PDF. I've an object that has object Line Items (Not too dissimalar to Opportunity -> Opportunity Products set up) I want to print the custom object with the line items attached but can't seem to see how to do this.

This works on the Opportunity object for printing the list of opporunity products on to a table-> 
<apex:repeat var="lineitem" value="{!opportunity.OpportunityLineItems}"> 

but when I try this on my custom object <apex:repeat var="lineitem" value="{!Estimate__c.Estimate_Product_Line_Item__c}"> 
I get an error "Invalid Field Estimate_Product_Line_Item__c for SObject Estimate__c"

There is a master detail relationship between my objects Estimate and Estimate products

Can any one help with something that might get me off the ground on this? 
Can anyone help with the below:

I'm trying to stop this trigger from creating an extra object every time the Opportunity page is updated.


trigger createPMPage on Opportunity (after update) {

    List <Project_Management__c> PMInsert  = new List <Project_Management__c> ();
  
 
for (Opportunity o : Trigger.new)
    {
         Project_Management__c p = new Project_Management__c ();


  if (o.Job_Type__c == '1' )
    
        {
   p.Project__c = o.Id;
         p.Name = o.Name;
         p.OwnerId = '005b0000000hZc9';  
         if( o.Stage_One__c != Null){
             p.Stage_five_Invoice__c = 'Ready to Invoice';}//end if
        }//end if
      
        if (o.Job_Type__c == '2'  )
        {
        p.Project__c = o.Id;
  p.Name = o.Name;
        p.OwnerId = '005b0000000hIRM';
        if( o.Stage_One__c != Null){
             p.Stage_five_Invoice__c = 'Ready to Invoice';}//end if
        }//end if
      
         if (o.Job_Type__c == '3'  )
        {
   p.Project__c = o.Id;
         p.Name = o.Name;
         p.OwnerId = '005b0000000jCjP';
         if( o.Stage_One__c != Null){
             p.Stage_five_Invoice__c = 'Ready to Invoice';}//end if
        }//end if

      
        if(trigger.newMap.get(o.name) != trigger.OldMap.get(p.Project__c)){
         PMInsert.add(p);
         }

  }//end for

  insert PMInsert;
     }//end trigger