• Scoobie
  • NEWBIE
  • 173 Points
  • Member since 2010

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

Hello

 

Need two Apex Controllers created which I do not know how to do could someone please let me know if they are able to create them based on the required information below and how long and much it would cost to do would be great. We will pay.

 

1.  We have a form (custom object – Coaching Template) within this form on Salesforce I have a button ‘Print Template’ this exports the data in the PDF using VF. The next step is where I am getting stuck. I need to include the tasks attached to the custom object on the print off. I can get the task on but it only shows the first task and not the rest. Is this where a controller is required to get the multiple tasks?

 

2.  We have a form (custom object – Visit Scorecard) within this form I have a print button as well and would like to print the form off and include the tasks like question 1. Another thing we would like to also add to the form is all the visit scorecards and annual interim reviews that are related to the employee object from the current visit scorecard you are on. I have included a little graph of the objects and their relationships.

 

I hope this makes sense and you can understand what I am trying to achieve. If not let me know.

 

Hope someone can help :)

 

Regards
James

 

Object Relationship

 

 

 

 

  • October 11, 2010
  • Like
  • 0

Hello,

 

I am trying to create a  trigger for understanding Maps as my real life situation has similar Object relationships.

 

I want all the Opportunity Names to be Populated as a New Contact  on insert or update.

 

My Problem is I have been able to successfuly query the Opportunity Name and create a new Contact. I am not able to iterate thru the Opporunity Object Map or when there are multiple Opportunities only one contact gets created.

 

I am enclosing the code and I hope this can run on any instance as I am using standard objects.

 

Thanks in advance.

trigger accountContactFromOpp1 on Account (before insert, before update) {
	//trigger accountContactFromOpp on Account (before update, before insert) {
/*
	This is a MAP test the objective is to query all Opportunities for an account which 
	has Billing city as Null (just a test)	New Contact for each Opportunity Name
*/
	//passing on all Account Id into a set
	Set<ID> AcctId = new Set<ID>();
	
	//loop thru the trigger set and build a set of all the Accounts with no contacts.
	
	for(Account acct : Trigger.new){
		if (acct.BillingCity == NULL){
			AcctId.add(acct.Id);
		}
	
	}
	//for query thos Accouts Id and create a map connecting them 	
		Map<ID,Opportunity> myOppMap = new Map<ID,Opportunity>();
	
	for(Opportunity thisOpp : [Select Id, Name, AccountId From Opportunity where AccountId IN : AcctId]){
		myOppMap.put(thisOpp.AccountId,thisOpp);
	}
	//looping thru the Trigger again ok
	for(Account acct : Trigger.new){
		if(acct.BillingCity == NULL){
			acct.Description = myOppMap.get(acct.Id).Name;
						
				Contact cont = new Contact(LastName = myOppMap.get(acct.Id).Name,AccountId = acct.Id);
				insert cont;
				
		}
	
	}//end loop acct Trigger.new
}

 

 

Hi,

I am creating a PDF doc rendered from visual force page, now I want to

display dashboard or graphs (pie chart,etc.) in PDF doc. Is there any way to do this ?

 

I would really appreciate for reply.

 

 

Thanks.

Hello!

 

I am new to Salesforce, I am trying to enable and make a text field mandatory if picklist value is "Other". 

Saw few posts online, but nothing seemed to help, the solution lies in Triggers or Workflow, just not sure how to go about it. 

 

Thanks in advance.

okay so im getting this error:

 

Compile Error: line 19, column 7: Invalid foreign key relationship: Lead.createdDate

 

 

with this code:

 

it comes from the part where i compare each aspect of CreatedDate to my variables.

     

 

 

public with sharing class stuff {
Date   oldThreshold = Date.newInstance(2010, 1, 1); 
String newStatusForOldLeads = 'Archive-Omitted';

   
List<Lead> oldLeads = [select id, createdDate, status, isConverted
from Lead where status = 'open' OR status = 'working'];

List<Lead> leadsToUpdate = new List<Lead>();


{
if(oldLeads.size() > 0)
{
 
 for(Lead currentLead: oldLeads)
 {  
  integer compareyear = 2010;
integer comparemonth = 1;
integer compareday = 1;
  //Date x = currentLead.CreatedDate.Date;
  
  if (currentLead.CreatedDate.year < compareyear &&
     currentLead.CreatedDate.month < comparemonth &&
     currentlead.CreatedDate.day < compareday)
     {
    
     
     
      currentLead.status = newStatusForOldLeads;  
      leadsToUpdate.add(currentLead);
 


       
     }
  }
}

if(leadsToUpdate.size() > 0)
{
update(leadsToUpdate);
}
 


}
}

 

I don't get it ?

I am having a problem with my navigation inside of a custom page layout. Here is a little background.

 

  • I have created a new Lead Page Layout
  • I have created a new Section on that Page Layout
  • Inside the section I have included a new Custom VF Page that displays some data

 

Here is the problem:

  1. Salesforce loads the custom VF page into an IFrame.
  2. Therefore when I select a link that is displayed in the custom section that I have created, It loads the selected navigation into the section instead of into the browser window. Obviously, this is a P3P issue.

Some things that I have tried:

  1. Added a script tag to check the window location with the top location.
  2. Modified the script tag to load the location of the JavaScript top object.

Is there a solution for this, or would anyone have a better approach to this issue. I'm not sure how I can add the appropriate P3P header information to a VF page.

 

Any help here would be appreciated.

 

Hi,

I am fairly new to salesforce. I was working with triggers and would like to know how I can access a child object two three levels deep in a trigger. e.g. the trigger is for Object A and it has child B which has child C , now I want to access object C's fields in the Object A trigger.

Thanx

Hello

 

Need two Apex Controllers created which I do not know how to do could someone please let me know if they are able to create them based on the required information below and how long and much it would cost to do would be great. We will pay.

 

1.  We have a form (custom object – Coaching Template) within this form on Salesforce I have a button ‘Print Template’ this exports the data in the PDF using VF. The next step is where I am getting stuck. I need to include the tasks attached to the custom object on the print off. I can get the task on but it only shows the first task and not the rest. Is this where a controller is required to get the multiple tasks?

 

2.  We have a form (custom object – Visit Scorecard) within this form I have a print button as well and would like to print the form off and include the tasks like question 1. Another thing we would like to also add to the form is all the visit scorecards and annual interim reviews that are related to the employee object from the current visit scorecard you are on. I have included a little graph of the objects and their relationships.

 

I hope this makes sense and you can understand what I am trying to achieve. If not let me know.

 

Hope someone can help :)

 

Regards
James

 

Object Relationship

 

 

 

 

  • October 11, 2010
  • Like
  • 0
In salesforce Production/Developer edition test coverage shows only 13%.But same code in trail edition test coverage shows 88% And salesforce Production/Developer edition system.assert shows error "variable doesnot exist But in Trail edition no errror Code Visualforce page DocumentEmailer Apex class DocumentEmailController public with sharing class DocumentEmailController { public ID documentId {get;set;} public String email {get;set;} public List documents { get { if (documents == null) { documents = new List(); documents.add(new SelectOption('01570000001NZDn','Cup of Coffee? - DOC')); documents.add(new SelectOption('01570000001NZDi','Workflow Cheatsheet - PDF')); } return documents; } set; } public PageReference sendDoc() { Document doc = [select id, name, body, contenttype, developername, type from Document where id = :documentId]; Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment(); attach.setContentType(doc.contentType); attach.setFileName(doc.developerName+'.'+doc.type); attach.setInline(false); attach.Body = doc.Body; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setUseSignature(false); mail.setToAddresses(new String[] { email }); mail.setSubject('Document Email Demo'); mail.setHtmlBody('Here is the email you requested: '+doc.name); mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); // Send the email Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Email with Document sent to '+email)); return null; } } Test code Test_DocumentEmailer @isTest private class Test_DocumentEmailer { static Document document; static { document = new Document(); document.Body = Blob.valueOf('Some Text'); document.ContentType = 'application/pdf'; document.DeveloperName = 'my_document'; document.IsPublic = true; document.Name = 'My Document'; document.FolderId = [select id from folder where name = 'My Test Docs'].id; insert document; } static testMethod void testDocumentEmailer() { PageReference pref = Page.DocumentEmailer; DocumentEmailController con = new DocumentEmailController(); Test.startTest(); System.assertEquals(2,con.documents.size()); // populate the field with values con.documentId = document.id; con.email = 'test@noemail.com'; // submit the request pref = con.sendDoc(); Test.stopTest(); } } In test code System.assertEquals(2,con.documents.size()); shows error Variable doesnot exist documents

Hi All,

          I have a small problem with my controller. I am trying to get values from a custom object  and trying to update the values. But it is not working fine. I have paste the visualforce code and the controller below:

 

 

<apex:page standardcontroller="Case" sidebar="false" showHeader="false" extensions="SubmitCaseController">
             
                           
       <apex:outputPanel styleClass="box1" style="border-style:none;border-widht:0px;background-color: #FFFFFF;margin-top:35px" >        
 
         <apex:outputPanel styleClass="box1" style="border:none">
    <apex:dataTable columns="2" id="firstbox1" value="{!List}" var="p" rendered="{!(List!=null)}">
        <apex:column styleClass="c1">
            <apex:outputtext value="Profile Name"/>
        </apex:column>
        <apex:column styleClass="c2">
            <apex:inputtext value="{!p.Name}" style="width:250px"/>
        </apex:column>
        <apex:column styleClass="c1">
            <apex:outputtext value="Operating System"/>
        </apex:column>
        <apex:column styleClass="c2">
            <apex:inputtext value="{!p.operating_system__c}" style="width:250px"/>
        </apex:column>
        <apex:column styleClass="c1">
            <apex:outputtext value="Application Development Language"/>
        </apex:column>
        <apex:column styleClass="c2">
            <apex:inputtext value="{!p.Application_Development_Language__c}" style="width:250px"/>
        </apex:column>
        <apex:column styleClass="c1">
            <apex:outputtext value="Database"/>
        </apex:column>
        <apex:column styleClass="c2">
            <apex:inputtext value="{!p.Database__c}" style="width:250px"/>
        </apex:column>
        <apex:column styleClass="c1">
            <apex:outputtext value="Web Server"/>
        </apex:column>
        <apex:column styleClass="c2">
            <apex:inputtext value="{!p.Web_Server__c}" style="width:250px"/>
        </apex:column>
        <apex:column styleClass="c1">
            <apex:outputtext value="Servlet Engine"/>
        </apex:column>
        <apex:column styleClass="c2">
            <apex:inputtext value="{!p.Servlet_Engine__c}" style="width:250px"/>
        </apex:column>
         <apex:column styleClass="bbox1">
                                                     <apex:column styleClass="bbox1">
              
<apex:commandButton value="Update" action="{!Save}" />
               </apex:column>
    </apex:dataTable>               
</apex:outputPanel>    
                     </apex:outputPanel>
        </apex:form>
   </apex:outputPanel>
</apex:page>

 

My controller is as follows:

 

public abstract class SubmitCaseController {

   
    public SubmitCaseController(ApexPages.StandardController controller) {
           }
    
   public List<Customer_Profile__c> cList{get;set;}
                 
   public PageReference Save(){
             update cList;
             return null;
   }
  
    
      public List<Customer_Profile__c> getList(){     
        cList = [select Id,Name,Application_Development_Language__c,Database__c,operating_system__c,Servlet_Engine__c,Web_Server__c from Customer_Profile__c where Account__r.Name =:accName];
              return cList;
    }        
    
     }

 

 

Can anyone please help me with this issue. Thanks in advance.

Background: I have a custom Object called Shift. It has lookup field to Contact. Each 'record' of the object Shift is just what you'd expect, it contains a Date and time that a Contact is scheduled to work.

 

Problem: I need to prevent users from scheduling the same contact for two shifts on the same date.

 

If there is a Shift where:  Contact = John Smith; Date = 9/15/2010, I don't want the user to be able to create another shift with those same values. I don't want to double book anybody.

 

I'm not sure of the simplest way to prevent this; or even a possible way. Thanks for any help / advice!

Hi ,

I am having an issue , there is a an opportunity trigger with event before insert and before update which will update the values of two field with corresponding two  values from  the owner record. For example if the owner of the opportunity  record is changed those two fields will also get updated with the corresponding values of  two fields from the owner record. This trigger works perfectly when the owner is changed directly from  opportunity record. but the problem is when the owner of the opportunity record getting changed indirectly by selecting options(Transfer closed opportunities ,Transfer open cases owned by the existing account owner ,Transfer closed cases) while changing owner of the master account record in that case  opportunity trigger is not firing at all, due to that fields opportunity records are not getting updated with the owner field values .Can any one help me.

  • September 20, 2010
  • Like
  • 0

Hello,

 

I am trying to create a  trigger for understanding Maps as my real life situation has similar Object relationships.

 

I want all the Opportunity Names to be Populated as a New Contact  on insert or update.

 

My Problem is I have been able to successfuly query the Opportunity Name and create a new Contact. I am not able to iterate thru the Opporunity Object Map or when there are multiple Opportunities only one contact gets created.

 

I am enclosing the code and I hope this can run on any instance as I am using standard objects.

 

Thanks in advance.

trigger accountContactFromOpp1 on Account (before insert, before update) {
	//trigger accountContactFromOpp on Account (before update, before insert) {
/*
	This is a MAP test the objective is to query all Opportunities for an account which 
	has Billing city as Null (just a test)	New Contact for each Opportunity Name
*/
	//passing on all Account Id into a set
	Set<ID> AcctId = new Set<ID>();
	
	//loop thru the trigger set and build a set of all the Accounts with no contacts.
	
	for(Account acct : Trigger.new){
		if (acct.BillingCity == NULL){
			AcctId.add(acct.Id);
		}
	
	}
	//for query thos Accouts Id and create a map connecting them 	
		Map<ID,Opportunity> myOppMap = new Map<ID,Opportunity>();
	
	for(Opportunity thisOpp : [Select Id, Name, AccountId From Opportunity where AccountId IN : AcctId]){
		myOppMap.put(thisOpp.AccountId,thisOpp);
	}
	//looping thru the Trigger again ok
	for(Account acct : Trigger.new){
		if(acct.BillingCity == NULL){
			acct.Description = myOppMap.get(acct.Id).Name;
						
				Contact cont = new Contact(LastName = myOppMap.get(acct.Id).Name,AccountId = acct.Id);
				insert cont;
				
		}
	
	}//end loop acct Trigger.new
}

 

 

Hi,

I am creating a PDF doc rendered from visual force page, now I want to

display dashboard or graphs (pie chart,etc.) in PDF doc. Is there any way to do this ?

 

I would really appreciate for reply.

 

 

Thanks.

I have a VF page that contains an actionpoller to refresh a section every 'n' seconds.  In order to let the user know that this is happening, I'm using an actionstatus with start/stop attributes to invoke javascript functions.

 

I've found that while this works fine in Chrome and Firefox, IE 7 and 8 throw errors.  I've managed to dwindle this down to the following page:

 

 

 

<apex:page tabstyle="Account" showheader="false" standardstylesheets="true">
   <script>
      function start()
      {
         alert("Starting");
      }
   
      function stop()
      {
         alert("Stopping");
      }
   </script>   

<!--    <h1>Poller Test</h1> -->

   <apex:form >
      <apex:actionStatus id="sref"
                onstart="start()" onstop="stop()"/> 
   
      <apex:actionPoller interval="10" rerender="status" status="sref"/>

      <apex:outputPanel id="status">
          Here is the panel
      </apex:outputPanel>
   </apex:form>
</apex:page>

 

When I access this page in IE, I get JavaScript errors that 

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
Timestamp: Tue, 3 Aug 2010 10:37:26 UTC
Message: 'window.document.getElementById(...)' is null or not an object
Line: 17
Char: 1
Code: 0
Message: 'window.document.getElementById(...)' is null or not an object
Line: 19
Char: 1
Code: 0

 

'window.document.getElementById(...)' is null or not an object'.  If I remove the comment around the line:

 

 

<!--    <h1>Poller Test</h1> -->

 

 

Then it works fine for IE.  

 

It appears that inserting some regular HTML in between the javascript and apex:form components fixes it, but I've no idea why.  

 

Any suggestions as to what is causing this (I've already drawn the obvious conclusion that its an IE bug!)

 

 

Hello

 

I am a newbie to triggers and was hoping that someone could help me with this ...Basically I am trying to update a field in my parent object whenever some updates/creates new child records. Below is what I have so far ( both parent and child are custom objects). To make it easier ...this would be like if I have an amount field on the account object and I need to copy the opty amount to this field on the account object. Basically the account amount field should be the sum of all the opty amount fields for the corresponding account ..

 

trigger License on License_Transfer__c (before update) {

List<DNB_Org__c> dnborgstoupdate = new List <DNB_Org__c>();
for(License_Transfer__c lct : System.Trigger.New) {
 if (lct.License_Type__c == 'UE'){
  DNB_Org__c dnborg = new DNB_Org__c (Id =lct.Holding_Org__c,Holding_Licenses_UE__c = lct.Licenses_to_Transfer__c);
  dnborgstoupdate.add(dnborg);
 }
}
update(dnborgstoupdate);
}

hi,

I am using apex code to submit approval process as soon as it validates all the fields in the object are filled. It is working perfectly with some records and throwing below exception for some other records.

 

System.DmlException: Process failed. First exception on row 0; first error: MANAGER_NOT_DEFINED, Manager undefined.: []

 

even though manager is defined in the record it was failing.Any idea !

  • July 26, 2010
  • Like
  • 0

Hello!

 

I am new to Salesforce, I am trying to enable and make a text field mandatory if picklist value is "Other". 

Saw few posts online, but nothing seemed to help, the solution lies in Triggers or Workflow, just not sure how to go about it. 

 

Thanks in advance.

okay so im getting this error:

 

Compile Error: line 19, column 7: Invalid foreign key relationship: Lead.createdDate

 

 

with this code:

 

it comes from the part where i compare each aspect of CreatedDate to my variables.

     

 

 

public with sharing class stuff {
Date   oldThreshold = Date.newInstance(2010, 1, 1); 
String newStatusForOldLeads = 'Archive-Omitted';

   
List<Lead> oldLeads = [select id, createdDate, status, isConverted
from Lead where status = 'open' OR status = 'working'];

List<Lead> leadsToUpdate = new List<Lead>();


{
if(oldLeads.size() > 0)
{
 
 for(Lead currentLead: oldLeads)
 {  
  integer compareyear = 2010;
integer comparemonth = 1;
integer compareday = 1;
  //Date x = currentLead.CreatedDate.Date;
  
  if (currentLead.CreatedDate.year < compareyear &&
     currentLead.CreatedDate.month < comparemonth &&
     currentlead.CreatedDate.day < compareday)
     {
    
     
     
      currentLead.status = newStatusForOldLeads;  
      leadsToUpdate.add(currentLead);
 


       
     }
  }
}

if(leadsToUpdate.size() > 0)
{
update(leadsToUpdate);
}
 


}
}

 

I don't get it ?

I'm trying to make a simple notification for non-SF users that is triggered by creation or updating of a case. The first problem I ran into was a null object error on the following code:

 

trigger newCaseToCustomerService on Case (after insert, after update) {
Case myCase = trigger.new[0];
Account myAccount = myCase.Account;
User myOwner = myCase.Owner;
String CRLF = '\r\n'
String msgbody;

if(myAccount.BillingCountry == 'Denmark'){
//code here
}
}

 when SF is inserting or updating the Case, why would the Account or Owner be null since they are set in the case properties? I noticed from the other messages asking help for the null object issues that a common approach was to use SOSQL query to access related objects but I don't quite get it why is that?

 

My second question is about the Messaging -class: Does the Apex Email Class allow setting the Priority -flag on outbound, single messages?

Hi all,

i am working on a custom object and i am not able to get name uniquely.can any one help me to get all names unique.

 

Thanks,

chiru.

 

Here is my page:

<apex:page controller="Todownload">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!Allattachments}" var="allatt">
                <apex:column value="{!allatt.DealName}"/>
                <apex:column value="{!allatt.Name}"/>
               <apex:column > <apex:outputLink value="/servlet/servlet.FileDownload?file={!allatt.Id}">{!allatt.Name}</apex:outputLink></apex:column>                
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

And the controller:

public with sharing class Todownload {
    List<Attachment> atlist;
    List<Deal__c> Dealfields;
    List<WrapperClass> wcList=new List<WrapperClass>();
     Set<String> dealidset=new Set<String>();
    public List<WrapperClass> getAllattachments() {
    Dealfields = [select  name, RecordTypeId, Address__c,City__c,State__c,ShortDescription__c,PPM_Funding_Date__c,Fundraising_Goal__c,DealType__c,id from deal__c where ShowInInvestorAdvisorPortals__c=true];
        
         if(Dealfields!=null && Dealfields.size()>0){            
             for(deal__c deal:Dealfields ){               
                 dealidset.add(deal.id);                 
             }
         }
        
         
         atlist=[Select Name,parentid,id from Attachment where ParentId in :dealidset];
        
         for(Attachment a :atlist ){
             WrapperClass w = new WrapperClass();
             w.Id = a.Id;
             w.Name=a.Name;
             for( deal__c d : Dealfields){
                 if(d.Id==a.parentid){
                     w.DealName=d.Name;
                 }
             }
             wcList.add(w);
         }
         
        return wcList;
    }
    public List<WrapperClass> getWrapperRec(){
       System.debug('asdf'+wcList.size());
        return wcList;
    }
    public class WrapperClass{
        public string Id{get;set;}
        public string Name{get;set;}
        public string DealName{get;set;}
    }
    
}

Hi everyone,

 

I am selecting lead record in one visualforce page by using checkbox and storing the records in list in apex class. When i am directing my page to another page which uses same extension as that of previous page,size of list becomes zero means it doesnot contain any records when i navigate to other page. So i am not able to fetch record from list.

 

My requirement is to select lead record on one vf page by clicking on checbox and then displaying them in next vf page so that i can perform further actions.

 

Can anyone help me to get out of this problem? 

Hi Guyz,

 

I am working on Performance Improvement. I need a favour, when I click on Particular button I want some fields to be re-rendered, I cant use the ActionFunction or CommandButton because that makes a call to Server/Controller. and I want to avoid this call.

 

Is there anyway I can re-rendered the salesforce component without making any call to Server/Controller.

 

Thanks in advance,

 

 

Anand Agrawal.

hi,

I have a small scenario hope anyone can help me in this issue.

 

My company has a public website and the guest users contact the company by entering the web2lead form.

 

once they are converted into leads their information is with the company.

 

Let us think "ABC" is a lead and now ABC wants to change his information like his email address.how can he change that directly.since he is not a salesforce user he cannot access the lead object he can just read the data.how can he modify the data.

I have a Unit Test class that I am using to test 12 triggers.  I've noticed at the bottom of the debug log that I have used 93 of the 100 SOQL queries I'm allowed to use for a test pass.  Is there a way to split out the testing so that I don't run into this limit as I continue to develop in this environment and need to unit test my new code?  If I split the tests into seperate classes will that change the way the limits are evaluated when I run "all tests"?  My concern is that I'm going to add code and try to deploy it and even though it's test covered I'll hit this query limit.  Thoughts?