• Gabriel C Ferreira
  • NEWBIE
  • 135 Points
  • Member since 2019
  • Consultant / Developer

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 26
    Replies

Hello all,

I have very simple trigger that loads a custom field  NewLead.NetNewLead__c=TRUE when a Lead is Cloned.

trigger Load_Cloned_NetNewLead_Trigger on Lead (before update) {
    for (Lead NewLead : Trigger.new) {
        if (NewLead.isClone() ){
          NewLead.NetNewLead__c=TRUE;
        }
    }
}

 

I am unable to write a test class to meet code coverage requirement. How do I simulate a Cloned Lead?

Thanks for your help.

 

@isTest
private class Load_Cloned_NetNewLead_TriggerTest {

static testMethod void testEx(){
        
Test.startTest();
        
 Account a = new Account(
 Name ='test 1', Industry='Academia', SI_Type__c='Prospect',           BillingCountry='United States');
 insert a; 
     Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Business_Contact').getRecordTypeId();
 

//CREATE CONTACT      
 Contact c=new Contact(
  FirstName='fname',recordtypeid ='0121A0000007rgsQAA',
  LastName = 'lname', accountid = a.Id , 
  Email = 'Test_002.email@gmail.com',
  Clinical_Services__c = True,
  Phone = '9743800309'); 
  insert c; 
 

//CREATE 1ST LEAD                  
Lead l = new Lead(FirstName='FirstName-Test1', LastName='LastName-Test1', Company='Company-Test1', Status='Untouched' , Email='Test_001.email@gmail.com', Industry='Academia' ,LeadSource='Advertising(Online)', Almac_Division__c='CS', NetNewLead__c=TRUE );
insert l ;

//CREATE 2ND LEAD        
Lead l1 = new Lead(FirstName='FirstName-Test2', LastName='LastName-Test2', Company='Company-Test2', Status='Untouched', Email='Test_002.email@gmail.com', Industry='Academia' ,LeadSource='Advertising(Online)', Almac_Division__c='CS', NetNewLead__c=FALSE );
insert l1 ;
    
//ATTEMPT TO CLONE LEAD???       
l1.FirstName='FirstName-Test3';
l1.LastName='LastName-Test3';
l1.Company='Company-Test3';
l1.Status='Untouched';
update l1 ;
System.assertEquals(true, l1.isClone());
        
Test.stopTest();
    }
    }

 

 

I have a large existing metadata from an org which we want to convert it to SF DX project. So far we have successfully converted the metadata from an existing org to the SF DX Project structure .

When i push the code to Scratch Org I am getting tons of issues and a lot of them are pointing to enabling Account & Opportunity Team Settings as shown below.
AccountTeamMember error in scratch org.

If i manually enable this in Scratch Org and push the code thereafter it works fine. However my goal is to automate these with Continous Integration where we will be creating the Scratch Org on the fly and pushing the existing metadata to it.
 
All,

I'm stumped and reaching out to the community.

I'm trying to create a formula that will display a date based on TODAY().  Here are the criterias:
  • If TODAY() is between January 1 and April 30, set the date to TODAY() + 15 days of the CURRENT year
  • If TODAY() is between May 1 and December 31, set the date to February 1 of NEXT year
Any pointers are appreciated!
I want to make a checkbox ticked automatically if field “Days since last acctivity” is greater than 7 and field “Visit Frequency” is is set to weekly. Please note “days since last activity “ field is formula field with date and “Visit Frequency “ field is a picklist. 

Hello all,

I have very simple trigger that loads a custom field  NewLead.NetNewLead__c=TRUE when a Lead is Cloned.

trigger Load_Cloned_NetNewLead_Trigger on Lead (before update) {
    for (Lead NewLead : Trigger.new) {
        if (NewLead.isClone() ){
          NewLead.NetNewLead__c=TRUE;
        }
    }
}

 

I am unable to write a test class to meet code coverage requirement. How do I simulate a Cloned Lead?

Thanks for your help.

 

@isTest
private class Load_Cloned_NetNewLead_TriggerTest {

static testMethod void testEx(){
        
Test.startTest();
        
 Account a = new Account(
 Name ='test 1', Industry='Academia', SI_Type__c='Prospect',           BillingCountry='United States');
 insert a; 
     Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Business_Contact').getRecordTypeId();
 

//CREATE CONTACT      
 Contact c=new Contact(
  FirstName='fname',recordtypeid ='0121A0000007rgsQAA',
  LastName = 'lname', accountid = a.Id , 
  Email = 'Test_002.email@gmail.com',
  Clinical_Services__c = True,
  Phone = '9743800309'); 
  insert c; 
 

//CREATE 1ST LEAD                  
Lead l = new Lead(FirstName='FirstName-Test1', LastName='LastName-Test1', Company='Company-Test1', Status='Untouched' , Email='Test_001.email@gmail.com', Industry='Academia' ,LeadSource='Advertising(Online)', Almac_Division__c='CS', NetNewLead__c=TRUE );
insert l ;

//CREATE 2ND LEAD        
Lead l1 = new Lead(FirstName='FirstName-Test2', LastName='LastName-Test2', Company='Company-Test2', Status='Untouched', Email='Test_002.email@gmail.com', Industry='Academia' ,LeadSource='Advertising(Online)', Almac_Division__c='CS', NetNewLead__c=FALSE );
insert l1 ;
    
//ATTEMPT TO CLONE LEAD???       
l1.FirstName='FirstName-Test3';
l1.LastName='LastName-Test3';
l1.Company='Company-Test3';
l1.Status='Untouched';
update l1 ;
System.assertEquals(true, l1.isClone());
        
Test.stopTest();
    }
    }

 

 

Hello everyone! I am trying to create a Rich text Field using VF Page where I can use conditions for checkboxes to retreive the values of text fields from "Case" standard object and populate it in the Rich Text Field area by using a custom action button. I am not experienced in Apex coding therefore seeking out for help in correcting my codes.

VF Page: 

<apex:page standardController="Case" extensions="textEditorcontroller" action="{!getautopopulatevalue}" >
    <apex:form >
    <apex:outputPanel style="padding:50px 50px 50px 50px" id="userDetail">
    <apex:outputText rendered="true">
    <div style="color:black;font-size: 15px;font-weight: bold;align-content: center;margin-top: 10px; margin-left: 10px">
    
  
     </div>
     </apex:outputText>
     <apex:pageBlock >
       <apex:pageBlockTable value="{!Case}" var="CS"> 
       
       </apex:pageBlockTable>
      </apex:pageBlock>
     
       
       
  <div style = "margin-left: 20px; margin-top: 10px">
    <apex:commandButton id="AddProofs" value="AddProofs" action="{!getautopopulatevalue}" />
   
    </div>
    <!--<div style = "margin-left: 10px; margin-top: 10px">-->
    
    
    <apex:inputTextarea id="Richtextarea" richText="true" value="{!Allproofs}"/>
   
 
  </apex:outputPanel>
  </apex:form>
    
</apex:page>

APEX Controller:

public class textEditorcontroller{

    
    public Case cs{get;set;}
    public List<Case> Allproofs{get;set;}
    public List<Case> csValue {get;set;}
    public textEditorController (Apexpages.StandardController stdController){
 
    
    this.cs = (Case)stdController.getrecord();
    }
    
    
    public void getautopopulatevalue(){
    
    
                    
               csValue = ([SELECT Document_1__c,Document_1_Comments__c FROM Case 
                                        WHERE Case.Id = :cs.Id]);
                       
                    Allproofs = csValue;
                         
                         
                        
                   }
    
     
      }


Thanks

Help me with my Save function, please?

Component

<aura:component controller="MyCustomSettingsController">
	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
	<aura:attribute name="CustSettings" type="MyCustomSettings__c"/>
	<div class="divform">
		<form>
			<table>
				<tbody>
					<tr>
						<td>
							<span class="slds-text-heading--small">Client Key</span>
							<lightning:input type="text" aura:id="clientKey"
											 name="client"
											 value="{!v.CustSettings.Client_Key__c}"/>
						</td>
						<td>
							<span class="slds-text-heading--small">Secret Key</span>
							<lightning:input type="text" aura:id="secretKey"
											 name="secret"
											 value="{!v.CustSettings.Secret_Key__c}"/>
						</td>
					</tr>
				</tbody>
			</table>
			<div class="slds-grid">
				<lightning:button aura:id="save"
								  label="Save"
								  class="slds-m-top--medium"
								  variant="brand"
								  onclick="{!c.btnSave}"/>
			</div>
		</form>
	</div>
</aura:component>

JS Controller

({
	doInit : function(component, event, helper) {
		var action = component.get("c.getCustomSettings");
		action.setCallback(this, function(response) {
			var state = response.getState();
			console.log(state);
			if (state === "SUCCESS") {
				var returnVal = response.getReturnValue();
				component.set("v.CustSettings", returnVal);
			}
		});
		$A.enqueueAction(action);
	},
 
	btnSave : function(component, event, helper) {
        var CustSettings = component.get("v.CustSettings");
		var action = component.get("c.saveCustSettings");
        action.setParams({"Cust_setting" : CustSettings});
        action.setCallback(this,function(response){
			var status = response.getState();
            if(status === "SUCCESS"){
				var msg = 'Changes saved!';
                var toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    title	: "Success!",
                    mode	: 'pester',
                    duration: '3000',
                    message	: msg,
                    type	: 'success'
                });
                toastEvent.fire();
			}
		});
		$A.enqueueAction(action);
    }
})
Apex controller
public with sharing class MyCustomSettingsController {
	@AuraEnabled
    public static MyCustomSettings__c getCustomSettings() {
       MyCustomSettings__c query = [SELECT Id, Client_Key__c, Secret_Key__c
                FROM MyCustomSettings__c];
        return query;
    }
    @AuraEnabled
    public static void saveCustSettings(MyCustomSettings__c Cust_setting){
        
        MyCustomSettings__c Custsetting = new MyCustomSettings__c();
        Custsetting = Cust_setting;
        update Custsetting;
    }
}

 
Hi All,
We have the following sharing settings:

Object  : Account, Contract and Asset
Default Internal Access: Public Read/Write
Default External Access: Private

Object  : Contact
Default Internal Access: Controlled by Parent
Default External Access: Controlled by Parent

We have Partner Communities and Accounts are shared via Sharing Rules to corresponding Contacts that belong to that Account.  Since Contacts are Controlled by Parent, we do not need sharing rules on Contact.
Now, we have introduced a criteria-based Sharing Rule that shares few Accounts with All Partner Users (these are community users).
Issue:  Since we share few Accounts with all Partner users, contacts associated to those Accounts are visible to all Partners users by default because Contact’s sharing is Controlled by Parent.
I am sure that we need to change the Default External access and create Sharing Sets / Sharing Rules to fix this issue but, I am trying to see if there are any other alternatives here.
Any help is highly appreciated.  


Thanks, 
Raghu
hi i am doing trailhead challenge "configure quote templates and quotes" and i am getting below error. 
I have chcked i have status as "In Review" and date as 3/31/2017 but i am not able to rename Quote name as " 'Diesel Generator and Installation for Edge', as this is auto number field. Any suggestion on how to rename Quote Name 
Could not find a Quote for the 'Edge Installation' opportunity with the name 'Diesel Generator and Installation for Edge', a status of 'In Review' and an expiration date of '3/31/2017'.
  • May 17, 2019
  • Like
  • 0
I have a large existing metadata from an org which we want to convert it to SF DX project. So far we have successfully converted the metadata from an existing org to the SF DX Project structure .

When i push the code to Scratch Org I am getting tons of issues and a lot of them are pointing to enabling Account & Opportunity Team Settings as shown below.
AccountTeamMember error in scratch org.

If i manually enable this in Scratch Org and push the code thereafter it works fine. However my goal is to automate these with Continous Integration where we will be creating the Scratch Org on the fly and pushing the existing metadata to it.
 
How to get the list of unused apex classes, triggers and visualforce pages
Hi,

I've implemented queueable apex on 2 chained classes: class a and class b. 

In Class A, when the class 2 gets invoked a list gets also passed into class b.

while the test cflass for class a is fine, I am unable to get coverage for class 2. 

Any ideas about how to write the test class for this scenario?
 
public class classA implements Queueable, Database.AllowsCallouts {

    
    public void execute(QueueableContext context) {

do something...

List<id> myList;

System.enqueueJob(new blassB(myList);

....

 
Hi all,

We created a visual force page (screen shot attached) to facilitate community guest user to create a case. But, we are not able to create a case by clicking 'Contact Us' button on this page.

The case creation through this VF page is working fine internally in sandbox but not from Community.


<apex:page standardController="Case" extensions="CaseCreation" >
    <style>
        body  .big_btn{background: rgb(228, 0, 70);border:1px solid rgb(228, 0, 70) !important;transition: all 0.5s;color: #fff;padding: 22px 30px;border: none;font-size: 14px;text-transform: uppercase;letter-spacing: 1px; }
        body  .big_btn:hover{background:#fff;color: rgb(228, 0, 70);border:1px solid #ccc  !important;}
        table.list {
    border-width: 0 !important;
}
tr.dataRow.last td {
    border-bottom-width: 0 !important;
}
        }
.brandQuaternaryBgr {
    background: #FFF !important;
}
    </style>
    <apex:form >

        <apex:pageBlock >
 
             <apex:pageBlockButtons  location="bottom" >
              <apex:commandButton value="Contact Us" styleClass="big_btn" action="{!save}" />
              </apex:pageBlockButtons> 
            <div style="text-align:center;font-size:18px;">
               <apex:outputText value="Can't find what you're looking for" /> 
           </div>
            <div style="text-align:center;font-size:13px;">
               <apex:outputText value="Contact customer support using the form below" /> 
           </div>
           
            
           <apex:pageBlockSection columns="1"  >
               <div >
               <apex:inputField label="E-Mail" value="{!CaseObject.E_Mail__c}" style="font-size:13px; width:100%;line-height:30px;border:none" required="true"/>
 </div>
               <apex:inputField label="First Name" value="{!CaseObject.First_Name__c}" style="font-size:13px; width:100%;line-height:30px;border:none"  required="true"/>
               <apex:inputField label="Last Name" value="{!CaseObject.Last_Name__c}" style="font-size:13px; width:100%;line-height:30px;border:none"  required="true"/>
               <apex:inputField label="Reason For Contacting Us" value="{!CaseObject.Type}" style="font-size:13px; width:100%;line-height:30px;border:none"  required="true"/>
               <apex:inputField label="Symptom" value="{!CaseObject.Symptom__c}" style="font-size:13px; width:100%;line-height:30px;border:none"  required="true"/>
               <apex:inputField label="Brief Description" value="{!CaseObject.Description}" style="font-size:13px; width:100%;line-height:30px;border:none"  required="true" />
               

               
                                                                           
               
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


Please help us.
I am trying to write a soql quey that is very similar to a summary report. I unsure but I believe that I need to group clause in the query.
This is the result that I am trying to achieveUser-added image

every field on this table is from the same object. I need to group by download_cycle__c and portal_name__c.
here is what I have been written but i cant get the desired result. I have not even attempted to write the lightning component table for it.
select count(Download_Cycle__c), Name, Last_Download__c, Portal_Name__c, count(Portal_URL__c), Password__c, Login__c, Count(Bill_Cycle__c), Location_Address__c, Location_Name__c from vendor_Invoice__c group by Name, Last_Download__c, Portal_Name__c, Password__c, Login__c, Location_Address__c, Location_Name__c


Thanks for the help in advance
Hi,

I have created a visualforce page as per the requirement in my team and that looks like below image.
I am able to see only 20 rows in this table, whereas the original list view contains more than 1000 records.
I am on group edition on salesforce. 
My requirement :

1. I need to have all the 1000+ rows displayed on the same page, I just want to scroll down to see them all. (Right now in the imkage page I see a limit of only 20 rows, I want the same page to display all the rows)
2. i have implemented pagination after looking at few forums, The prev and next buttons that you see in the image. However clicking on any of them throws the error "Modified rows exist in the records collection! "

Please help me implement 1 , if not atleast 2 should be in working condition.

Thanks,
Haritha
User-added image
Hi All,

I have a lightning component on a stanalone app which is a input form for creating a new record. But somehow it is not saving the record as expected.

component:
<aura:component controller="CreateCarRecord" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="newCar" type="Car__c"
     default="{ 'sobjectType': 'Car__c',
                     'Name': '',
                     'Build_Year__c': '',
                     'Mileage__c': '',
                      'Available_For_Rent__c': '',
                   }"/>

    
    
        <lightning:layout>
            <lightning:layoutItem size="4" padding="around-small">
              <lightning:input aura:id="carField" type="text" value="{!v.newCar.Name}" Name="Name" label ="Car Name"/>
       <lightning:input aura:id="carField" type="number" name="Build Year" label="Build Year"  value="{!v.newCar.Build_Year__c}" />
                 <lightning:input aura:id="carField" type="number"  value="{!v.newCar.Mileage__c}"  Name="Mileage" label="Mileage"/>
        <lightning:input aura:id="carField" type="checkbox"  value="{!v.newCar.Available_For_Rent__c}"  Name="Available" label="Available"/>
        
        <lightning:button aura:id="carField" label="Save Car" onclick="{!c.saveCar}"/>
            </lightning:layoutItem>
            </lightning:layout>
</aura:component>

controller:
({
	saveCar :  function(component, event) {
    var newAcc = component.get("v.newCar");
    var action = component.get("c.save");
    action.setParams({ 
        "con": newAcc
    });
    action.setCallback(this, function(a) {
           var state = a.getState();
        console.log("state--" +state);
            if (state === "SUCCESS") {
                var name = a.getReturnValue();
               alert("hello from here"+name);
            }else{
                alert("nothing");
            }
        });
    $A.enqueueAction(action)
}
})

Apex:
public class CreateCarRecord {

  
    @AuraEnabled
    public static Car__c save(Car__c con)
    {
     insert con;
        return con;
    }
}

​​​​​​​​​​​​​​
All,

I'm stumped and reaching out to the community.

I'm trying to create a formula that will display a date based on TODAY().  Here are the criterias:
  • If TODAY() is between January 1 and April 30, set the date to TODAY() + 15 days of the CURRENT year
  • If TODAY() is between May 1 and December 31, set the date to February 1 of NEXT year
Any pointers are appreciated!
Hello everyone!

I've been thinking about how to prevent account creation by using profile and recordtype. In the object Account I have two recordtypes: "Example 1" and "Example 2". In my ORG there are 2 profiles such as "System Administrator" and also "Customer Service" .What I need to do is basically:

-  If I'm logged in with profile  "System Administrator" or "Customer Service" I'm allowed to create an account "Example 1" or "Example 2"(recordtype) on Salesforce. 

Thank you guys in advance. Have a good one.