• Tobias Hagge
  • NEWBIE
  • 90 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 31
    Questions
  • 34
    Replies
Hey, is there a quick solution to this? One way to do it would be leftstring + ':' + rightstring but it seems super messy.

Any ideas?
Hi. I've created an Email Template (Visualforce) and pass Visualforce Components in there. One of the components is an image of a dashboard component in the following format:
<apex:component access="global">

<apex:image value="https://instance.my.salesforce.com/servlet/servlet.ChartServer?[...]">
</apex:image>

</apex:component>
It's displayed perfectly in the Email Template HTML preview, but of course when sending the email, the image can't be referenced.

Any idea how to overcome this? Thank you!
 
Hello. I have two basic reports where I would like to combine the totals.

1. Total calls by agent (tasks(activities) on leads and accounts)
2. Total signups by agent (accounts)

I would like to show Total call/signup by agent, but it is overly complicated to combine these two reports. What's the best way to achieve this solution?

Thank you.
Hello. I've created a custom report with the following logic:

Leads (A)
with or without related records from Accounts (B)

To display account information of converted leads. The fields are all available from both leads and accounts, but the account field values are all blank. Any idea what went wrong?

Thanks
Hey, hope someone could help debugging this code. Every email we sent to customers is bcc'd to Salesforce, so they are being attached to the relevant account/contact. For one specific email, we would like to display the time the email has been sent to the customer. This works fine in any simple/manual test, but fails in production on a significant big amount of customer who receive the email (30%+), in which case the datestamp is just missing.
I'm not sure if we exceed any limits (no error message) and don't know how to debug, as the trigger works in theory. Thanks for the help, all if, else if conditions are mutual exclusive.
 
trigger Trigger_Task2Account on Task (after insert, after update) { //trigger name, on which object, when does it fire 
  Task[] tasks = Trigger.New;
  
  Map<String, Task> accountMap = new Map<String, Task>();
  
  for(Task task: tasks)
  {
    String accountId = task.AccountId; // maps object where triggers fire to object where result resides
    if (accountId != null)
      accountMap.put(task.WhatId, task);
  }
  List<Account> accounts = new List<Account>([Select Id, Doc_Chaser__c, Last_Call_Purpose__c, Last_Call_Outcome__c , Last_Call_Date__c, Latest_Opportunity__c, Required_Documents_Email__c, Last_Call_Result__c, Customer_Process__c FROM Account WHERE Id in :accountMap.keySet()]);
  
  for(Account account: accounts)
  {   
        Task task = accountMap.get(account.Id);
        if(task.Purpose__c != null || task.Call_Outcome__c != null) //conditions 
        {
            account.Last_Call_Purpose__c = task.Purpose__c;  //what: object.field__c, true, false, 'string', datetime.function
            account.Last_Call_Outcome__c = task.Call_Outcome__c;
            account.Last_Call_Date__c = task.CreatedDate;
        }
        
        else if(task.Subject == 'Email: Completing your iwoca application...')
        {
          account.Required_Documents_Email__c = datetime.NOW();
        }
        
        else if(task.Subject == 'Telesales Call')
        {
          if(task.CallDisposition == 'Sale - Application Review' && account.Customer_Process__c == '5 - Live in Dialler')
          {
            account.Last_Call_Result__c = task.CallDisposition; //CallDisposistion is API name for Call Result
            account.Last_Call_Date__c = task.CreatedDate;
            account.Customer_Process__c = '1 - Application Review';
            update account;
          }
          else
          {
          account.Last_Call_Result__c = task.CallDisposition; //CallDisposistion is API name for Call Result
          account.Last_Call_Date__c = task.CreatedDate;
          }
        }
    }
    update accounts;
}

 
Hello. I try to insert the following in a rich area text field. Standard html tags should be available for these, but can't get it to work.

Tried around a bunch with BR() function and <br> tag.
 
"text" & ??? & "text"

should convert to ->

"text"
"text"

Any ideas?
trigger Trigger_Opportunity2Contact on Opportunity (after update) {
	Opportunity[] opportunities = Trigger.New;
	
	// Fetch fields we'll be using AND filter out Opportunities != 1
	List<Opportunity> oppsWithContact = new List<Opportunity>([Select Underwriter_Notes__c, Account.Contact__c, Approval_Decision__c, Decision_Date__c, Reason_for_Deferring__c, Reason_for_Rejecting__c From Opportunity where Id in: opportunities and Opportunity_Number__c = 1]);
		
	Map<String, Opportunity> opportunityMap = new Map<String, Opportunity>();
	for(Opportunity opportunity: oppsWithContact)
	{
		opportunityMap.put(opportunity.Account.Contact__c, opportunity);
	}
	List<Contact> contacts = new List<Contact>([SELECT Id, Additional_Info_for_Easycallnow__c, Approval_Decision__c, Decision_Date__c, Reason_for_Deferring__c, Reason_for_Rejecting__c FROM Contact WHERE Id in :opportunityMap.keySet()]);

	for(Contact contact: contacts)
	{
		Opportunity opp = opportunityMap.get(contact.Id);
		if(opp != null){
			contact.Approval_Decision__c = opp.Approval_Decision__c;
			contact.Decision_Date__c = opp.Decision_Date__c;
			contact.Reason_for_Deferring__c = opp.Reason_for_Deferring__c;
			contact.Reason_for_Rejecting__c = opp.Reason_for_Rejecting__c;
			contact.Additional_Info_for_Easycallnow__c = opp.Underwriter_Notes__c;
		}
	}
	update contacts;
}

Having a trigger that simply triggers field updates from Opportunity to Contact. Works fine on a simple manual update. However we sync/update all Opportunities in the night, so it should have triggered all Opportunity values to the Contact, but didn't trigger at all. The Opportunities are updated in 200 batches.
Afterwards bulk-changed 1000 Opportunities on a arbitrary field and it triggered and updated part of the fields, but then suddenly seemed to stop. E.g. updated all Approval_Decision__c, but no Decision_Date__c. Running the same bulk change again then updated the Decision_Date__c, which lets me think there might  be a limit on how many values you can change in one job?
Priority has to update all through the API.

Thanks!
I would like to do a trigger on Opportunities to rollup values into the Contact object. We don't use ContactRoles. There is a lookup fields to the relevant Contact on the Account, but the following gives a null ID.
Map<String, Opportunity> opportunityMap = new Map<String, Opportunity>();
		for(Opportunity opportunity: opportunities)
		{
			String id = opportunity.Account.Contact__c;
			System.debug ('*****' + id);
			if(id != null)
				opportunityMap.put(opportunity.Account.Contact__c, opportunity);
Any ideas?
Hey, the following trigger gives me a dml exception error when uploading to production.
trigger Trigger_Account2Contact on Account (after update) {
	Account[] accounts = Trigger.New;
	Account[] oldAccounts = Trigger.Old;
	List<Account> changedAccounts = new List<Account>();
	
	for(integer i = 0; i < accounts.size(); i++)
		if(accounts[i].Customer_Process__c != oldAccounts[i].Customer_Process__c)
			changedAccounts.add(accounts[i]);
			
/* 
	if ischanged CPS = Live in Dialler: push Contact to dialler
	if ischanged CPS != Live in Dialler: Discard from dialler
*/

	Map<String, Contact> contactMap = new Map<String, Contact>();
	for(Contact c: [SELECT Id, AccountId FROM Contact WHERE Is_Applicant__c = True])
		contactMap.put(c.AccountId, c);

	for(Account account: changedAccounts)
	{
		Contact contact = contactMap.get(account.Id);
		if(contact != null)
		{		
			if(account.Customer_Process__c == '5 - Live in Dialler')
			{
				contact.Easycallnow_Table__c = 'UK: Reassessing Applications';
			}
			else
			{
				contact.Easycallnow_Table__c = null;
			}
		}
	}
	update contactMap.values();
}
Theoretical it should create a list of Accounts where the Customer_Process__c has changed and map all Contacts where Is_Applicant__c = True to it and then update a field on the Contact (Easycallnow_Table__c).

Where does it violate the governor limit? It gives the error message on every save attemp, even if Customer_Process__c is not changed at all.

Thanks for the help.
Hi.

I smartly refreshed the sandbox without having released a couple of trigger and testclasses. Is there any way to retrieve them from the Developer Console, or any other way for that matters.

Pretty embarrassing :'(
Hello. I hope you can help me debugging the following code. The scenario is that 200 leads are being updated in a batch with tasks being created on them. The task has a name field (Agent_Name__c) that I want to compare against a name field (Name) on a custom object (Acquirer__c) and then insert the custom object ID in a lead custom lookup field (Sales_Agent__c). Unfortunately the governor limit is being hit and I can't figure out which part does too many queries.
 
trigger Trigger_Task2Lead on Task (after insert) {
  Task[] tasks = Trigger.New;
  
	  Map<String, Acquirer__c> acquirers = new Map<String, Acquirer__c>();
	  for(Acquirer__c a: [SELECT Name, Id from Acquirer__c])
	  {
	  	acquirers.put(a.Name, a);
	  }
	  
	  Map<String, Task> leadMap = new Map<String, Task>();
	  for(Task task: tasks)
	  {
	  	String id = task.WhoId;
	  	if(id != null && id.startsWith('00Q')==TRUE)  // All Lead IDs begin with 00Q
	  		leadMap.put(task.WhoId, task);
	  
	  List<Lead> leads = new List<Lead>([Select Id, Sales_Agent__c from Lead where Id in :leadMap.keySet()]);
	  	  
	  for(Lead lead: leads)
	  {
		String agentname = leadMap.get(lead.Id).Agent_Name__c;
		Acquirer__c acquirer = acquirers.get(agentname);
		try {
	    	lead.Sales_Agent__c = acquirer.Id;
		} catch (NullPointerException e){
	    	System.debug('NPE***');
	    }
	  }
	  update leads;
	  	}
}

Thanks for the help!
I have tried

// comment
/* comment */
<!-- comment -->

Any other ideas what the syntax might be? Or is it not possible at all?
Hey, I want to call a standard button from a Visualforce page in the same window of the Service Cloud Console, but it opens the link a new browser window. The standard button/link on the page works fine, just the calling from java does not work properly.
 
<apex:pageBlockButtons location="top" id="pbbID9">
            <apex:commandlink value="Email_Default_Notice_Ltd" action="{!URLFOR($Action.Account.View,Account.Id)}" onclick="openConga()" rerender="pbbID9" target="_blank"/>
</apex:pageBlockButtons>

    <script Language="JavaScript">
        function openConga() { window.open('{!URLFOR($Action.Account.Email_Default_Notice_Ltd,Account.Id)}', '','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes, toolbar=no,location=no,status=yes'); }  
    </script>

Any idea how to modify? I tried all target="_blank" self, etc.
Hello.

I would like to render all fields in a VF page and I think the repeat function might be the easiest.
<apex:repeat value="{!$ObjectType.Account.Fields.}" var="f">
            <apex:outputfield value="{!Account[f]}"> 
            </apex:outputfield>
        </apex:repeat>
I am missing the last bit though. Is that achievable, or would it need a class that gets all fields and then the repeat function referencing it?

Thanks!
Hello.

We have a built a custom save class and want to only compare values of a certain set of fields, in our case all fields that are updateable and on the Visualforce page. Is there a way to query this subset of fields? It tries to get all fields that exist on the object, rather than only the ones from the controller.
It's very unfortunate that rebuild account pages look so different from native/standard page layouts (detail pages). Is there any way to access the relevant style, or is there existing code that makes the changes?
/* */ is supposed to work, but doens't exclude anything from the page. How do you write comments on a VF page?

Cheers
I would like to have the following functionality rebuild on a VF page. Baiscally the standard functionality

Account Owner FirstName LastName [change]

Best way to get formatting right is putting it in a pageblocksectionitem, otherwise you would need CSS to bring the change button to the right position
 
<apex:pageblocksectionitem>
				<apex:outputlabel> Account Owner </apex:outputlabel>
				<apex:outputfield value="{!Account.Ownerid}"/>
					<a href="/{!id}/a?retURL=/{!id}">[Change]</a>
</apex:pageblocksectionitem>
Unfortunately only 2 items are accepted in the section and the outputfield only displays FirstName LastName. Any good idea how to achieve this?
 
Hello.

Rendering a report in a VF page is easy, but is there a way to only render the output columns/rows? Basically without all the report informations, filters, etc.?

The section I am referring to is "div.reportOutput". Hopefully that helps.
Is there a way to modify the following code so that I could display the native HelpText for all fields?
 
<apex:page StandardController="Opportunity" wizard="true" showHeader="false" sidebar="false">   

<apex:stylesheet value="{!$Resource.customCSS}"/>

<apex:form id="formId"> 

<apex:pageblock id="pbId" mode="inlineEdit" title="Opportunity Details">  

        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>

    <apex:pageblocksection columns="2" id="pbsIs">  
        <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Opp_Details_django}" var="f">  
            <apex:outputfield value="{!Opportunity[f]}">  
            </apex:outputfield>
        </apex:repeat>  
    </apex:pageblocksection>
</apex:pageblock>   

</apex:form> 

</apex:page>
Problems to solve: ShowHeader must stay false (or to be hidden by CSS) and native HelpText only works for pageblocksectionitem.
Hello.

As far as my understanding goes is the only native way to include the help text in a Visualforce page by setting showHeader="true". I realloy don't want to show the Header though, is it possible to exclude this with CSS? I read in a different thread that the following would work, but it doesn't for me.
.bPageHeader{
    display: none;
}
Any ideas?
Hey, is there a quick solution to this? One way to do it would be leftstring + ':' + rightstring but it seems super messy.

Any ideas?
Hi. I've created an Email Template (Visualforce) and pass Visualforce Components in there. One of the components is an image of a dashboard component in the following format:
<apex:component access="global">

<apex:image value="https://instance.my.salesforce.com/servlet/servlet.ChartServer?[...]">
</apex:image>

</apex:component>
It's displayed perfectly in the Email Template HTML preview, but of course when sending the email, the image can't be referenced.

Any idea how to overcome this? Thank you!
 
Hello. I've created a custom report with the following logic:

Leads (A)
with or without related records from Accounts (B)

To display account information of converted leads. The fields are all available from both leads and accounts, but the account field values are all blank. Any idea what went wrong?

Thanks
Hey, hope someone could help debugging this code. Every email we sent to customers is bcc'd to Salesforce, so they are being attached to the relevant account/contact. For one specific email, we would like to display the time the email has been sent to the customer. This works fine in any simple/manual test, but fails in production on a significant big amount of customer who receive the email (30%+), in which case the datestamp is just missing.
I'm not sure if we exceed any limits (no error message) and don't know how to debug, as the trigger works in theory. Thanks for the help, all if, else if conditions are mutual exclusive.
 
trigger Trigger_Task2Account on Task (after insert, after update) { //trigger name, on which object, when does it fire 
  Task[] tasks = Trigger.New;
  
  Map<String, Task> accountMap = new Map<String, Task>();
  
  for(Task task: tasks)
  {
    String accountId = task.AccountId; // maps object where triggers fire to object where result resides
    if (accountId != null)
      accountMap.put(task.WhatId, task);
  }
  List<Account> accounts = new List<Account>([Select Id, Doc_Chaser__c, Last_Call_Purpose__c, Last_Call_Outcome__c , Last_Call_Date__c, Latest_Opportunity__c, Required_Documents_Email__c, Last_Call_Result__c, Customer_Process__c FROM Account WHERE Id in :accountMap.keySet()]);
  
  for(Account account: accounts)
  {   
        Task task = accountMap.get(account.Id);
        if(task.Purpose__c != null || task.Call_Outcome__c != null) //conditions 
        {
            account.Last_Call_Purpose__c = task.Purpose__c;  //what: object.field__c, true, false, 'string', datetime.function
            account.Last_Call_Outcome__c = task.Call_Outcome__c;
            account.Last_Call_Date__c = task.CreatedDate;
        }
        
        else if(task.Subject == 'Email: Completing your iwoca application...')
        {
          account.Required_Documents_Email__c = datetime.NOW();
        }
        
        else if(task.Subject == 'Telesales Call')
        {
          if(task.CallDisposition == 'Sale - Application Review' && account.Customer_Process__c == '5 - Live in Dialler')
          {
            account.Last_Call_Result__c = task.CallDisposition; //CallDisposistion is API name for Call Result
            account.Last_Call_Date__c = task.CreatedDate;
            account.Customer_Process__c = '1 - Application Review';
            update account;
          }
          else
          {
          account.Last_Call_Result__c = task.CallDisposition; //CallDisposistion is API name for Call Result
          account.Last_Call_Date__c = task.CreatedDate;
          }
        }
    }
    update accounts;
}

 
Hello. I try to insert the following in a rich area text field. Standard html tags should be available for these, but can't get it to work.

Tried around a bunch with BR() function and <br> tag.
 
"text" & ??? & "text"

should convert to ->

"text"
"text"

Any ideas?
trigger Trigger_Opportunity2Contact on Opportunity (after update) {
	Opportunity[] opportunities = Trigger.New;
	
	// Fetch fields we'll be using AND filter out Opportunities != 1
	List<Opportunity> oppsWithContact = new List<Opportunity>([Select Underwriter_Notes__c, Account.Contact__c, Approval_Decision__c, Decision_Date__c, Reason_for_Deferring__c, Reason_for_Rejecting__c From Opportunity where Id in: opportunities and Opportunity_Number__c = 1]);
		
	Map<String, Opportunity> opportunityMap = new Map<String, Opportunity>();
	for(Opportunity opportunity: oppsWithContact)
	{
		opportunityMap.put(opportunity.Account.Contact__c, opportunity);
	}
	List<Contact> contacts = new List<Contact>([SELECT Id, Additional_Info_for_Easycallnow__c, Approval_Decision__c, Decision_Date__c, Reason_for_Deferring__c, Reason_for_Rejecting__c FROM Contact WHERE Id in :opportunityMap.keySet()]);

	for(Contact contact: contacts)
	{
		Opportunity opp = opportunityMap.get(contact.Id);
		if(opp != null){
			contact.Approval_Decision__c = opp.Approval_Decision__c;
			contact.Decision_Date__c = opp.Decision_Date__c;
			contact.Reason_for_Deferring__c = opp.Reason_for_Deferring__c;
			contact.Reason_for_Rejecting__c = opp.Reason_for_Rejecting__c;
			contact.Additional_Info_for_Easycallnow__c = opp.Underwriter_Notes__c;
		}
	}
	update contacts;
}

Having a trigger that simply triggers field updates from Opportunity to Contact. Works fine on a simple manual update. However we sync/update all Opportunities in the night, so it should have triggered all Opportunity values to the Contact, but didn't trigger at all. The Opportunities are updated in 200 batches.
Afterwards bulk-changed 1000 Opportunities on a arbitrary field and it triggered and updated part of the fields, but then suddenly seemed to stop. E.g. updated all Approval_Decision__c, but no Decision_Date__c. Running the same bulk change again then updated the Decision_Date__c, which lets me think there might  be a limit on how many values you can change in one job?
Priority has to update all through the API.

Thanks!
Hello. I hope you can help me debugging the following code. The scenario is that 200 leads are being updated in a batch with tasks being created on them. The task has a name field (Agent_Name__c) that I want to compare against a name field (Name) on a custom object (Acquirer__c) and then insert the custom object ID in a lead custom lookup field (Sales_Agent__c). Unfortunately the governor limit is being hit and I can't figure out which part does too many queries.
 
trigger Trigger_Task2Lead on Task (after insert) {
  Task[] tasks = Trigger.New;
  
	  Map<String, Acquirer__c> acquirers = new Map<String, Acquirer__c>();
	  for(Acquirer__c a: [SELECT Name, Id from Acquirer__c])
	  {
	  	acquirers.put(a.Name, a);
	  }
	  
	  Map<String, Task> leadMap = new Map<String, Task>();
	  for(Task task: tasks)
	  {
	  	String id = task.WhoId;
	  	if(id != null && id.startsWith('00Q')==TRUE)  // All Lead IDs begin with 00Q
	  		leadMap.put(task.WhoId, task);
	  
	  List<Lead> leads = new List<Lead>([Select Id, Sales_Agent__c from Lead where Id in :leadMap.keySet()]);
	  	  
	  for(Lead lead: leads)
	  {
		String agentname = leadMap.get(lead.Id).Agent_Name__c;
		Acquirer__c acquirer = acquirers.get(agentname);
		try {
	    	lead.Sales_Agent__c = acquirer.Id;
		} catch (NullPointerException e){
	    	System.debug('NPE***');
	    }
	  }
	  update leads;
	  	}
}

Thanks for the help!
I have tried

// comment
/* comment */
<!-- comment -->

Any other ideas what the syntax might be? Or is it not possible at all?
Hey, I want to call a standard button from a Visualforce page in the same window of the Service Cloud Console, but it opens the link a new browser window. The standard button/link on the page works fine, just the calling from java does not work properly.
 
<apex:pageBlockButtons location="top" id="pbbID9">
            <apex:commandlink value="Email_Default_Notice_Ltd" action="{!URLFOR($Action.Account.View,Account.Id)}" onclick="openConga()" rerender="pbbID9" target="_blank"/>
</apex:pageBlockButtons>

    <script Language="JavaScript">
        function openConga() { window.open('{!URLFOR($Action.Account.Email_Default_Notice_Ltd,Account.Id)}', '','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes, toolbar=no,location=no,status=yes'); }  
    </script>

Any idea how to modify? I tried all target="_blank" self, etc.
Hello.

I would like to render all fields in a VF page and I think the repeat function might be the easiest.
<apex:repeat value="{!$ObjectType.Account.Fields.}" var="f">
            <apex:outputfield value="{!Account[f]}"> 
            </apex:outputfield>
        </apex:repeat>
I am missing the last bit though. Is that achievable, or would it need a class that gets all fields and then the repeat function referencing it?

Thanks!
I would like to have the following functionality rebuild on a VF page. Baiscally the standard functionality

Account Owner FirstName LastName [change]

Best way to get formatting right is putting it in a pageblocksectionitem, otherwise you would need CSS to bring the change button to the right position
 
<apex:pageblocksectionitem>
				<apex:outputlabel> Account Owner </apex:outputlabel>
				<apex:outputfield value="{!Account.Ownerid}"/>
					<a href="/{!id}/a?retURL=/{!id}">[Change]</a>
</apex:pageblocksectionitem>
Unfortunately only 2 items are accepted in the section and the outputfield only displays FirstName LastName. Any good idea how to achieve this?
 
Is there a way to modify the following code so that I could display the native HelpText for all fields?
 
<apex:page StandardController="Opportunity" wizard="true" showHeader="false" sidebar="false">   

<apex:stylesheet value="{!$Resource.customCSS}"/>

<apex:form id="formId"> 

<apex:pageblock id="pbId" mode="inlineEdit" title="Opportunity Details">  

        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>

    <apex:pageblocksection columns="2" id="pbsIs">  
        <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Opp_Details_django}" var="f">  
            <apex:outputfield value="{!Opportunity[f]}">  
            </apex:outputfield>
        </apex:repeat>  
    </apex:pageblocksection>
</apex:pageblock>   

</apex:form> 

</apex:page>
Problems to solve: ShowHeader must stay false (or to be hidden by CSS) and native HelpText only works for pageblocksectionitem.
Hello.

As far as my understanding goes is the only native way to include the help text in a Visualforce page by setting showHeader="true". I realloy don't want to show the Header though, is it possible to exclude this with CSS? I read in a different thread that the following would work, but it doesn't for me.
.bPageHeader{
    display: none;
}
Any ideas?
Hello.

Even when having different pageblocks and the save button only appears in one block it automatically saves all pageblock values.
<apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
Is it possible to modify this code, so it only saves the relevant pageblock in which the button is?
Hello. Is it possible (and how) to display (render) a VF page on another VF page?

Example:
<apex:page>   

<apex:pageblock>
</apex:pageblock>


Render Visualforce here


<apex:pageblock>
</apex:pageblock>

</apex:page>