• Adilson Arcoverde Jr
  • NEWBIE
  • 435 Points
  • Member since 2018
  • CTO
  • Dreamm Tecnologia


  • Chatter
    Feed
  • 14
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 69
    Replies
Hello All,
I have been tasked to find duplicate Leads within our org.

Each Lead has an activity(s)
FInd the oldest lead and make this the master.
Take the activities from the other Leads and merge them to the Master Lead. 
Delete the duplicate Leads.

This wil be a once and done since we now have a process to marry all the Leads together based on the email address.
I just need some help on the best approach to resolve this issue.
I do not actually need to merge the vlaues on the Lead details record as much as I need to make sure I get all of the Activities into a single Leads record.

I thought about trying the below approach but I am not thinking it will meet all of me needs
List<AggregateResult> DuplicateList = 
[select count(email), id from lead where email != '' group by id having count(email) >1 limit 200];


For (AggregateResult Agm:DuplicateList){

   String LeadEmail = string.valueOf(agm.get('email'));
   Lead ToLead = [Select id, email from Lead where email like :LeadEmail limit 1];
   Lead FromLead = [Select id, email from Lead where Id != :ToLead.Id and email like :LeadEmail Limit 1];

   system.debug(LoggingLevel.Info,'*** FromLead: ' + FromLead.email+' ('+FromLead.Id+')');
   system.debug(LoggingLevel.Info,'*** ToLead  : ' + ToLead.email+' ('+ToLead.Id+')');
   database.merge(ToLead , FromLead );

}
Thanks,
M
 
Hello,

I have lookup "contact" on my "opportunity", 
"Contact" has a field called "XYZ (checkbox)".
I want to implement a validation rule which says that, if the Opportunity Stage is Won, then only allow the users to mody the checkbox on Contact.

How can i implement this validation rule ?
thank you for sugestions
  • January 09, 2019
  • Like
  • 0
How to write cross object trigger in salesforce?
I have one checkbox in one of my custom object and 'Instalment field' in another custom object, if that checkbox is checked in then first object then take sum of all instalments in another object

Hi,
I need to expose certain Salesforce Data to a third party app that doesn't have a ready-made Salesforce integration. I'm going to use REST API to expose the data and this action will be triggered when a status changes. 

Here is the general process of what should happen 
1. User changes status which triggers the API
2. API call made to an external app and Salesforce Data is exposed, ready to be consumed
3. External App consumes data 

I'm struggling to understand what would I need to ask from the third part? and is there anything else I would need to do?

Any help is much appreciated :)
Many Thanks,
Natasha 


 

I want to to fill this class  but I can't reach wrapper attributes:
 
public class PricingMotor_cls {
	public Double cost;
	public OrderItems[] orderItems;

//Wrapper for OrderItem
	public class OrderItems {

		public Integer quantity;
		public CashAmounts creditAmounts;
	}

	//Wrapper CashAmounts 
	public class CashAmounts {
		public Double totalPrice;
		public OrderConditions[] orderConditions;
	}
        //Wrapper OrderConditions 
        public class OrderConditions {
		public String conditionType;
		public Decimal amount;
	}

}

I try 
List<ISSM_DeserializePricingMotor_cls.OrderItems> abc = new ISSM_DeserializePricingMotor_cls.OrderItems[1];
abc[0].quantity = 1;

but told me:  FATAL_ERROR System.ListException: List index out of bounds

what I'm doing wrong...
how I fill all object?
Below code retrieves all nested level user's Id list. Need to retrieve only immediate lower level user's Id list.
public with sharing class RoleUtils {
	
  public static Set<ID> getRoleSubordinateUsers(Id userId) {
  	
    // get requested user's role
    Id roleId = [select UserRoleId from User where Id = :userId].UserRoleId;
    // get all of the roles underneath the user
    Set<Id> allSubRoleIds = getAllSubRoleIds(new Set<ID>{roleId});
    // get all of the ids for the users in those roles
    Map<Id,User> users = new Map<Id, User>([Select Id, Name From User where 
      UserRoleId IN :allSubRoleIds]);
    // return the ids as a set so you can do what you want with them
    return users.keySet();
  	
  }
	
  private static Set<ID> getAllSubRoleIds(Set<ID> roleIds) {
  	
    Set<ID> currentRoleIds = new Set<ID>();
    
    // get all of the roles underneath the passed roles
    for(UserRole userRole :[select Id from UserRole where ParentRoleId 
      IN :roleIds AND ParentRoleID != null])
    currentRoleIds.add(userRole.Id);
    
    // go fetch some more rolls!
    if(currentRoleIds.size() > 0)
      currentRoleIds.addAll(getAllSubRoleIds(currentRoleIds));

    return currentRoleIds;
    
  }

}

 
Hello Guys,

I am working on one scenario in which an object is having self lookup relationship and need to count records based on record types.

I have an object called "Property_Assignment__c" which has two record types.
1) Primary Property Assignment
2) Secondary Property Assignment
Its also having a self lookup relationship and this lookup field "Primary_Assignemnt__c" is available on "Secondary Property Assignment" page layout which is lookup to "Primary Property Assignment".
Now if I create any records in "Secondary Property Assignment" record type then I need to count and save in "Number_Of__Dependents" field in "Primary Property Assignment".
Can anyone help me to solve this problem if possible please.
 
Hi everyone, I am working on a Lightning Component which has a lightning select with its values fetched dynamically from a picklist field.
 
<lightning:select aura:id="select" label="Estado de la cita" name="source" onchange="{!c.handleSelect}" class="slds-m-bottom_medium">
     <option value="" disabled="true" text="-- Selecciona Estado --"/>
     <option value="Todos" text="Todos"/>
     <aura:iteration var="stat" items="{!v.statusList}">
          <option value="{!stat}" text="{!stat}"/>
     </aura:iteration>
 </lightning:select>

I found on the Internet this solution but it's not working for me
doInit: function(cmp){
        
        var action = cmp.get("c.getStatus");
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            var statusList = response.getReturnValue();
            if(state == "SUCCESS"){
                cmp.set("v.statusList",statusList);
                window.setTimeout(
                $A.getCallback( function() {
                    cmp.find("select").set("v.statusList", statusList[1]);
                }));
            }
        });
        
        $A.enqueueAction(action);
    },
The cmp.find recover the value I want but then that value it's not setted as default.

Someone can help me?

Regards and thanks in advance
 
Hi All,

I'm having trouble bringing all the events users create.
As I understand, Once I settled role hierarchy, low-level role couldn't access its superior's data.
Even though I query all the events, it's affected by the role setting. (unable to show all the events to low-level role user)
In case of this situation, How do I make it able to show all the events?

Please let me know if my explanation is not enough to understand.

Thanks for your help in advance.
Hi,
I'm trying to use a map as a static set of values, something akin to a literal, and want to use different values for the 'literal' in different sections of code. What I would like to do is something like this:
Map<String,List<String>> x;
x = new Map<List<String>>{'key1' => new List<String>{'a', 'b', 'c'}, etc};
// stuff using x as list of literals
x = new Map<List<String>>{'key1' => new List<String>{'d', 'e', 'f'}, etc};
// stuff using x as list of different literals
now my question is how this will behave in apex - whether this will create a memory leak? when I instantiate the same map the second time, does the memory get freed from my first 'instance'? I haven't coded in 18 years, and that was in C where I had to be more explicit with my memory.
I could just create multiple Maps, but it seems unnecessary when each of these sets are used mutually exclusively, and i have a perfectly good Map sitting there already.
thanks in advance!
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
1. At asset creation, it should take the following value: product.pen ++ "_" ++ Account.Name (truncated to max 80 characters) ++ "_" ++ Creation Date
2.This is a standard field and should be read-only.

Could you please help me with this 
Hi,

I have custom object called ITEM with three Fields:
  1. CUSTOMER   (lookup field from Account)
  2. LOCATION (lookup from field Well__c)
  3. PRIME CUSTOMER (checkbox)
 
I have another custom field: DIRECT INVOICE where there are only two fields. This is kind of list of combination.
  1. CUSTOMER INVOICE  (lookup field from Account)
  2. LOCATION INVOICE (Lookup field from Well__c)
 
I need to write a trigger (after update, after insert) where if CUSTOMER and LOCATION from object ITEM matches with any of the records  with CUSTOMER INVOICE and LOCATION INVOICE from DIRECT INVOICE, then update a field PRIME CUSTOMER in item to TRUE.
 
I am maintaining a list of combination of customer invoice and location invoice in Direct invoice object, hence any new record of update record in object is to be checked with all records in Direct invoice to find if any records matches.
 
Thank you for your suggestion.
 
Hi,

I'm stucked on Service Cloud Specialist step 6. It shows the error message:

Challenge Not yet complete... here's what's wrong: 
We can't find the Recipient field in the email template. Ensure the Cloudy Weather Email Template addresses the Recipient of the email.
Close errors

However, my email template called Cloudy weather (Text format) has the following body:

Hey {!Contact.FirstName}, Sorry to hear that your panels aren't generating the power you hoped for. Based on our research, it appears the low power produced is related to the cloudy weather in your area recently. In the worst conditions, Ursa Major panels produce ~25% of maximum power. If you have additional questions, please give us a call and reference case {!Case.CaseNumber}. Thanks! {!User.Name}, Ursa Major Solar

Any ideas?

Regards
Hi,

I'm stucked on Service Cloud Specialist step 6. It shows the error message:

Challenge Not yet complete... here's what's wrong: 
We can't find the Recipient field in the email template. Ensure the Cloudy Weather Email Template addresses the Recipient of the email.
Close errors

However, my email template called Cloudy weather (Text format) has the following body:

Hey {!Contact.FirstName}, Sorry to hear that your panels aren't generating the power you hoped for. Based on our research, it appears the low power produced is related to the cloudy weather in your area recently. In the worst conditions, Ursa Major panels produce ~25% of maximum power. If you have additional questions, please give us a call and reference case {!Case.CaseNumber}. Thanks! {!User.Name}, Ursa Major Solar

Any ideas?

Regards
I have a RestClient test class. In the following part I get this error,
static testmethod void testGet() { 
        RestClientSpy spy = new RestClientSpy();
        
        spy.send(RequestMethods.GET.name(), '/services/data', null);
        
        System.assertEquals(1, spy.getSendCount());
        System.assertEquals(null, spy.getHttpRequest().getBody()); 
        System.assertEquals('GET', spy.getHttpRequest().getMethod()); 
    }

"System.AssertException: Assertion Failed: Expected: null, Actual:"
I tried different things to make it work, still am unable to figure it out. Can anyone help me in this please?
TIA.
Hello All,
I have been tasked to find duplicate Leads within our org.

Each Lead has an activity(s)
FInd the oldest lead and make this the master.
Take the activities from the other Leads and merge them to the Master Lead. 
Delete the duplicate Leads.

This wil be a once and done since we now have a process to marry all the Leads together based on the email address.
I just need some help on the best approach to resolve this issue.
I do not actually need to merge the vlaues on the Lead details record as much as I need to make sure I get all of the Activities into a single Leads record.

I thought about trying the below approach but I am not thinking it will meet all of me needs
List<AggregateResult> DuplicateList = 
[select count(email), id from lead where email != '' group by id having count(email) >1 limit 200];


For (AggregateResult Agm:DuplicateList){

   String LeadEmail = string.valueOf(agm.get('email'));
   Lead ToLead = [Select id, email from Lead where email like :LeadEmail limit 1];
   Lead FromLead = [Select id, email from Lead where Id != :ToLead.Id and email like :LeadEmail Limit 1];

   system.debug(LoggingLevel.Info,'*** FromLead: ' + FromLead.email+' ('+FromLead.Id+')');
   system.debug(LoggingLevel.Info,'*** ToLead  : ' + ToLead.email+' ('+ToLead.Id+')');
   database.merge(ToLead , FromLead );

}
Thanks,
M
 
Hi All,
        i have 15 record types. and i created a Visualforce page in which i am taking all record types in the Record type picklist(caseObj.RecordTypeId).
        now my requirement is to take only few record type in the  RecordType picklist in my visualforce Page.
how to do this?User-added image
I'm stumped by this, because there may be multiple triggers fired. Really what I want is a trigger on the opp when any related opportunitysplit is inserted, updated, or deleted (that's how OpportunityLineItem works). But OpportunitySplit does not seem to fire Opportunity triggers.

I can't figure out how to use the OpportunitySplit trigger, because multiple triggers may fire (insert, update, delete), and I only want to send one email when any aspect of the OpportunitySplit changes.
I am trying to programmatically reduce the number of tasks. I ran a simple query using in Apex Execute Anonymous:
 
List<Task> tasks = [Select Id from Task WHERE Subject Like '%Was Email Sent%'];
System.debug(tasks.size());
delete tasks;

To my confusion, the query came back with 0 results, even though I know for a fact that a task with that string in the subject exists. I then went  to an actual Task with that in the subject and ran this query:
 
List<Task> tasks = [Select Id from Task WHERE Id = '00TA000002lcsWy'];
System.debug(tasks);
delete tasks;

But that returned 0 results. I can manually edit and delete these tasks, but for some reason, I can't query them.
I did notice that the Tasks that were queriable have IDs that begin with 00T1 whilst these start off with 00TA. Is there anything to that? Are they recognized as a completely different object? 

 
Hi,

I have a lightning compnent exactly same as given in below link... 
http://sfdcmonkey.com/2018/10/22/data-table-pagination-checkbox-lightning/.

<aura:if isTrue="{!v.bNoRecordsFound}">
       <div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_info" role="alert">
            <span class="slds-assistive-text">Error</span>
            <h2> ERROR MESSAGE </h2>
        </div>
        <aura:set attribute="else">
         --------------
             <table>
                   <!---- TABLE WITH DATA --->
             </table>
         -----------------
            </aura:set>    
     </aura:if>

Here, when the lightning component is loaded, even if there are no records to display in table of else section... still a blank table is displayed for a while and goes off... and later error message from if section is shown.
how to avoid this ?
We strictly want to show error message immediately if the given condition is true else display the else section(table).

Thanks,
Anupama


    

 
Hi,
My logic is: If (Manager__c == Null && region__c == 'South' 
 then assign the newly created record to South_Zonal_Manager__c

My requirement is something like this, can someone help me.

Twist here for me is I have 4 regions (east, west, north, south)  and I have 4 different zonal managers

 
  • January 09, 2019
  • Like
  • 0
Hello,

I have lookup "contact" on my "opportunity", 
"Contact" has a field called "XYZ (checkbox)".
I want to implement a validation rule which says that, if the Opportunity Stage is Won, then only allow the users to mody the checkbox on Contact.

How can i implement this validation rule ?
thank you for sugestions
  • January 09, 2019
  • Like
  • 0
Hi Every one,

How can i write program checking Duplicate fields in Lead object FirstName,Email,company,phone using trigger concept and also display message if it is Dublicate its not dublicate record will save.
How to write cross object trigger in salesforce?
I have one checkbox in one of my custom object and 'Instalment field' in another custom object, if that checkbox is checked in then first object then take sum of all instalments in another object
Hello,

I am working in a B2B environment and the vast majority (if not all) of the Cases created are from Web-to-Case submission. I've done some research and it seems that the most efficient way of auto-assigning my Entitlement (only one Entitlement for all Accounts) is through an Apex trigger. Can anyone help with the most efficient way of doing this? Only one Entitlement, wanting to auto-assign to every Case that is created through Web-To-Case.

Thank you!