• Nathan Ehrmann
  • NEWBIE
  • 25 Points
  • Member since 2014
  • Salesforce Architect
  • Accruent


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

I wouldn't call myself a developer per se, more like an overreaching admin.

Trying to build an invocable class that converts a lead if it meets a criteria set in Process Builder. 

The class itself appears to be working, but my test is failing and I have 0% code coverage. *cries*

Class: 
---------------------------------------------------------------------------------
Public class AutoConvertLead
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
            Database.LeadConvert Leadconvert = new Database.LeadConvert();
            Leadconvert.setLeadId(LeadIds[0]);
            LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            Leadconvert.setConvertedStatus(Leads.MasterLabel);
            Leadconvert.setDoNotCreateOpportunity(TRUE); 
            Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
            System.assert(Leadconverts.isSuccess());
   }
}


---------------------------------------
Test:
----------------------------------------------

@isTest 
      public class TestAutoConvertLead{
            static testMethod void createnewlead() {
      User userToCreate = [Select id from user where profile.name='System Administrator' Limit 1];
      
      Test.startTest();    
      Lead leadToCreate =new Lead();
      List<id> Ids= New List<Id>();
      leadToCreate.Ownerid = '005D0000005sPGcIAM';
      leadToCreate.LastName ='Bertha';
      leadToCreate.Company='Salesforce';
      leadToCreate.Status='Sales Qualified';
      leadToCreate.SalesCountry__r.id = 'a002000000F9XHaAAN';
      leadToCreate.Email = 'bigbertha@testing.com';
      leadToCreate.Street ='1 Union Street';
      leadToCreate.City = 'London';
      leadToCreate.State = 'London';
      leadToCreate.PostalCode = 'SW8 2LN';
      leadToCreate.Country = 'United Kingdom';
      insert leadToCreate; 
 
      Ids.add(leadToCreate.id);
      AutoConvertLead.LeadAssign(Ids);
      
      Test.stopTest();
   }
}

------------------------------------------
Error: 
--------------------------------------------
System.NullPointerException: Attempt to de-reference a null object 
Stack Trace: Class.TestAutoConvertLead.createnewlead: line 13, column 1


Any help, or a nudge in the right direction would be appreciated.  

Thanks, 
Jess 
The Contact URL field would be read only I believe, but I still want to be able to click the URL in the Contact Page and have it bring me to that URL. 
The Contact object already has two lookup fields to User: Created By and Owner. I would like to add a third that will be used to indicate responsibility for for marketing activities.  In other words, a Contact will be owned by someone - someone who is a field based salesperson - yet will have someone who is assigned from the Inside Sales team to communicate with the Contact for other issues. Looks like I am unable to do that because adding the lookup would be a third lookup to the User object.

I can use a junction object but that will make things significantly more complicated. Does anyone have a workaround or idea to make this work? Am I missing something?
Pretty new to writing test classes, was looking for help for this trigger:

trigger SumPositions on Investor__c (before insert, before update, before delete) {
    for (Investor__c record : Trigger.new) {
        record.Sum_of_Positions__c = null;
    }
    for(AggregateResult result: [SELECT SEI_Investor_Id__c, SUM(Position__c.Balance__c)
                                 FROM Position__c WHERE SEI_Investor_Id__c
                                 IN :Trigger.newMap.keyset() GROUP BY SEI_Investor_Id__c]) {
         Trigger.newMap.get(result.get('SEI_Investor_Id__c')).Sum_of_Positions__c = (Decimal)result.get('expr0');
     }
 }
I have a custom agreement object that is associated to a custom order object which shows up as a related list on the agreement. 

I would like to write a line of apex code that: upon save ie before update of the agreement , check the order related list, and if there is more than one order in it, then, throw an error asking the user to remove all other oder records, except for the latest one.

Only allow the user to save the record after this action is taken

Any ideas on how I can write this line of code?
I am trying to solve the challenge to create a field on Contract called Days Remaining and use formula editor to calculate the days left for the contract to end. The formula I am trying is:
EndDate - TODAY()

I get the following error when on Check Syntax: Error: Field EndDate may not be used in this type of formula

Can you help me on what is incorrect here?
I am trying to write a trigger that will add points to a custom field within Leads based on the subject and created by id of a task.  These points would need to accumulate on top of each other over time.  I am completely new to writing triggers and am looking for any recommendations or starting points.
Hi,
Based off new GDPR rules in EU, we need to anonymise the contact and Lead personal details. Salesforce provides obfuscateUser() to anonymize the User data.
Is there an equivalent process available to anonymise th Contact and Lead personal details. Or should we implement a custom logic for the same.
Will Shield Platform Encryption, encrypt [anonymise] the data for all users in Salesforce and for third party.
Also what would be the impact of enabling the 'Data Protection and Privacy', from Setup =>Search.

Kind regards,
Rohini
Does anyone have experience writing Update() code on the Campaign Member object to update the Status field using SOAP API in PHP? We’re stumped how to do this. Seems there are some limitations with using Upsert() function on the Campaign Member and wonder if there is a way to at least use an update() call. Ours may just be a syntax issue.

This is the code we’re trying to use:
if ($campaign_member_id) {
$mainResp = $mySFConnection->update($mainCM, 'CampaignMember');
//$mainResp = $mySFConnection->upsert('Id', $mainCM, 'CampaignMember');
echo "*** Campaign Member ID exists *** ";
var_dump($mainCM);
} else {
$mainResp = $mySFConnection->create($mainCM, 'CampaignMember');
echo "*** No Campaign Member ID *** ";
var_dump($mainCM);
}
Create a new link on the contact row to delete the contact from the account. On clicking the link, the contact should be deleted this time using VisualForce Remoting. On successful deletion, an alert should be displayed on the page stating “The contact has been deleted”.
  • August 04, 2018
  • Like
  • 1
The Contact URL field would be read only I believe, but I still want to be able to click the URL in the Contact Page and have it bring me to that URL. 
The Contact object already has two lookup fields to User: Created By and Owner. I would like to add a third that will be used to indicate responsibility for for marketing activities.  In other words, a Contact will be owned by someone - someone who is a field based salesperson - yet will have someone who is assigned from the Inside Sales team to communicate with the Contact for other issues. Looks like I am unable to do that because adding the lookup would be a third lookup to the User object.

I can use a junction object but that will make things significantly more complicated. Does anyone have a workaround or idea to make this work? Am I missing something?
Pretty new to writing test classes, was looking for help for this trigger:

trigger SumPositions on Investor__c (before insert, before update, before delete) {
    for (Investor__c record : Trigger.new) {
        record.Sum_of_Positions__c = null;
    }
    for(AggregateResult result: [SELECT SEI_Investor_Id__c, SUM(Position__c.Balance__c)
                                 FROM Position__c WHERE SEI_Investor_Id__c
                                 IN :Trigger.newMap.keyset() GROUP BY SEI_Investor_Id__c]) {
         Trigger.newMap.get(result.get('SEI_Investor_Id__c')).Sum_of_Positions__c = (Decimal)result.get('expr0');
     }
 }
I have a custom agreement object that is associated to a custom order object which shows up as a related list on the agreement. 

I would like to write a line of apex code that: upon save ie before update of the agreement , check the order related list, and if there is more than one order in it, then, throw an error asking the user to remove all other oder records, except for the latest one.

Only allow the user to save the record after this action is taken

Any ideas on how I can write this line of code?
I am trying to solve the challenge to create a field on Contract called Days Remaining and use formula editor to calculate the days left for the contract to end. The formula I am trying is:
EndDate - TODAY()

I get the following error when on Check Syntax: Error: Field EndDate may not be used in this type of formula

Can you help me on what is incorrect here?
I am trying to write a trigger that will add points to a custom field within Leads based on the subject and created by id of a task.  These points would need to accumulate on top of each other over time.  I am completely new to writing triggers and am looking for any recommendations or starting points.
Hi,

I am building a public site with multiple pages. I need to pass some parameters on each page so that I can use those parameters in my SOQL queries and display more information in next pages. 
I can do it by passing parameter via URL, but I don't think that is a secured way of doing it. 

Can somebody suggest me if there is any other way of passing some values from one controller to another without using URL?