• Amarpreet
  • NEWBIE
  • 225 Points
  • Member since 2019

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 23
    Replies

We have several brands being worked within one Salesforce org by using a multi-picklist field called “Brand Connect” to keep it all separated and organized.

We have 2 custom fields, called “The Appointment Setter” and “The Appointment Setter ID”. These are used to reference a User ID and there is automation running so whenever The Appointment Setter is input, their persons associated User ID is populated in The Appointment Setter ID.

For our email automation we have Process Builder calling Apex. It was designed to use The Appointment Setter ID to set the correlated “Sender ID” for the email, and it pulls in email signature data from custom fields on the User object that are set up for each brand (so tagline and email address can be set uniquely for each brand).
 

The problem is that the developer we worked with only set it up for one brand, and we need it to work for all the brands in our org.

Here's the email template:

User-added image

To support this we have a visualforce component called "SenderSignature" -- Here we need some sort of If/Else statements at the end to reference the custom field called "Brand_Connect__c" ...

1. Company should be the value of Brand Connect
2. For Sig_Tagline and Sig_Email, we have custom fields on the User object for each individual brand. What we want to do is define the references for each brand. So “if Brand Connect = Advisor Fuel then use Sig AF Tagline” and “if Brand Connect = DB Lightning then use Sig DB Email”.
 

<apex:component controller="SenderSignatureCtrl" access="global">
   <apex:attribute name="company" description="name of company" type="string"/>
   <apex:attribute name="senderId" description="Id of sender" type="String" required="required" assignTo="{!appSetterId}" />
   <p>{!Sender.Sig_Tagline__c}</p>
   <p>{!Sender.Sig_Name__c}</p>
   <p>
       {!company}
       <br/>
       {!Sender.Sig_AF_Title__c}
       <br/>
       {!Sender.Phone}
       <br/>
       {!Sender.Sig_AF_Email__c}
   </p>
</apex:component>
 

and here's the apex class "SenderSignatureCtrl"
 

public class SenderSignatureCtrl {
   public String appSetterId { get; set; }
   public User sender {
       get {
           if (appSetterId != null) {
               sender = [SELECT Sig_Tagline__c, Sig_Name__c, CompanyName, Sig_AF_Title__c, Phone, Sig_AF_Email__c FROM User WHERE Id = :appSetterId];
               system.debug('Sender Signature ==> ' + sender);
           }
           return sender;
       }
       set;
   }
}


 

I'm happy to provide any additional information that may be necessary to troubleshoot the problem. Thank you so much to whoever is willing to help!

Hi Guys
   I am new to coding and i need your help. My task is to create a trigger which will allow to move the opportunity stage from qualification to estimation only if the record has an attachment. I found a trigger for this but i need a test class.

Apex Trigger
trigger AttachmentTrigger on Opportunity (before update) {
    
    
    for(Opportunity o:Trigger.New) {
        if(o.stagename == 'Estimating') {
            
            Attachment a = new Attachment();
            try {
               a = [Select Id, Name from Attachment where ParentId =:o.Id];
            }
            catch(Exception e) {
               a = null;
            }
            
            if (a == null)
               o.addError('Add an attachment before you change the Opportunity stage to Estimating');
        }
    }
}

Apex Class:
@isTest 
public class AttachmentTriggerTest {
    static testMethod void testMethod1(){
        Opportunity opp = new Opportunity();
          
            opp.Name = 'Test Opportunity';
            opp.CloseDate = system.today();
            opp.StageName = 'Qualification';
            opp.Type = 'New Customer';
        insert opp;
        
        Attachment attach=new Attachment();       
         attach.Name='Unit Test Attachment';
         Blob bodyBlob = Blob.valueOf('Unit Test Attachment Body');
          attach.body = bodyBlob;
          attach.parentId = Opp.id;
        insert attach;
        
        }
}


i don't know why the apex class is not working. Iried deploy it in my production but it says 0% code coverage.
Trigger UpdateOwnerOfContact on Account(before update) {
 //Map to collect account id with changed owner id(user id ) .
 Map<Id,Id> accIdWithOwnerIdMap = new Map<Id,Id>();
 List<Contact> listOfContactsToUpdate = new List<Contact>();
 for(Account currentAccount : trigger.new) {
     if(currentAccount.OwnerId != Trigger.oldMap.get(currentAccount.Id).OwnerId){
        accIdWithOwnerIdMap.put(currentAccount.Id,currentAccount.OwnerId);
     }         
 }
 if(!accIdWithOwnerIdMap.isEmpty()){
  for(Contact con: [SELECT Id, OwnerId, AccountId FROM Contact 
                    WHERE AccountId IN :accIdWithOwnerIdMap.keySet() ]) {
   con.OwnerId = accIdWithOwnerIdMap.get(con.AccountId);
   listOfContactsToUpdate.add(con);
  }
 }
 if(!listOfContactsToUpdate.isEmpty()) {
  try{
   update listOfContactsToUpdate;
  }catch(DmlException de){
   System.debug(de);
  }
  
 }
}   
Hi All,

I have Lighting Form with 2 Field if the uses click on the add button then concatenate these two fields and show in the table

2
I am trying to do the following:
Call Apex from a Process or Flow (Invocable Method),
Make an HTTP Callout (can't do this from invocable method so using a queueable class)

I have been using these examples to write the code related to invocable variables:
1. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableVariable.htm
2. https://developer.salesforce.com/forums/?id=9060G0000005nusQAA

Here is what I have:
public class EnqueueCallout {

    @InvocableMethod(label='Enroll in XYZ Program' )
    public static void queueCallout(List<FlowInputs> calloutvars) {
        string card = calloutvars.cardnum;
        string offer = calloutvars.offerid;
//this calls the queueable class and sends the variables...this part works fine when using the execute command in the execute anonymous apex window.
        ID jobID = System.enqueueJob(new SendCallout(card, offer));
    }
    //input details that come into apex from flow
    public class FlowInputs {
        @InvocableVariable(required=true)
        public string cardnum;
        
        @InvocableVariable(required=true)
        public string offerid;
    }
}

but I am getting the error "Error: Compile Error: Variable does not exist: cardnum at line 5 column 35"
  • September 18, 2019
  • Like
  • 0
Hi Team,

This Is Balaji .I am new to apex development.I Have one scneario here

I am trying to get list of user for task assignment by datewise.Please find the below code for reference.

public class allUser{
    Public Static List<String> GetUserListForTaskAssignmentNew(List<String> allUser){
List<String> UserId = new List<String>();
    List<User> assignUserList=new List<User>();
    String User = null;
        List<User> = [SELECT ownerId, count(Type) from Task where createdDate<=Today group By ownerID];
        {
          if(allUser.size() > 0)
        }
    }
}

While writing in query i am getting only who has done task but i need how has done task aswell not done task.

these are the error i am getting:
Unexpected token 'List'.
Missing return statement required return type: List<String>

thank you inadvance.please help me
Hello, fairly new to Visualforce. I'm trying to create a Visualforce page to replace the default create new opportunity page. The code I used came from a similar new account page which is working. I'm seeing no warrnings in the developer console and the page displays fine, but when I click the save button, no record is created and when I click the cancel button, it flags required fields as needing to be filled out to move forward. Can someone tell me where I'm going wrong? Thank you! 
 
<apex:page standardController="Opportunity" lightningStylesheets="TRUE" showHeader="TRUE" docType="html-5.0">
    <apex:SectionHeader title="New Opportunity"> 
    	<apex:form >
        	<apex:pageBlock title="Add Opportunity"  mode="edit">
          		<apex:pageBlockButtons >
            		<apex:commandButton action="{!save}" value="Save"/>
            		<apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>
       			</apex:pageBlockButtons> 
                <apex:pageBlockSection >
                    <apex:inputField value="{!Opportunity.Name}" />
                    <apex:inputField value="{!Opportunity.AccountId}" />
                    <apex:inputField value="{!Opportunity.Stagename}" /> 
                    <apex:inputField type="date" showDatePicker="TRUE" value="{!Opportunity.CloseDate}" required="TRUE" /> 
                    <apex:inputField type="date" showDatePicker="TRUE" value="{!Opportunity.Project_Launch_Date__c}" required="TRUE" /> 
                    <apex:inputField value="{!Opportunity.Broker_Account__c}" />
                    <apex:inputField value="{!Opportunity.Broker_Contact__c}" /> 
                </apex:pageBlockSection>
            </apex:pageBlock>
    	</apex:form>
    </apex:SectionHeader>
</apex:page>

Screenshot

Hello All,

Has anyone created a VF page to replace the standard page with Salesforce Promotions (https://c.salesforce.com/login-messages/promos.html) content of the right side of the login page? I want to replace the Salesforce Promotions with something more pertinient to my company.

I think many would like to do the same? Can someone point me in the right direction? Any suggestions?

Thanks,

Robert

 

 

We have several brands being worked within one Salesforce org by using a multi-picklist field called “Brand Connect” to keep it all separated and organized.

We have 2 custom fields, called “The Appointment Setter” and “The Appointment Setter ID”. These are used to reference a User ID and there is automation running so whenever The Appointment Setter is input, their persons associated User ID is populated in The Appointment Setter ID.

For our email automation we have Process Builder calling Apex. It was designed to use The Appointment Setter ID to set the correlated “Sender ID” for the email, and it pulls in email signature data from custom fields on the User object that are set up for each brand (so tagline and email address can be set uniquely for each brand).
 

The problem is that the developer we worked with only set it up for one brand, and we need it to work for all the brands in our org.

Here's the email template:

User-added image

To support this we have a visualforce component called "SenderSignature" -- Here we need some sort of If/Else statements at the end to reference the custom field called "Brand_Connect__c" ...

1. Company should be the value of Brand Connect
2. For Sig_Tagline and Sig_Email, we have custom fields on the User object for each individual brand. What we want to do is define the references for each brand. So “if Brand Connect = Advisor Fuel then use Sig AF Tagline” and “if Brand Connect = DB Lightning then use Sig DB Email”.
 

<apex:component controller="SenderSignatureCtrl" access="global">
   <apex:attribute name="company" description="name of company" type="string"/>
   <apex:attribute name="senderId" description="Id of sender" type="String" required="required" assignTo="{!appSetterId}" />
   <p>{!Sender.Sig_Tagline__c}</p>
   <p>{!Sender.Sig_Name__c}</p>
   <p>
       {!company}
       <br/>
       {!Sender.Sig_AF_Title__c}
       <br/>
       {!Sender.Phone}
       <br/>
       {!Sender.Sig_AF_Email__c}
   </p>
</apex:component>
 

and here's the apex class "SenderSignatureCtrl"
 

public class SenderSignatureCtrl {
   public String appSetterId { get; set; }
   public User sender {
       get {
           if (appSetterId != null) {
               sender = [SELECT Sig_Tagline__c, Sig_Name__c, CompanyName, Sig_AF_Title__c, Phone, Sig_AF_Email__c FROM User WHERE Id = :appSetterId];
               system.debug('Sender Signature ==> ' + sender);
           }
           return sender;
       }
       set;
   }
}


 

I'm happy to provide any additional information that may be necessary to troubleshoot the problem. Thank you so much to whoever is willing to help!

Hi Guys
   I am new to coding and i need your help. My task is to create a trigger which will allow to move the opportunity stage from qualification to estimation only if the record has an attachment. I found a trigger for this but i need a test class.

Apex Trigger
trigger AttachmentTrigger on Opportunity (before update) {
    
    
    for(Opportunity o:Trigger.New) {
        if(o.stagename == 'Estimating') {
            
            Attachment a = new Attachment();
            try {
               a = [Select Id, Name from Attachment where ParentId =:o.Id];
            }
            catch(Exception e) {
               a = null;
            }
            
            if (a == null)
               o.addError('Add an attachment before you change the Opportunity stage to Estimating');
        }
    }
}

Apex Class:
@isTest 
public class AttachmentTriggerTest {
    static testMethod void testMethod1(){
        Opportunity opp = new Opportunity();
          
            opp.Name = 'Test Opportunity';
            opp.CloseDate = system.today();
            opp.StageName = 'Qualification';
            opp.Type = 'New Customer';
        insert opp;
        
        Attachment attach=new Attachment();       
         attach.Name='Unit Test Attachment';
         Blob bodyBlob = Blob.valueOf('Unit Test Attachment Body');
          attach.body = bodyBlob;
          attach.parentId = Opp.id;
        insert attach;
        
        }
}


i don't know why the apex class is not working. Iried deploy it in my production but it says 0% code coverage.
Hello!
There is a process in my client's daily routine which requires the possibilty to modify the RelatedToId from an Email Message to change the related Case. ¿Is there a way of achieving this? ¿How would a possible trigger be like?

Thank in advanced.
Trigger UpdateOwnerOfContact on Account(before update) {
 //Map to collect account id with changed owner id(user id ) .
 Map<Id,Id> accIdWithOwnerIdMap = new Map<Id,Id>();
 List<Contact> listOfContactsToUpdate = new List<Contact>();
 for(Account currentAccount : trigger.new) {
     if(currentAccount.OwnerId != Trigger.oldMap.get(currentAccount.Id).OwnerId){
        accIdWithOwnerIdMap.put(currentAccount.Id,currentAccount.OwnerId);
     }         
 }
 if(!accIdWithOwnerIdMap.isEmpty()){
  for(Contact con: [SELECT Id, OwnerId, AccountId FROM Contact 
                    WHERE AccountId IN :accIdWithOwnerIdMap.keySet() ]) {
   con.OwnerId = accIdWithOwnerIdMap.get(con.AccountId);
   listOfContactsToUpdate.add(con);
  }
 }
 if(!listOfContactsToUpdate.isEmpty()) {
  try{
   update listOfContactsToUpdate;
  }catch(DmlException de){
   System.debug(de);
  }
  
 }
}   

Hi 

Greetings of the day!!!

I create a country picklist into contact object in Sales app and i want to use it into lightning component to select a country from the <select> in the form,

I am not getting, how I can call a picklist into a lightning component from.

<lightning:select aura:id="NewCon" label="Course" name="NewCon" type="String" value="{!v.NewCon.CourseCategory__c}" required="true"/>

Hi,

My goal is to be able to delete records in Salesforce, as part of a Process Builder.
As I don't know how to work with Flows I went online and followed this Apex method: https://automationchampion.com/tag/call-an-apex-from-process/

Custom Object: Exec_Ed_Opportunity__c
Related: Events

I want to be able to delete Exec Ed Opportunity related Events based on a field criteria.


Can you help me to build the Apex Class? I get errors when I try.

Thanks,
Alexandros
Hi All,

I have Lighting Form with 2 Field if the uses click on the add button then concatenate these two fields and show in the table

2
I am trying to create a lightning component that pulls some contacts from my salesforce. 

Here is the HTML
<template for:each={examiners.data} for:item='examiner'>
    <tr key={examiner.Id}>
        <th>{examiner.Name}</th>
        <th>{examiner.Title}</th> 
        <th>{examiner.Account.Name</th>
    </tr>
</template>

Here is the javascript
 
import { LightningElement, wire } from 'lwc';
import getSiteExaminers from '@salesforce/apex/Dynamic_Pages.getSiteExaminers';

export default class SiteExaminers extends LightningElement {

    @wire(getSiteExaminers) examiners;
}

and the error I am getting is: This page has an error. You might just need to refresh it. afterRender threw an error in 'c:siteExaminers_v2' [Cannot read property 'Name' of undefined] Failing descriptor: {c:siteExaminers}
I am trying to do the following:
Call Apex from a Process or Flow (Invocable Method),
Make an HTTP Callout (can't do this from invocable method so using a queueable class)

I have been using these examples to write the code related to invocable variables:
1. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableVariable.htm
2. https://developer.salesforce.com/forums/?id=9060G0000005nusQAA

Here is what I have:
public class EnqueueCallout {

    @InvocableMethod(label='Enroll in XYZ Program' )
    public static void queueCallout(List<FlowInputs> calloutvars) {
        string card = calloutvars.cardnum;
        string offer = calloutvars.offerid;
//this calls the queueable class and sends the variables...this part works fine when using the execute command in the execute anonymous apex window.
        ID jobID = System.enqueueJob(new SendCallout(card, offer));
    }
    //input details that come into apex from flow
    public class FlowInputs {
        @InvocableVariable(required=true)
        public string cardnum;
        
        @InvocableVariable(required=true)
        public string offerid;
    }
}

but I am getting the error "Error: Compile Error: Variable does not exist: cardnum at line 5 column 35"
  • September 18, 2019
  • Like
  • 0
Hi Team,

This Is Balaji .I am new to apex development.I Have one scneario here

I am trying to get list of user for task assignment by datewise.Please find the below code for reference.

public class allUser{
    Public Static List<String> GetUserListForTaskAssignmentNew(List<String> allUser){
List<String> UserId = new List<String>();
    List<User> assignUserList=new List<User>();
    String User = null;
        List<User> = [SELECT ownerId, count(Type) from Task where createdDate<=Today group By ownerID];
        {
          if(allUser.size() > 0)
        }
    }
}

While writing in query i am getting only who has done task but i need how has done task aswell not done task.

these are the error i am getting:
Unexpected token 'List'.
Missing return statement required return type: List<String>

thank you inadvance.please help me
Hello, fairly new to Visualforce. I'm trying to create a Visualforce page to replace the default create new opportunity page. The code I used came from a similar new account page which is working. I'm seeing no warrnings in the developer console and the page displays fine, but when I click the save button, no record is created and when I click the cancel button, it flags required fields as needing to be filled out to move forward. Can someone tell me where I'm going wrong? Thank you! 
 
<apex:page standardController="Opportunity" lightningStylesheets="TRUE" showHeader="TRUE" docType="html-5.0">
    <apex:SectionHeader title="New Opportunity"> 
    	<apex:form >
        	<apex:pageBlock title="Add Opportunity"  mode="edit">
          		<apex:pageBlockButtons >
            		<apex:commandButton action="{!save}" value="Save"/>
            		<apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>
       			</apex:pageBlockButtons> 
                <apex:pageBlockSection >
                    <apex:inputField value="{!Opportunity.Name}" />
                    <apex:inputField value="{!Opportunity.AccountId}" />
                    <apex:inputField value="{!Opportunity.Stagename}" /> 
                    <apex:inputField type="date" showDatePicker="TRUE" value="{!Opportunity.CloseDate}" required="TRUE" /> 
                    <apex:inputField type="date" showDatePicker="TRUE" value="{!Opportunity.Project_Launch_Date__c}" required="TRUE" /> 
                    <apex:inputField value="{!Opportunity.Broker_Account__c}" />
                    <apex:inputField value="{!Opportunity.Broker_Contact__c}" /> 
                </apex:pageBlockSection>
            </apex:pageBlock>
    	</apex:form>
    </apex:SectionHeader>
</apex:page>

Screenshot

Hello All,

Has anyone created a VF page to replace the standard page with Salesforce Promotions (https://c.salesforce.com/login-messages/promos.html) content of the right side of the login page? I want to replace the Salesforce Promotions with something more pertinient to my company.

I think many would like to do the same? Can someone point me in the right direction? Any suggestions?

Thanks,

Robert