• Janno Rip
  • NEWBIE
  • 70 Points
  • Member since 2018
  • CRM Manager

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 17
    Replies

Hello developers,

we have a lot of process builders in our org that run when an opportunity record gets created/edited. They have very different criterias on when to run and when not to. In order to do some bugfixing and improving the performance I would like to know which of these process actually get triggered when creating/saving an opportunity.

Is there a way to see which of those actually run when I create/save an opportunity? Some kind of an overview which flows have run?

I only found the overview for 'pending' flows but thats not what I need. 

Thanks!

I have implemented the following visualforce page on the lead layout:
User-added image
Here is the code:
<apex:page standardController="Lead" extensions="JTo_LeadeventOnLead" tabStyle="Lead" showHeader="false" sidebar="false" >
    <style>
      
        .hmk_top5table{
         
            color:black;
            width:99%;

            font-family:Arial, Helvetica, sans-serif;
            font-size:12px;
            padding:5px;
    
            background:white; 
            margin:5px;
            border:rgb(50,205,50) 1px solid;
        
            -moz-border-radius:5px;
            -webkit-border-radius:5px;
            border-radius:5px; 
        }
         
    </style>
    <apex:form >
    <apex:pagemessages />
    <apex:outputPanel id="hmk_panel_top5table" rendered="{!the_le_list!=null && the_le_list.size>0 && (the_lead.Leadevents_in_Bearbeitung_Counter__c > 0 || the_lead.Nicht_zugewiesene_Leadevents_Counter__c > 0) }">
    
        <table class="hmk_top5table"> 
            <tr>
                <th style="text-align:center;padding:5px;">Aktion</th>
                <th style="text-align:center;padding:5px;">Leadevent</th>
                <th style="text-align:center;padding:5px;">Phase</th>
                <th style="text-align:center;padding:5px;">Datum</th>
                <th style="text-align:center;padding:5px;">Fälligkeitsdatum</th>
                <th style="text-align:center;padding:5px;">Ungeöffnet</th>
      
            </tr> 
 
            <apex:variable var="ct" value="{!1}"/>
            <apex:repeat value="{!the_le_list}" var="sega" >
                <tr style="display: {!IF(sega.isClosed__c = true,'none','table-row')};"   > 
                    
                    <td style="text-align:center">
                     

                       <apex:commandButton rendered="{!sega.Phase__c = 'Offen'}" disabled="{!sega.Leadevents_in_Bearbeitung_Counter_II__c > 0 && sega.Leadevents_nicht_zugewiesen_Counter__c > 0}" styleClass="btn" style="right:10px;position:relative;width:150px;" action="{!accept}" id="accept" value="Akzeptieren"/>
                       <apex:commandButton rendered="{!sega.Phase__c = 'Offen'}" styleClass="btn" style="width:150px;" action="{!decline}" id="decline" value="Ablehnen"/>
                       <apex:commandButton rendered="{!sega.Phase__c="in Bearbeitung" && sega.Leadevents_in_Bearbeitung_Counter_II__c > 0 && sega.Leadevents_nicht_zugewiesen_Counter__c > 0}" styleClass="btn" style="width:150px;" action="{!close}" id="close" value="Abschließen"/>

                   </td>


                    <td style="text-align:center">
                        <apex:outputLink style="color:{!IF(sega.Phase__c = 'in Bearbeitung','green','')}" target="_blank" value="{!URLFOR($Action.Leadevents__c.View, sega.Id, null)}">
                            <apex:outputtext value="{!sega.name}"/>
                        </apex:outputLink>          
                    </td>
                        
                     
                    <td style="text-align:center;color:{!IF(sega.Phase__c = 'in Bearbeitung','green','')}">
                        <apex:outputField value="{!sega.Phase__c}" /> 
                    </td>
                    
                   <td style="text-align:center">
                        <apex:outputText value="{0,date,dd.MM.yyyy}" >
                            <apex:param value="{!sega.Datum_des_Leadevents__c}"/> 
                        </apex:outputText>
                        
                    </td>
                                    
                    <td style="text-align:center;color:{!IF(sega.F_lligkeitsdatum__c < TODAY(),'red','')}">
                        <apex:outputText value="{0,date,dd.MM.yyyy}" >
                            <apex:param value="{!sega.F_lligkeitsdatum__c}"/> 
                        </apex:outputText>
                        
                    </td>
          
                    <td style="text-align:center">
                    
                    <apex:inputCheckBox value="{!sega.Unge_ffnet_JR__c}"/>
                    
                    </td>
                      
                </tr>
                <apex:variable var="ct" value="{!(ct+1)}"/>
            </apex:repeat>
        </table>        
        
    </apex:outputPanel>
</apex:form>
</apex:page>
Here is my code:
public with sharing class JTo_LeadeventOnLead {

    public Lead the_lead {get; private set;} 
    
    public Leadevents__c the_leadevent {get; private set;}
    
    public string the_leadid {get; private set;}
     
    public List<Leadevents__c> the_le_list {get; private set;}
    
    public JTo_LeadeventOnLead(ApexPages.StandardController standardController) {
        
        the_leadid = standardController.getId(); 
        
        the_lead = [
                    SELECT id, Name,Nicht_zugewiesene_Leadevents_Counter__c , Leadevents_in_Bearbeitung_Counter__c  
                    FROM Lead
                    WHERE id = : the_leadid
                    LIMIT 1
                  ];
   
        if(the_lead != null){
        
                the_le_list = [     
                                        SELECT Id, Name,F_lligkeitsdatum__c,Phase__c,Datum_des_Leadevents__c,Unge_ffnet_JR__c,isClosed__c,Leadevents_in_Bearbeitung_Counter_II__c,Leadevents_nicht_zugewiesen_Counter__c
                                        FROM Leadevents__c 
                                        WHERE Lead__c = : the_leadid
                                        Order by F_lligkeitsdatum__c DESC
                                        LIMIT 5
                                  ];
                                  
        the_leadevent = [ 
        
                                        SELECT Id, Name,F_lligkeitsdatum__c,Phase__c,Datum_des_Leadevents__c,Unge_ffnet_JR__c,isClosed__c,Leadevents_in_Bearbeitung_Counter_II__c,Leadevents_nicht_zugewiesen_Counter__c
                                        FROM Leadevents__c 
                                        WHERE Lead__c = : the_leadid
                                        LIMIT 1
                                    ];    
                                                                 

}
}


public PageReference accept() {

     
    for (Leadevents__c le : the_le_list) {
        le.Phase__c = 'in Bearbeitung';
    }
    
    update the_le_list;

    return null;
        
  }
}

What happens?
If I hit my custom commandbutton "accept" every entry in the list is getting updated and the visualforce page refreshes.
User-added image
What should happen?
Only the record where i hit the "Accept" - button should be updated and not only should the vf page refresh but the entire lead since I want the related lists - that include my custom object - to be up to date.
User-added image

Dear Developers,

I have a custom object called Leadevents__c who is connected to Leads. There I have built several custom onclick javascript buttons. For example one button called "Accept" that - besides other stuff - changes a field called "Stage__c" on that custom object.

Now I don't want my users to work any longer from that object itself but to work from the standard lead object. I have built an APEX Class and a Visualforce Page to display the relevant information:

User-added image

What I am trying to achieve is that my commandButtons on the visualforce behave the same way my custom javascript buttons do on the leadevents__c object.

So when I am on a Lead, that has a Leadevents__c record displayed in that visualforce page and I hit "Accept" the Stage__c of that very Leadevents__c record should change.

While I was able to display the buttons themselve I have little experience in APEX. So there is no code behind these buttons! It's just for showing what I want.

Here is my APEX Class so far:

public with sharing class JTo_LeadeventOnLead {

    public Lead the_lead {get; private set;} 
    
    public string the_leadid {get; private set;}
    
    public List<Leadevents__c> the_le_list {get; private set;}
    

    public JTo_LeadeventOnLead(ApexPages.StandardController sc) {
        
        the_leadid = sc.getId(); 
        
        the_lead = [
                    SELECT id, Name, State, City, PostalCode, WirtschaftszweigWZ08__c,PLZ_erste_zwei_Ziffern__c 
                    FROM Lead
                    WHERE id = : the_leadid
                    LIMIT 1
                  ];
        

        
        if(the_lead != null){
            
           
            
                the_le_list = [     
                                        SELECT Id, Name,F_lligkeitsdatum__c,Phase__c,Datum_des_Leadevents__c,Unge_ffnet_JR__c,isClosed__c   
                                        FROM Leadevents__c 
                                        WHERE Lead__c = : the_leadid
                                        Order by F_lligkeitsdatum__c DESC
                                        LIMIT 5
                                  ];
       
    
    
}
}
}
Here my VF Page:
 
<apex:page standardController="Lead" extensions="JTo_LeadeventOnLead" tabStyle="Lead" showHeader="false" sidebar="false" >
    <style>
    
        
        .hmk_top5table{
         
            color:black;
            width:99%;

            font-family:Arial, Helvetica, sans-serif;
            font-size:12px;
            padding:5px;
    
            background:white; 
            margin:5px;
            border:rgb(50,205,50) 1px solid;
        
            -moz-border-radius:5px;
            -webkit-border-radius:5px;
            border-radius:5px; 
        }
         
    </style>
    
    <apex:pagemessages />
    <apex:outputPanel id="hmk_panel_top5table" rendered="{!the_le_list!=null && the_le_list.size>0}">
    
        <table class="hmk_top5table"> 
            <tr>
                <th style="text-align:center;padding:5px;">Aktion</th>
                <th style="text-align:center;padding:5px;">Leadevent</th>
                <th style="text-align:center;padding:5px;">Phase</th>
                <th style="text-align:center;padding:5px;">Datum</th>
                <th style="text-align:center;padding:5px;">Fälligkeitsdatum</th>
                <th style="text-align:center;padding:5px;">Ungeöffnet</th>

                
     
            </tr> 
            
           
            
            <apex:variable var="ct" value="{!1}"/>
            <apex:repeat value="{!the_le_list}" var="sega" >
                <tr style="display: {!IF(sega.isClosed__c = true,'none','table-row')};"   > 
                    
                    
                    <td style="text-align:center">
                     <apex:form >
                       <apex:commandButton rendered="{!sega.Phase__c = 'Offen'}" styleClass="btn" style="right:10px;position:relative;width:150px;" action="{!save}" id="accept" value="Akzeptieren"/>
                       <apex:commandButton rendered="{!sega.Phase__c = 'Offen'}" styleClass="btn" style="width:150px;" action="{!cancel}" id="decline" value="Ablehnen"/>
                     </apex:form>
                   </td>
                   
                 

                    <td style="text-align:center">
                        <apex:outputLink style="color:{!IF(sega.Phase__c = 'in Bearbeitung','green','')}" target="_blank" value="{!URLFOR($Action.Leadevents__c.View, sega.Id, null)}">
                            <apex:outputtext value="{!sega.name}"/>
                        </apex:outputLink>          
                    </td>
                        
                     
                    <td style="text-align:center">
                        <apex:outputField value="{!sega.Phase__c}" /> 
                    </td>
                    
                   <td style="text-align:center">
                        <apex:outputText value="{0,date,dd.MM.yyyy}" >
                            <apex:param value="{!sega.Datum_des_Leadevents__c}"/> 
                        </apex:outputText>
                        
                    </td>
                                    
                    <td style="text-align:center;color:{!IF(sega.F_lligkeitsdatum__c < TODAY(),'red','')}">
                        <apex:outputText value="{0,date,dd.MM.yyyy}" >
                            <apex:param value="{!sega.F_lligkeitsdatum__c}"/> 
                        </apex:outputText>
                        
                    </td>
                    
                    
                    
                    <td style="text-align:center">
                    <apex:form >
                    <apex:inputCheckBox value="{!sega.Unge_ffnet_JR__c}"/>
                    </apex:form>
                    </td>
                                        
                    
                </tr>
                <apex:variable var="ct" value="{!(ct+1)}"/>
            </apex:repeat>
        </table>        
        
    </apex:outputPanel>

</apex:page>

 
Hello Developers,

I have a custom object (Leadevents__c), that is linked via lookup to accounts. The following visualforce page code shows me a specific related list (open tasks) from that account on my custom object
 
<apex:page standardcontroller="Leadevents__c"> 
<base target="_top"/> 

<apex:relatedList id="OpenTask_acc" pageSize="3" subject="{!Leadevents__c.Account__c}" list="OpenActivities" />

</apex:page>
Is there any chance to display the list only if there are actually records in the account related list? If there are no open tasks on the account, the related list should not be display on my custom object.

Thanks!
 

Hello Developers,

I have a question regarding the possibilty of having a visualforce page that shows different content depending on the User Profile. The varying content is nurtured by different apex classes.

Right now my solution looks like this: 2 Apex Classes and 2 VF Pages that are both on the layout:

Apex Class A delivers data for VF Page 1
Apex Class B delivers data for VF Page 2

User-added image
What I want to achieve is the following example:

If I am an Administrator I want to display VF Page 1 with the data delivered from apex class A

If I am a Sales Agent I want to display VF Page 2 with the data delivered from apex class B
User-added image
Would it be 1 Apex Class with 1 VF Page where? Or would it be 2 Apex Class and 1 VF Page? 

I am already able to show different VF Page dependent on the profile, but I am struggling with the classes because they also need to change since its different data that should be displayed.

Maybe some of you have an idea how to tackle this

Thanks in Advance

Jan

Hello Developers,

I have the following trigger which pulls data (Leadevent_Kategorie__c) from the lead / contact and writes it after creation/insert on the task (tk.Vertriebsaktion__c).
trigger UpdateLeadeventKategorieTask on Task (before insert) {
    Set<Id> leadId = new Set<Id>();
    Set<Id> contactid = new Set<Id>();
    
    for(Task t : Trigger.new){
        if(t.WhoId != null){
              String s1 = t.WhoId;
               if(s1.left(3) == '00Q'){
                        leadId.add(t.whoId);
               }
               else if(s1.left(3) == '003'){
                       contactId.add(t.whoId);
               }
         }
    }

    Map<Id,Lead> leadMap = new Map<Id,Lead>([Select Id, Leadevent_Kategorie__c From Lead Where Id In : leadId]);
    Map<Id,Contact> contactMap = new Map<Id,Contact>([Select Id, Leadevent_Kategorie__c From Contact Where Id In : contactId]);
    
    for(Task tk: Trigger.New){
        if(tk.Vertriebsaktion__c == null)
        {
            if(!leadMap.isEmpty() && leadMap.containsKey(tk.WhoId)){
                tk.Vertriebsaktion__c = leadMap.get(tk.WhoId).Leadevent_Kategorie__c;
            }
            else if(!contactMap.isEmpty() && contactMap.containsKey(tk.WhoId)){
                tk.Vertriebsaktion__c = contactMap.get(tk.WhoId).Leadevent_Kategorie__c;
            }
        }
    } 
    
}
This works just perfect. But what would need in addition is the scenario where a task is neither linked to a lead 
if(t.WhoId != null){
              String s1 = t.WhoId;
               if(s1.left(3) == '00Q'){
nor to a contact
else if(s1.left(3) == '003'){
                       contactId.add(t.whoId);

but only to an account. So in fact 'WhoId' would be emtpy and 'WhatId' would begin with '001'. 

Where and how can I add this condition?

Greetings and Thanks in Advance!

Jan
 

Hello Developers,

I have a custom field "Leadevent_Kategorie__c" on lead and contact. If this field is not blank, I want newly created tasks on these records to populate their field "Vertriebsaktion__c" with the value from "Leadevent_Kategorie__c".

I have the following trigger for leads:
trigger UpdateLeadeventKategorieLead on Task (before update) {
    Set<Id> leadId = new Set<Id>();
    for(Task t : Trigger.new){
        if(t.WhoId != null){
              String s1 = t.WhoId;
               if(s1.left(3) == '00Q'){
                        leadId.add(t.whoId);
               }
         }
    }

    Lead lead = [Select Id, Leadevent_Kategorie__c From Lead Where Id In : leadId limit 1];
    for(Task tk: Trigger.New){
           tk.Vertriebsaktion__c = lead.Leadevent_Kategorie__c;
    } 
    
}

and this one for contacts:
trigger UpdateLeadeventKategorieKontakt on Task (before update) {
    Set<Id> contactid = new Set<Id>();
    for(Task t : Trigger.new){
        if(t.WhoId != null){
              String s1 = t.WhoId;
               if(s1.left(3) == '003'){
                       contactId.add(t.whoId);
               }
         }
    }

    Contact contact = [Select Id, Leadevent_Kategorie__c From Contact Where Id In : contactId limit 1];
    for(Task tk: Trigger.New){
           tk.Vertriebsaktion__c = contact.Leadevent_Kategorie__c;
    } 
    
}
I always get the following error message: "System.QueryException: List has no rows for assignment to SObject Trigger"

Even though the value gets populated. I would also need to check if "Vertriebsaktion__c" on the task object is actually blank. If not - do not populated.




 

Hello there,

I have a custom object where I allow my users to add / attach contacts given from the information from a 3rd party.

User-added image
I have a created a Custom JavaScript Button, that - besides some other stuff - checks in its beginning, whether the "name" inside the field "Ansprechpartner" matches a contact inside the attached Account "Hobby Dittrich". 

If no contacts with this name are found, a new contact is created in the account and attached to my custom object in the field "Kontakt". (last part of my code)

What I need now is the case where the contact already exists in the account but is not yet attached to my custom object. In this specific example (screenshot) I know the contact already exists in the account. I need my button to take the queried contactID (contactsQuery?) and with it, populate my lookup field (Kontakt) so that the contact is on my custom object.

{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} 


var contactsQuery = sforce.connection.query

("SELECT Id FROM Contact WHERE AccountId='{!Leadevents__c.AccountId__c}' AND Salutation = '{!Leadevents__c.Anrede_JRi__c}'AND LastName = '{!Leadevents__c.Nachname_JRi__c}' ");

var contactsRecords = contactsQuery.getArray("records");

if( contactsRecords.length > 0 & "{!Leadevents__c.Kontakt__c}" == "") {
   alert("Kontakt existiert bereits im Account. Bitte dem Leadevent zuordnen");
} 

else if

("{!Leadevents__c.Nachname_JRi__c}" == "" || "{!Leadevents__c.Anrede_JRi__c}" == "")

{
alert('Es stehen nicht genügend Informationen zur Anlage eines neuen Kontaktes zur Verfügung.');
}


else if 

("{!Leadevents__c.Nachname_JRi__c}" == 
"{!Leadevents__c.Nachname_des_AP_auf_dem_Kontakt__c}"

&

"{!Leadevents__c.Anrede_JRi__c}" == 
"{!Leadevents__c.Anrede_des_AP_auf_dem_Kontakt__c}")



{ 
alert("Kontakt wurde bereits dem Leadevent zugeordnet.");
}



else
{
var Con = new sforce.SObject("Contact"); 
Con.Salutation = '{!Leadevents__c.Anrede_JRi__c}';
Con.FirstName = '{!Leadevents__c.Vorname_JRi__c}';
Con.LastName = '{!Leadevents__c.Nachname_JRi__c}';
Con.AccountId = '{!Leadevents__c.Account_ID__c}';
Con.Position__c = 'Personal-Referent';
Con.LeadSource = '{!Leadevents__c.Kategorie__c}';
Con.Phone = '{!Leadevents__c.Telefon_JRi__c}';
Con.Email = '{!Leadevents__c.E_Mail_JRi__c}';
Con.erstellt_durch_Leadevent__c = 1;	

var result = sforce.connection.create([Con]); 

if (result[0].getBoolean("success")) 

	{ 
	alert('Kontakt wird erstellt und dem Leadevent zugeordnet.'); 

	var p = new sforce.SObject("Leadevents__c");

	p.Id="{!Leadevents__c.Id}";
	p.Kontakt__c = result[0].id;

	var result1 = sforce.connection.update([p]);

		if(result1[0].getBoolean("success")) 

		location.reload(true);

			else
			alert('Error : '+result1); 

}
	}
Thanks in Advance and Greetings!

Jan
 

Hello everyone,

I am a total newbie when it comes to apex test classes and code coverage. I took over an org where a lot of customizing was done. When i hit "Estimate your organization's code covearge" it says:
User-added imageBefore that I was running tests on all our test classes.

Now I've build something on our sandbox and tried to deploy it. But I am getting the following error:

User-added image
Are these two different things? 

What can i do to get more than 73%? Write test classes for existing apex classes?

Thanks in Advance
Jan

Hello Devs,

I have the following use case: Whenever the custom field Update_child__c on a parent account is set to true, all child accounts should be set to true in this field as well.

This is what I got so far, but I am getting a "UpdateChildAccount: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: ()"

trigger UpdateChildAccount on Account (after update){
map<id,Account> acctId_to_acct = new map<id,Account>();
for(Account a : trigger.new){
if(trigger.oldmap.get(a.id).Update_child__ != a.Update_child__){
acctId_to_acct.put(a.id,a);
}
}
if(acctId_to_acct.size() > 0)
{
    List<Account> childAccounts = [select Update_child__,parentid from Account where id in :acctId_to_acct.keyset()];
    if(childAccounts <> NULL && childAccounts.size()>0)
    {
        for(Account a : childAccounts)
        {
            a.Update_child__ = acctId_to_acct.get(a.parentid).Update_child__;
           
        }
        update childAccounts;
    }
}   
}
Hello everyone,

i have a custom javascript button ("Kontakt anlegen und zuordnen), that allows me to create a new contact in an account while I am on my custom object and refer that newly created contact to that custom object:

Here is the button:

{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} 

var Con = new sforce.SObject("Contact"); 

Con.Salutation = '{!Leadevents__c.Anrede_JRi__c}';
Con.FirstName = '{!Leadevents__c.Vorname_JRi__c}';
Con.LastName = '{!Leadevents__c.Nachname_JRi__c}';
Con.AccountId = '{!Leadevents__c.Account_ID__c}';
Con.Position__c = 'Personal-Referent';
Con.LeadSource = '{!Leadevents__c.Kategorie__c}';
Con.Phone = '{!Leadevents__c.Telefon_JRi__c}';
Con.Email = '{!Leadevents__c.E_Mail_JRi__c}';
Con.erstellt_durch_Leadevent__c = 1;    

var result = sforce.connection.create([Con]); 

if (result[0].getBoolean("success")) 

    { 
    alert('Kontakt wird erstellt und dem Leadevent zugeordnet.'); 

    var p = new sforce.SObject("Leadevents__c");

    p.Id="{!Leadevents__c.Id}";
    p.Kontakt__c = result[0].id;

    var result1 = sforce.connection.update([p]);

        if(result1[0].getBoolean("success")) 

        location.reload(true);

            else
            alert('Error : '+result1); 
    } 

else{ 
    alert('Es stehen keine Informationen zur Anlage eines neuen Kontaktes zur Verfügung.'); 
    }


Here is my custom object:

User-added image
Now whenever I hit "Kontakt anlegen und zuordnen" the button creates a new contact in the connected account and links it to the custom object depenending on the information inside the field "Ansprechpartner". If the "salutation" or "lastname" are missing it alerts "Not enough information ti create a new contact". 

Now the problem I have is the following: The button executes everytime I hit it. So I can create the same contact over and over again. What I need is a condition that goes like this: When the information inside the field "Ansprechpartner" is the same as in "Kontakt" (maybe I would refer to it in another text formula to make it comparable) then do not create a new contact but alert sth like: "Contact already exists in that account."

I am not sure where to put my condition :/ Hope problem is clear and someone with more experience can help out.

Thanks in advance

Hello everyone,
on my custom object Leadevents__c I have create a custom button "New Contact" which creates the standard object "contact". For this I have all the data I need on my custom object: Name, AccountID etc.

On my custom object I have also a lookup to contacts.
User-added image
What I need is after the creation of a new contact (coming from my leadevents__c) that this contacts id gets passed into the related Leadevent and ends up as a look up value:

Here the result I would need:
User-added image
So I somehow need to update my Leadevents__c after a contact creation and figure out that the right contact is picked.
 

Does anyone have an idea to push me in the right direction? First thing I came up with (in theory) was creating a new contact via ProcessBuilder triggerd by a button on my leadevent, populate Leadevents__c ID on that contact and then "somehow" run a trigger that checks for contacts and Leadevents where the (Leadevents) - IDs match and then populate the contact id on my leadevent?

 

Hello everyone,

I created a custom related List using Visualforce for my custom object Leadevents__c on the account view:

User-added image


What I would need now, is to establish a custom hover link on top of the account page. Since this is not the "standard" related list from my custom object I assume I need to override my account page with a visualaforce page and add the code (???) there.

This is the 'standard' related list from the custom object which needs to be replaced.


User-added image
 
 
Hello everyone,

I have the following custom button (Akzeptieren / Accept) on detail view on my custom object leadevents__c:


User-added image

On top of that I build a custom related list (visualforce) for my custom object on the account view:


User-added image

Here also, i want to implement the logic of my button so whenever I click the Accept / Decline Button in the related List I want to trigger the logic of my custom detail page button. I achieved editing the "action button" inside my visualforce page:

<apex:commandLink value="Akzeptieren" style="color:#015ba7;" 
action="{!editLeadevents}" target="_parent" ><apex:param value="{!le.id}" name="LeadeventsId"/> </apex:commandLink> 

As one can see the "action" is {!editLeadevents} which is a standard action!? What I want is to call my very own action / button "Akzeptieren"

Here is the code from the java script onclick button on the detail page:

{!REQUIRESCRIPT("/soap/ajax/41.0/connection.js")} 

try{ 
var LeadeventObj = new sforce.SObject("Leadevents__c"); 
LeadeventObj.Id = "{!Leadevents__c.Id}"; 

if("{!Leadevents__c.OwnerId}" != "{!$User.Id}")

alert("Nicht ausreichend Berechtigung."); 

else if ({!Leadevents__c.Leadevents_in_Bearbeitung_Counter_II__c} > 0)
{
alert("Es ist bereits ein Leadevent in Bearbeitung.");
}
else if("{!Leadevents__c.AccountId__c}" == '')

LeadeventObj.RecordTypeId = "0121l0000008XPt";
LeadeventObj.Status__c = "Akzeptiert";
LeadeventObj.Phase__c = "in Bearbeitung"; 

var updateResult = sforce.connection.update([LeadeventObj]); 
if(updateResult[0].success === "true"){ 
location.reload(); 
}
}
else 
{
LeadeventObj.RecordTypeId = "0121l0000008XPe";
LeadeventObj.Status__c = "Akzeptiert";
LeadeventObj.Phase__c = "in Bearbeitung"; 


Here is the part of my controller that is resonsible for the "editing" functionality:


    //This method is to edit the existing leadevent records while clicking the Edit link 

    public pageReference editLeadevents(){  

        String LeadeventsId = Apexpages.currentpage().getParameters().get('LeadeventsId');  

        pageReference pageRef = new pageReference(URL.getSalesforceBaseUrl().toExternalForm() + '/' + LeadeventsId + '/e?retURL=' + Leadevents__c.id);  

        return pageRef;  


So what I want is to click on the "Akzeptieren" CommandLink inside my custom related list and to execute the logic of the javascript onclick button. Pretty sure this is possible

Thanks in Advance and Greetings

 

Hello everyone,

I'm stuck with a question regarding the naming of my pageBlockTable. I have build a custom related List using Visual Force. I am struggling however to add a title to that related List that is on the same level as my button.

This would be the default related list:

User-added image

Mine is missing the naming.

User-added image

Here is part of my VF:

 <apex:form >                 

        <apex:pageblock id="OppList" > 

          <div style="margin-left: 30%;" ><apex:commandLink value="Neue Opportunity" action="{!newOpportunity}" target="_parent" styleClass="btn" style="text-decoration:none;padding:4px;"/></div> 

            <br/> 

            <apex:pageBlockTable value="{!opportunities}" var="opp" rendered="{!NOT(ISNULL(opportunities))}" title="Contact">   

                <apex:column HeaderValue="Action" width="100" > 

                    <apex:commandLink value="Bearbeiten" style="color:#015ba7;" action="{!editOpportunity}" target="_parent" ><apex:param value="{!opp.id}" name="OpportunityId"/> 

                    </apex:commandLink> 

                    </apex:column> 
                
                <apex:column headerValue="Opportunity Name"><apex:outputLink value="/{!opp.id}" target="_blank">{!opp.Name}</apex:outputLink> </apex:column>  
                
                <apex:column value="{!opp.Inhaber_vollst_ndiger_Name__c}"/>
                
                <apex:column value="{!opp.StageName}"/> 
                
                <apex:column value="{!opp.Probability}"/>    
                
                <apex:column value="{!opp.Amount}"/>
                
                <apex:column value="{!opp.CloseDate}"/>
                       
               </apex:pageBlockTable>    

Hello everyone,

I have a custom object called "Leadevents__c" that can be attached to Leads and Accounts. In the screenshot it is attached  to Lead: 
User-added image
After conversion it will get attached to an account. We have an apex class in place that provides this:
User-added image
However I lose the contact on my way from Lead to Account. What I would need is the following result:
User-added image

The challenge is that the apex class provinding said usability is over 10 years old and not mine. I was able (at least I think so) to figure out the code responsable:

User-added image


I added "Kontakt__c" so that I could refer to "le.Kontakt__c" and give it a value. Now I have a fix contact ID in there which actually works. When I convert a lead, this contact ID is attached to the "leadevent__c". Obviously I need a dynamic verison. Is anyone able to review this code and tell me if this is the right place and what I would need to achieve this?

Thanks guys!
Hello Community,

I need to create a onClick JavaScript Button that switches a custom field on my custom object to a specific value. Now here’s the trick part: It should only execute if no other related objects have already that value.

Example:

User-added image

My custom object is leadevent__c and has a lookup to account. Therefore it is a related list. I have a custom field Phase__c with a value called "in Bearbeitung". I only want to allow 1 leadevent to be in the Phase__ "in Bearbeitung" at a time. Now on the page of the leadevent I already have a button called "Akzeptieren" (Accept) that switches my Phase__c to "in Bearbeitung". However before that happens the button should query through all other leadevents who relate to that account and check if any of them is already in the Phase__c "in Bearbeitung". If so, a simple alert would be enough. If not, the Phase__c should change.

User-added image
 
Is that possible? Im a just in at the beginning of my travel in figuring out what is possible in Salesforce. Hope someone can help.

Greetings from Germany

Hello developers,

we have a lot of process builders in our org that run when an opportunity record gets created/edited. They have very different criterias on when to run and when not to. In order to do some bugfixing and improving the performance I would like to know which of these process actually get triggered when creating/saving an opportunity.

Is there a way to see which of those actually run when I create/save an opportunity? Some kind of an overview which flows have run?

I only found the overview for 'pending' flows but thats not what I need. 

Thanks!

Hello Developers,

I have the following trigger which pulls data (Leadevent_Kategorie__c) from the lead / contact and writes it after creation/insert on the task (tk.Vertriebsaktion__c).
trigger UpdateLeadeventKategorieTask on Task (before insert) {
    Set<Id> leadId = new Set<Id>();
    Set<Id> contactid = new Set<Id>();
    
    for(Task t : Trigger.new){
        if(t.WhoId != null){
              String s1 = t.WhoId;
               if(s1.left(3) == '00Q'){
                        leadId.add(t.whoId);
               }
               else if(s1.left(3) == '003'){
                       contactId.add(t.whoId);
               }
         }
    }

    Map<Id,Lead> leadMap = new Map<Id,Lead>([Select Id, Leadevent_Kategorie__c From Lead Where Id In : leadId]);
    Map<Id,Contact> contactMap = new Map<Id,Contact>([Select Id, Leadevent_Kategorie__c From Contact Where Id In : contactId]);
    
    for(Task tk: Trigger.New){
        if(tk.Vertriebsaktion__c == null)
        {
            if(!leadMap.isEmpty() && leadMap.containsKey(tk.WhoId)){
                tk.Vertriebsaktion__c = leadMap.get(tk.WhoId).Leadevent_Kategorie__c;
            }
            else if(!contactMap.isEmpty() && contactMap.containsKey(tk.WhoId)){
                tk.Vertriebsaktion__c = contactMap.get(tk.WhoId).Leadevent_Kategorie__c;
            }
        }
    } 
    
}
This works just perfect. But what would need in addition is the scenario where a task is neither linked to a lead 
if(t.WhoId != null){
              String s1 = t.WhoId;
               if(s1.left(3) == '00Q'){
nor to a contact
else if(s1.left(3) == '003'){
                       contactId.add(t.whoId);

but only to an account. So in fact 'WhoId' would be emtpy and 'WhatId' would begin with '001'. 

Where and how can I add this condition?

Greetings and Thanks in Advance!

Jan
 

Hello Developers,

I have a custom field "Leadevent_Kategorie__c" on lead and contact. If this field is not blank, I want newly created tasks on these records to populate their field "Vertriebsaktion__c" with the value from "Leadevent_Kategorie__c".

I have the following trigger for leads:
trigger UpdateLeadeventKategorieLead on Task (before update) {
    Set<Id> leadId = new Set<Id>();
    for(Task t : Trigger.new){
        if(t.WhoId != null){
              String s1 = t.WhoId;
               if(s1.left(3) == '00Q'){
                        leadId.add(t.whoId);
               }
         }
    }

    Lead lead = [Select Id, Leadevent_Kategorie__c From Lead Where Id In : leadId limit 1];
    for(Task tk: Trigger.New){
           tk.Vertriebsaktion__c = lead.Leadevent_Kategorie__c;
    } 
    
}

and this one for contacts:
trigger UpdateLeadeventKategorieKontakt on Task (before update) {
    Set<Id> contactid = new Set<Id>();
    for(Task t : Trigger.new){
        if(t.WhoId != null){
              String s1 = t.WhoId;
               if(s1.left(3) == '003'){
                       contactId.add(t.whoId);
               }
         }
    }

    Contact contact = [Select Id, Leadevent_Kategorie__c From Contact Where Id In : contactId limit 1];
    for(Task tk: Trigger.New){
           tk.Vertriebsaktion__c = contact.Leadevent_Kategorie__c;
    } 
    
}
I always get the following error message: "System.QueryException: List has no rows for assignment to SObject Trigger"

Even though the value gets populated. I would also need to check if "Vertriebsaktion__c" on the task object is actually blank. If not - do not populated.




 

Hello there,

I have a custom object where I allow my users to add / attach contacts given from the information from a 3rd party.

User-added image
I have a created a Custom JavaScript Button, that - besides some other stuff - checks in its beginning, whether the "name" inside the field "Ansprechpartner" matches a contact inside the attached Account "Hobby Dittrich". 

If no contacts with this name are found, a new contact is created in the account and attached to my custom object in the field "Kontakt". (last part of my code)

What I need now is the case where the contact already exists in the account but is not yet attached to my custom object. In this specific example (screenshot) I know the contact already exists in the account. I need my button to take the queried contactID (contactsQuery?) and with it, populate my lookup field (Kontakt) so that the contact is on my custom object.

{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} 


var contactsQuery = sforce.connection.query

("SELECT Id FROM Contact WHERE AccountId='{!Leadevents__c.AccountId__c}' AND Salutation = '{!Leadevents__c.Anrede_JRi__c}'AND LastName = '{!Leadevents__c.Nachname_JRi__c}' ");

var contactsRecords = contactsQuery.getArray("records");

if( contactsRecords.length > 0 & "{!Leadevents__c.Kontakt__c}" == "") {
   alert("Kontakt existiert bereits im Account. Bitte dem Leadevent zuordnen");
} 

else if

("{!Leadevents__c.Nachname_JRi__c}" == "" || "{!Leadevents__c.Anrede_JRi__c}" == "")

{
alert('Es stehen nicht genügend Informationen zur Anlage eines neuen Kontaktes zur Verfügung.');
}


else if 

("{!Leadevents__c.Nachname_JRi__c}" == 
"{!Leadevents__c.Nachname_des_AP_auf_dem_Kontakt__c}"

&

"{!Leadevents__c.Anrede_JRi__c}" == 
"{!Leadevents__c.Anrede_des_AP_auf_dem_Kontakt__c}")



{ 
alert("Kontakt wurde bereits dem Leadevent zugeordnet.");
}



else
{
var Con = new sforce.SObject("Contact"); 
Con.Salutation = '{!Leadevents__c.Anrede_JRi__c}';
Con.FirstName = '{!Leadevents__c.Vorname_JRi__c}';
Con.LastName = '{!Leadevents__c.Nachname_JRi__c}';
Con.AccountId = '{!Leadevents__c.Account_ID__c}';
Con.Position__c = 'Personal-Referent';
Con.LeadSource = '{!Leadevents__c.Kategorie__c}';
Con.Phone = '{!Leadevents__c.Telefon_JRi__c}';
Con.Email = '{!Leadevents__c.E_Mail_JRi__c}';
Con.erstellt_durch_Leadevent__c = 1;	

var result = sforce.connection.create([Con]); 

if (result[0].getBoolean("success")) 

	{ 
	alert('Kontakt wird erstellt und dem Leadevent zugeordnet.'); 

	var p = new sforce.SObject("Leadevents__c");

	p.Id="{!Leadevents__c.Id}";
	p.Kontakt__c = result[0].id;

	var result1 = sforce.connection.update([p]);

		if(result1[0].getBoolean("success")) 

		location.reload(true);

			else
			alert('Error : '+result1); 

}
	}
Thanks in Advance and Greetings!

Jan
 

Hello everyone,

I am a total newbie when it comes to apex test classes and code coverage. I took over an org where a lot of customizing was done. When i hit "Estimate your organization's code covearge" it says:
User-added imageBefore that I was running tests on all our test classes.

Now I've build something on our sandbox and tried to deploy it. But I am getting the following error:

User-added image
Are these two different things? 

What can i do to get more than 73%? Write test classes for existing apex classes?

Thanks in Advance
Jan

Hello everyone,

i have a custom javascript button ("Kontakt anlegen und zuordnen), that allows me to create a new contact in an account while I am on my custom object and refer that newly created contact to that custom object:

Here is the button:

{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} 

var Con = new sforce.SObject("Contact"); 

Con.Salutation = '{!Leadevents__c.Anrede_JRi__c}';
Con.FirstName = '{!Leadevents__c.Vorname_JRi__c}';
Con.LastName = '{!Leadevents__c.Nachname_JRi__c}';
Con.AccountId = '{!Leadevents__c.Account_ID__c}';
Con.Position__c = 'Personal-Referent';
Con.LeadSource = '{!Leadevents__c.Kategorie__c}';
Con.Phone = '{!Leadevents__c.Telefon_JRi__c}';
Con.Email = '{!Leadevents__c.E_Mail_JRi__c}';
Con.erstellt_durch_Leadevent__c = 1;    

var result = sforce.connection.create([Con]); 

if (result[0].getBoolean("success")) 

    { 
    alert('Kontakt wird erstellt und dem Leadevent zugeordnet.'); 

    var p = new sforce.SObject("Leadevents__c");

    p.Id="{!Leadevents__c.Id}";
    p.Kontakt__c = result[0].id;

    var result1 = sforce.connection.update([p]);

        if(result1[0].getBoolean("success")) 

        location.reload(true);

            else
            alert('Error : '+result1); 
    } 

else{ 
    alert('Es stehen keine Informationen zur Anlage eines neuen Kontaktes zur Verfügung.'); 
    }


Here is my custom object:

User-added image
Now whenever I hit "Kontakt anlegen und zuordnen" the button creates a new contact in the connected account and links it to the custom object depenending on the information inside the field "Ansprechpartner". If the "salutation" or "lastname" are missing it alerts "Not enough information ti create a new contact". 

Now the problem I have is the following: The button executes everytime I hit it. So I can create the same contact over and over again. What I need is a condition that goes like this: When the information inside the field "Ansprechpartner" is the same as in "Kontakt" (maybe I would refer to it in another text formula to make it comparable) then do not create a new contact but alert sth like: "Contact already exists in that account."

I am not sure where to put my condition :/ Hope problem is clear and someone with more experience can help out.

Thanks in advance

Hello everyone,
on my custom object Leadevents__c I have create a custom button "New Contact" which creates the standard object "contact". For this I have all the data I need on my custom object: Name, AccountID etc.

On my custom object I have also a lookup to contacts.
User-added image
What I need is after the creation of a new contact (coming from my leadevents__c) that this contacts id gets passed into the related Leadevent and ends up as a look up value:

Here the result I would need:
User-added image
So I somehow need to update my Leadevents__c after a contact creation and figure out that the right contact is picked.
 

Does anyone have an idea to push me in the right direction? First thing I came up with (in theory) was creating a new contact via ProcessBuilder triggerd by a button on my leadevent, populate Leadevents__c ID on that contact and then "somehow" run a trigger that checks for contacts and Leadevents where the (Leadevents) - IDs match and then populate the contact id on my leadevent?

 

Hello everyone,

I'm stuck with a question regarding the naming of my pageBlockTable. I have build a custom related List using Visual Force. I am struggling however to add a title to that related List that is on the same level as my button.

This would be the default related list:

User-added image

Mine is missing the naming.

User-added image

Here is part of my VF:

 <apex:form >                 

        <apex:pageblock id="OppList" > 

          <div style="margin-left: 30%;" ><apex:commandLink value="Neue Opportunity" action="{!newOpportunity}" target="_parent" styleClass="btn" style="text-decoration:none;padding:4px;"/></div> 

            <br/> 

            <apex:pageBlockTable value="{!opportunities}" var="opp" rendered="{!NOT(ISNULL(opportunities))}" title="Contact">   

                <apex:column HeaderValue="Action" width="100" > 

                    <apex:commandLink value="Bearbeiten" style="color:#015ba7;" action="{!editOpportunity}" target="_parent" ><apex:param value="{!opp.id}" name="OpportunityId"/> 

                    </apex:commandLink> 

                    </apex:column> 
                
                <apex:column headerValue="Opportunity Name"><apex:outputLink value="/{!opp.id}" target="_blank">{!opp.Name}</apex:outputLink> </apex:column>  
                
                <apex:column value="{!opp.Inhaber_vollst_ndiger_Name__c}"/>
                
                <apex:column value="{!opp.StageName}"/> 
                
                <apex:column value="{!opp.Probability}"/>    
                
                <apex:column value="{!opp.Amount}"/>
                
                <apex:column value="{!opp.CloseDate}"/>
                       
               </apex:pageBlockTable>    

Hello everyone,

I have a custom object called "Leadevents__c" that can be attached to Leads and Accounts. In the screenshot it is attached  to Lead: 
User-added image
After conversion it will get attached to an account. We have an apex class in place that provides this:
User-added image
However I lose the contact on my way from Lead to Account. What I would need is the following result:
User-added image

The challenge is that the apex class provinding said usability is over 10 years old and not mine. I was able (at least I think so) to figure out the code responsable:

User-added image


I added "Kontakt__c" so that I could refer to "le.Kontakt__c" and give it a value. Now I have a fix contact ID in there which actually works. When I convert a lead, this contact ID is attached to the "leadevent__c". Obviously I need a dynamic verison. Is anyone able to review this code and tell me if this is the right place and what I would need to achieve this?

Thanks guys!
Hi,

I have created following trigger for custom rollup summary.
but now i want to calculate sum of all orderItem on insertion of each new OrderItem. Now it only adding new value into existing rollup field.

Object Details :
Parent : Order
Child : OrderItem
Roll up field : Total_Pieces1__c (order field)
Summurised field : Pieces__c (OrderItem field)

trigger TotalPiecesSum on OrderItem (before update, before insert,before delete) {

list<Order> a = new list<Order>();
    set<id> OrderIDs= new set<id>();

if(trigger.isInsert || trigger.isBefore){
   for(OrderItem o : Trigger.new){
      OrderIDs.add(o.Orderid);
   }
   }

else if(trigger.isDelete){
     for(OrderItem o : Trigger.old){
         OrderIDs.add(o.Orderid);
     }
}
else 
      
     if(trigger.isUpdate){
     for(orderItem o: trigger.new){
        if(trigger.oldmap.get(o.id).Order!=o.Order){
            OrderIDs.add(o.OrderID);
            OrderIDs.add(trigger.oldmap.get(o.id).OrderID);
        }
    }
}
    
    AggregateResult[] groupedResults = [SELECT SUM(Pieces__c),OrderId FROM OrderItem where OrderId IN :OrderIDs GROUP BY OrderId ];
    system.debug('*******groupedResults **********'+groupedResults);     
    
    for(AggregateResult ar:groupedResults) {
        Id orid = (ID)ar.get('OrderId');
        system.debug('*******selected Oredr id **********'+orid);     
        Decimal count = (Decimal)ar.get('expr0');
            
        Order o1 = new Order(Id=orid);
        o1.Total_Pieces1__c= count;
        system.debug('*******Total_Pieces1__cOredr id **********'+count); 
        a.add(o1);
       }
   update a;
}