• Shravan Kumar 71
  • NEWBIE
  • 160 Points
  • Member since 2017

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 36
    Replies
Hi! What I'm trying to do is pretty simple, but I'm not sure how to achieve it. On our Opportunity page, I'd like to show "Amount" in 2 places. I made a Formula field to pull the information from Amount using TEXT(Amount). I'm now seeing the number in both places, but it is displayed in the Amount field as "$824.00" and under the new field as "824". Is there anyway to pull this information into a new field and retain the currency format?
I am getting the error "'npm' is not recognised as an internal or external command" while creating project in VS code using Salesforce CLI. Don't know what I am missing out. Can anyone guide me.
I am looking for a solution where when I click on a button, the resulting page should open in the same window below the button. Below is my current VF page, right now the page is opening in a new tab.
 
<apex:page lightningStylesheets="true">
<style>
    body input.btn, body input.btnDisabled, body input.btnCancel {
    padding: 4px 3px;
    padding-left: 1rem;
    padding-right: 1rem;
    text-align: center;
    vertical-align: middle;
    justify-content: center;
    border: 1px solid #dddbda;
    transition: border .15s linear;
    background-color: #0070d2;
    border-color: #0070d2;
    /* color: #fff; */
    width: 300px;
    height: 35px;
    }
</style>

<apex:form target="_self" >

        <center>
            <apex:commandButton id="one" value="Lead Page" oncomplete="openDashboard(this.id);" />&nbsp;&nbsp;
            <apex:commandButton id="two" value="Account Page" oncomplete="openDashboard(this.id);"/> 
        </center>
        <br/>
</apex:form>

<script type="text/javascript">
function openDashboard(clicked_id) {
    if(clicked_id.includes('one')){
        window.open("Lead URL");
    }else if(clicked_id.includes('two')){
        window.open("Account URL");
    } 
}
</script>
<apex:page standardController="Order" extensions="orderPageLayoutController">    
    <apex:form id="fm">
<apex:pageBlock id="pbsk">	
            <apex:pageBlockSection title="Order Terms and Client POC Details" columns="2">
                <apex:pageblocksectionItem >
                    <apex:outputlabel value="Invoice Contact" />
                    <apex:actionRegion >
                        <apex:inputField value="{!Order.Invoice_Contact__c}" required="true">
                            <apex:actionSupport event="onchange" action="{!autoFillData}" reRender="conEmail,conPhone"/>   
                        </apex:inputField>
                    </apex:actionRegion>
                </apex:pageblocksectionItem>
                <apex:inputField value="{!Order.Invoice_Email__c}" id="conEmail"/>
                <apex:inputField value="{!Order.Invoice_Phone__c}" id="conPhone"/>
                <apex:repeat value="{!$ObjectType.Order.FieldSets.Contact_Name_and_Payment_Terms}" var="f">                             
                    <apex:inputField value="{!Order[f]}"  required="{!OR(f.required, f.dbrequired)}" />
                </apex:repeat>
            </apex:pageBlockSection>   
</apex:pageBlock>
</apex:form>			
            
    <!-- File Uplaod Section -->
    <apex:form enctype="multipart/form-data">
        <apex:pageBlock id="thePageBlock" >
            <apex:pageBlockSection title="Upload Related Files" columns="1">
                <apex:pageMessages />
            </apex:pageBlockSection>
            <apex:pageBlockSection showHeader="false" columns="1" id="block1">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="File Name" for="fileName"/>
                    <apex:inputField value="{!theConVer.title}" styleClass="slds-input slds-size_1-of-2"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="File" for="file"/>
                    <apex:inputFile value="{!theConVer.versionData}" fileName="{!fileName}" id="file" />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Document Type"/>
                    <apex:inputField value="{!theConVer.Document_Type__c}" styleClass="slds-listbox slds-input slds-size_1-of-2" required="true" />
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <input id="uploadButton" type="button" value="Upload file" name="uploadFile" onclick="uploadFileToTemp()" />			   
        </apex:pageBlock>
        <apex:actionFunction action="{!uploadFile}" name="uploadFile" reRender=""/>
    </apex:form> 
    
	<script type="text/javascript">
    function uploadFileToTemp(){
        document.getElementById ('uploadButton').disabled = true;
        uploadFile();    
    }
    </script>
	
</apex:page>

Hello,

Can anyone help me out to fix the rerender with apex:inputfile issue :

 
Component
<aura:if isTrue="{!v.leadRecord.Company!=null}">
            <div class="slds-form-element">
                <label class="slds-form-element__label" for="text-input-id-1">Company</label>
                <div class="slds-form-element__control">
                    <input type="text" aura:id="company" placeholder="" value="{!v.leadRecord.Company}" disabled="true" class="slds-input" />
                </div>
            </div>
            <aura:set attribute="else">
                <lightning:input aura:id="company" label="Company Name" required="true" value="{!v.company}"/>
            </aura:set>
        </aura:if>

JS
var company = component.find("company").get("v.value");

 
I am trying to add a custom LWC to a phone record page however getting the below error message. Could anyone help me out how to make the component mobile viewable.

User-added image
I am trying to create a view to show activity information. However the below code is not displaying any information, only header is showing. Please help.
HTML Component :

<template>
    <lightning-card class="slds-text-title_bold"  title = "Activity Information">
        <div class="slds-p-around_medium lgc-bg" style="height: 300px;">
            <lightning-datatable
                    key-field="id"
                    data={data}
                    columns={columns}>
            </lightning-datatable>
        </div>
    </lightning-card>
</template>
 
JS File:

import { LightningElement,api,wire,track} from 'lwc';
import ActivitySearchController from '@salesforce/apex/ActivityLeadPage.ActivitySearchController'

const columns = [
    { label: 'Subject', fieldName: 'Subject' },
    { label: 'Due Date', fieldName: 'ActivityDate' },
    { label: 'Status', fieldName: 'Status' },
];

export default class ActivityLeadPageComponent extends LightningElement {
    @api recordId;
    @track data = [];
    @track columns = columns;
    @wire(ActivitySearchController, { currentID: '$recordID'})
    TaskList;
}
 
Controller :

public class ActivityLeadPage{
    
    @AuraEnabled(cacheable=true)
    public static List<Task> ActivitySearchController(String currentID){
        List<Task> TaskList = new List<Task>();
        Map<Id,Lead> leadMap = new Map<Id,Lead>();
        if(currentID.startsWith('00Q')){
            try{
                List <Lead> leadList = [SELECT id, Email FROM Lead WHERE ID=:currentId];
                String ldEmail       = leadList[0].Email;
                Set<String> emailIds = new Set<string>();
                if(ldEmail!=null){
                    emailIds.add(ldEmail);
                }               
                
                TaskList = getTaskList(emailIds);
                
            }           
            catch(Exception e){
                system.debug('getlinenumber-->'+ e.getMessage() +' line '+ e.getLineNumber());
            } 
        }
        return TaskList;
    }
    
    public static List<Task> getTaskList (Set<String> emailIds) {  
        Map<Id,Lead> leadMap = new Map<Id,Lead>();      
        leadMap = new Map<Id,Lead>([SELECT id, Email FROM Lead Where Email IN:emailIds]);       
        
        Set<Id> leadID = new Set<Id>(); 
        for(Lead lE : leadMap.values()){
            leadID.add(lE.id);            
        }  
        
        List<Task> TaskList = [Select id, Subject, Description, who.Type, What.Type, Priority, Status, ActivityDate,CreatedDate, LastModifiedDate FROM Task 
                               WHERE whoId IN:leadID ORDER BY createddate DESC LIMIT 20];
        
        if(TaskList.size() == 0){
            Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No Tasks to Display'));
        }
        
        return TaskList;
    }   
}
With the help of the Local Time app we are able to get the DateTime of the customer in real time.However we would like to tweak the format at bit. At present we are getting the format as : 08-05-2019 2:21 PM GMT (this is a string field), we are looking at something like Mon, AUG 08, 2019 2:21 PM. Looking forward for the inputs.
Hello Ohana,

If I understood correctly, if I pass 1000 records in the below batch, it will divide across 5 sub batch(200 each). The List<CSVGenerator.Values>  will hold value only for the final batch. What I am looking at is the List<CSVGenerator.Values>  should store the values of all the 5 sub batches which I will be passing to another method in my FINISH method. Need help here.
 
public class BatchToGenerateCSVForMarin implements Database.Batchable<sObject>, Database.Stateful {
    
    public List<CSVGenerator.Values> indiaGoogleValList = new List<CSVGenerator.Values>();
    public List<CSVGenerator.Values> indiaFacebookValList = new List<CSVGenerator.Values>();
    
    public Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'SELECT ID,Email,Status,CreatedDate,Lead_GEO__c,GCLID__c,MKWID__c,MSCLICKID__c,FBCLID__c FROM Lead WHERE RecordType.Name=\'B2C\' AND Status!=\'Duplicate\'';
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext BC, List<Lead>scope){
        try{
            Set<Id> indiaLeadID = new Set<Id>();
            Set<Id> ROWLeadID = new Set<Id>();
            Set<Id> USLeadID = new Set<Id>();
            for(Lead l : scope){
                if(l.Lead_GEO__c!=null && l.Lead_GEO__c =='INDIA'){
                    indiaLeadID.add(l.Id);
                }
            }
            
            Map<String,Integer> googleIDIndiaMap = new Map<String,Integer>();
            Map<String,Integer> marinIDIndiaMap = new Map<String,Integer>();
            
            List<AggregateResult> leadMarketingIDAgg = [SELECT Count(ID)id, GCLID__c googleID, MKWID__c marinID, MSCLICKID__c bingID, FBCLID__c facebookID FROM Lead WHERE ID IN:indiaLeadID Group By GCLID__c,MKWID__c,MSCLICKID__c,FBCLID__c];
            
            for(AggregateResult agg : leadMarketingIDAgg){
                if((String)agg.get('googleID')!=null){
                    googleIDIndiaMap.put((String)agg.get('googleID'), (Integer)agg.get('id'));
                }
                if((String)agg.get('marinID')!=null){
                    marinIDIndiaMap.put((String)agg.get('marinID'), (Integer)agg.get('id'));
                }
            }
            
            for(String s : googleIDIndiaMap.keySet()){
                CSVGenerator.Values val = new CSVGenerator.Values();
                val.recordDate = String.valueof(System.today());
                val.conversionType = 'Lead';
                val.conversions = string.valueof(googleIDIndiaMap.get(s));
                val.revenue = '0';
                val.currencyCode = '';
                val.comments = s;
                indiaGoogleValList.add(val);
            }
            
            for(String s : marinIDIndiaMap.keySet()){
                CSVGenerator.Values val = new CSVGenerator.Values();
                val.recordDate = String.valueof(System.today());
                val.conversionType = 'Lead';
                val.conversions = string.valueof(marinIDIndiaMap.get(s));
                val.revenue = '0';
                val.currencyCode = '';
                val.comments = s;
                indiaMarinValList.add(val);
            }
    }
    
    public void finish(Database.BatchableContext BC){
        if(indiaGoogleValList.size() > 0){
            CSVGenerator.generateCsv('Marin', indiaGoogleValList, 'Google', 'INDIA');
        }       
        if(indiaMarinValList.size() > 0){
            CSVGenerator.generateCsv('Marin', indiaMarinValList, 'Marin', 'INDIA');
        }
    } 
}

 
Hello Trailblazers, 

When a user clicks on the link, it should open in a subtab in lightning console. Below is the VF page that I have come up with, however it's not working as expected. Any inputs will be highly appreciated. 
 
<apex:page standardController="LiveChatTranscript" extensions="PastChatSearchController">
    <apex:includeScript value="/support/console/45.0/integration.js"/>
    
    <script>
    var preRecordId;    
    function openSubtab(id, name) 
    {
        preRecordId= id;    
        alert('URL----->'+'{!$CurrentPage.URL}');        
        if (sforce.console.isInConsole())
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
        else
            window.top.location.href = '/' + id;
    }
    
    var openSubtab = function openSubtab(result) 
    {
        var primaryTabId = result.id;        
        sforce.console.openSubtab(primaryTabId, '/'+preRecordId, true, preRecordId , null , openSuccess, 'salesforceSubtab');
    };
    </script>
        
    <apex:form >
        <apex:pageBlock id="pb">
            <apex:pageMessages ></apex:pageMessages>
            <apex:pageBlockTable value="{!LiveChatTranscript}" var="d">
                <apex:column headerValue="Live Chat Transcript Name">
             <!--       <apex:outputLink target="_blank" style="color:blue" value="{!URLFOR($Action.LiveChatTranscript.View, d.ID)}"> {!d.Name} 
                    </apex:outputLink> -->
                    
                    <a href="#" onclick="openSubtab('{!d.id}', '{!d.id}');return false">{!d.Name}</a>
                </apex:column>
                
                <apex:column headerValue="CreatedDate">                  
                    <apex:outputField value="{!d.CreatedDate}">                               
                    </apex:outputField>                   
                </apex:column>
                
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>    
</apex:page>

Thank you
Shravan
Hello Folks,

Below is the sample code :
Map<Id, Lead> ledMap = //Consider this will give me 3 records
for(Lead l : leadMap.values()){
if(l.status = 'New'){
//logic here
}
else if(l.status = 'Dead'){
//logic here
}
}

What I am looking at here is, if any record meet the first creteria (l.status = 'New') then I don't want to iterate the remaining records (in this case remaining 2 records). And in case if none of the records meet the first creteria (l.status = 'New') then only I need to perform the logic inside the else if condition. 

Looking forward for your inputs.

Thanks,
Shravan
 
Hello There,

I would like to have a drop down option on "Event Type" for the below VF page. The result should display based on the Event type I select.
User-added image
Here is the Controller :
public class UserWebActivityController{
    
    public Account accld; 
    public Lead lID;
    public Opportunity opp;
    public String recordId;
    public List<WebActivity> userWebActivityLstAll{get;set;}
    String currentId = ApexPages.CurrentPage().getparameters().get('id'); 
    
    public UserWebActivityController (ApexPages.StandardController controller) {
    
    //Lead ID
        if (currentId.startsWith('00Q')) {
            try{
                String lEmail;
                String lAltEmail;
                
                recordId      = controller.getId();                
                lID = (Lead)controller.getRecord(); 
                if(lID!=null) {
                    List<Lead> ldLst = LeadSelector.getLeadFromIds(new set<Id>{lID.id});
                    if(ldLst.size()>0){
                        lEmail           = ldLst[0].email;
                        lAltEmail        = ldLst[0].Alternate_Email__c; 
                    }                 
                } 
                                 userWebActivityLstAll=UserWebActivityController.getUserDetailsFromObject(lEmail, lAltEmail); 
            }
            
            catch(exception e){
                system.debug('****Exception in page:-'+e.getMessage()+' at line number:- '+e.getLineNumber());
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'An internal exception has occurred. please contact administrator.'));
            }
        }
        
        
        //Account ID
        if (currentId.startsWith('001')) {
            try{
                String accEmail;
                String accAltEmail;
                
                recordId      = controller.getId();
                accld = (Account)controller.getRecord(); 
                if(accld!=null) {
                    List<Account> accLst = AccountSelector.getAccount(new set<Id>{accld.id});
                    if(accLst.size()>0){
                        accEmail           = accLst[0].PersonEmail;
                        accAltEmail        = accLst[0].Alternate_Email__c; 
                    }                 
                } 
                
userWebActivityLstAll=UserWebActivityController.getUserDetailsFromObject(accEmail, accAltEmail); 
            }
            
            catch(exception e){
                system.debug('****Exception in page:-'+e.getMessage()+' at line number:- '+e.getLineNumber());
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'An internal exception has occurred. please contact administrator.'));
            }
        }
        
        //Opportunity ID
        if (currentId.startsWith('006')) {
            try{
                String accEmail;
                String accAltEmail;
                
                recordId      = controller.getId();
                opp = (Opportunity)controller.getRecord(); 
                if(opp!=null) {
                //  List <Opportunity> oppList = [SELECT id, AccountId FROM Opportunity WHERE ID=:oppId];
                //  if(oppList.size()>0 && oppList.get(0).AccountId!=null){
                   if(opp.AccountId!=null){ 
                    List<Account> accLst = AccountSelector.getAccount(new set<Id>{opp.AccountId});
                        if(accLst.size()>0){
                            accEmail           = accLst[0].PersonEmail;
                            accAltEmail        = accLst[0].Alternate_Email__c; 
                        }
                    }   
                                                
                } 
                
                  userWebActivityLstAll=UserWebActivityController.getUserDetailsFromObject(accEmail, accAltEmail); 
            }
            
            catch(exception e){
                system.debug('****Exception in page:-'+e.getMessage()+' at line number:- '+e.getLineNumber());
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'An internal exception has occurred. please contact administrator.'));
            }
        }
    }
    
    
    // Method to get from the table 
    
    public static List<WebActivity> getUserDetailsFromObject(String accEmail, String accAltEmail) {
        List<WebActivity> userWebActivityLstAll = new List<WebActivity>();
        
        Set<String> emailIdSet= new Set<String>();
        if(accEmail!=null){
            
            emailIdSet.add(accEmail);
        }
        if(accAltEmail!=null){
            
            emailIdSet.add(accAltEmail);
        }
        
        
        if(emailIdSet.size()>0){ 
            Map<Id,Customer_Web_Activity__c>  customerWebActivity = CustomerWebActivitySelector.getCustomerWebActivityFromEmail(emailIdSet);
            
            for(Customer_Web_Activity__c custActivity : customerWebActivity.values()){
                
                WebActivity custWebActivity = new WebActivity();
                custWebActivity.email=custActivity.Email__c;
                custWebActivity.activityDateTime=custActivity.Activity_Time__c;
                custWebActivity.event_type=custActivity.Event_Type__c;
                custWebActivity.description=custActivity.Description__c;
                custWebActivity.url=custActivity.URL__c;
                custWebActivity.activity=custActivity;             
                userWebActivityLstAll.add(custWebActivity);
            }
        } 
    
       return   userWebActivityLstAll;
    }
    
    public class WebActivity{      
        public String email {get;set;} 
        public String activityTime {get;set;} 
        public Datetime activityDateTime{get;set;}
        public String event_type {get;set;}  
        public String description {get;set;}  
        public String url{get;set;}
        public Customer_Web_Activity__c activity{get;set;}
    }
}

Here is the VF Page :
 
<apex:page standardController="Lead" extensions="UserWebActivityController">
    <apex:form >

       <apex:pageBlock >
            
             <apex:pageMessages />

            <apex:pageBlockTable value="{!userWebActivityLstAll}" var="w">
                
                <apex:column headervalue="Time" >
                <apex:outputField value="{!w.activity.Activity_Time__c}"/>                                      
                </apex:column>
                
                <apex:column headervalue="Event Type" >
                    <apex:outputText value="{!w.event_type}"/>                    
                </apex:column>               
                
                <apex:column headervalue="Description" >
                    <apex:outputText value="{!w.description}"/>
                 <apex:outputPanel rendered="{!w.url!=null}"> 
                   <br/>
                    <apex:outputLink value="{!w.url}" target="_blank"><b>Click here for Email Template</b></apex:outputLink>  
                  </apex:outputPanel>                   
                </apex:column>                  
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Kindly do the needful.

Thanks,
Shravan
 
Hello There,

I have a Map i.e., Map<String, List<Account>> emailAccListMap
I am trying to access the account field from the above Map by saying emailAccListMap.get(String).Name, but this doesn't work.

Can anyone help?

Thanks
I have a custom field on Lead - Product_ID__c which store Product ID. I am unable to sucessfully wite a trigger that lookup up to product based upon the product ID and update two fields on lead Course Code & Category Code with the values from Product object.

Any sample code would help a lot.

Thanks,
Shravan
Please help me with the Test Class for the below Controller :

public class ActivitySearchController {
    
    Public List<Task> TaskList {get;set;}  
    String currentId =ApexPages.CurrentPage().getparameters().get('id');
                
    public ActivitySearchController(ApexPages.StandardController controller) {    
        //Lead ID
        if (currentId.startsWith('00Q')) {
            
            try{         
                List <Lead> leadList = [SELECT id, Email, Alternate_Email__c FROM Lead WHERE ID=:currentId];
                String ldEmail       = leadList[0].Email;
                String ldAltEmail    = leadList[0].Alternate_Email__c;
                Set<String> emailIds = new Set<string>();
                if(ldEmail!=null){
                    emailIds.add(ldEmail);
                }
                if(ldAltEmail!=null){
                    emailIds.add(ldAltEmail);
                }
                
                List <Lead> rldLead    = [SELECT id, Email, Alternate_Email__c FROM Lead Where Email IN:emailIds OR Alternate_Email__c IN:emailIds];
                List <Account> accLst  = [SELECT id, PersonEmail, Alternate_Email__c FROM Account Where PersonEmail IN:emailIds OR Alternate_Email__c IN:emailIds];
                
                Set<Id> leadID = new Set<Id>(); 
                Set<Id> accIds = new Set<Id>();    
                for(Lead lE : rldLead){
                    leadID.add(lE.id);            
                }  
                for(Account acc : accLst){
                    accIds.add(acc.id);            
                }      
                
                TaskList = [Select id, Subject, Comments_Short__c, who.Type, What.Type, Priority, Status, ActivityDate FROM Task 
                            WHERE (accountid IN:accIds OR whoId IN:leadID) AND Status = 'Open' ORDER BY createddate DESC];
                
                if(TaskList.size() == 0)
                {
                    Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No Tasks to Display'));
                } 
                
            } 
            
            catch(Exception e){
                system.debug('getlinenumber-->'+ e.getMessage() +' line '+ e.getLineNumber());
            }
            
        }
        
        
        //Account ID
        else if (currentId.startsWith('001p')) {
            
            try{         
                List <Account> accList = [SELECT id, PersonEmail, Alternate_Email__c FROM Account WHERE ID=:currentId];
                String ldEmail       = accList[0].PersonEmail;
                String ldAltEmail    = accList[0].Alternate_Email__c;
                Set<String> emailIds = new Set<string>();
                if(ldEmail!=null){
                    emailIds.add(ldEmail);
                }
                if(ldAltEmail!=null){
                    emailIds.add(ldAltEmail);
                }
                
                List <Lead> rldLead    = [SELECT id, Email, Alternate_Email__c FROM Lead Where Email IN:emailIds OR Alternate_Email__c IN:emailIds];
                List <Account> accLst  = [SELECT id, PersonEmail, Alternate_Email__c FROM Account Where PersonEmail IN:emailIds OR Alternate_Email__c IN:emailIds];
                
                Set<Id> leadID = new Set<Id>(); 
                Set<Id> accIds = new Set<Id>();    
                for(Lead lE : rldLead){
                    leadID.add(lE.id);            
                }  
                for(Account acc : accLst){
                    accIds.add(acc.id);            
                }      
                
                TaskList = [Select id, Subject, Comments_Short__c, who.Type, What.Type, Priority, Status, ActivityDate FROM Task 
                            WHERE (accountid IN:accIds OR whoId IN:leadID) AND Status = 'Open' ORDER BY createddate DESC LIMIT 10];
                
                if(TaskList.size() == 0)
                {
                    Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No Tasks to Display'));
                } 
                
            } 
            
            catch(Exception e){
                system.debug('getlinenumber-->'+ e.getMessage() +' line '+ e.getLineNumber());
            }
            
        }
        
        //Opportunity ID
        else if (currentId.startsWith('006p')) {
            
            try{         
                List <Opportunity> oppList = [SELECT id, AccountId FROM Opportunity WHERE ID=:currentId];
                String oppID = oppList[0].Accountid;
                List <Account> oppAccList = [SELECT id, PersonEmail, Alternate_Email__c FROM Account WHERE ID =: oppID];
                String ldEmail       = oppAccList[0].PersonEmail;
                String ldAltEmail    = oppAccList[0].Alternate_Email__c;
                Set<String> emailIds = new Set<string>();
                if(ldEmail!=null){
                    emailIds.add(ldEmail);
                }
                if(ldAltEmail!=null){
                    emailIds.add(ldAltEmail);
                }
                
                List <Lead> rldLead    = [SELECT id, Email, Alternate_Email__c FROM Lead Where Email IN:emailIds OR Alternate_Email__c IN:emailIds];
                List <Account> accLst  = [SELECT id, PersonEmail, Alternate_Email__c FROM Account Where PersonEmail IN:emailIds OR Alternate_Email__c IN:emailIds];
                
                Set<Id> leadID = new Set<Id>(); 
                Set<Id> accIds = new Set<Id>();    
                for(Lead lE : rldLead){
                    leadID.add(lE.id);            
                }  
                for(Account acc : accLst){
                    accIds.add(acc.id);            
                }      
                
                TaskList = [Select id, Subject, Comments_Short__c, who.Type, What.Type, Priority, Status, ActivityDate FROM Task 
                            WHERE (accountid IN:accIds OR whoId IN:leadID) AND Status = 'Open' ORDER BY createddate DESC LIMIT 10];
                
                if(TaskList.size() == 0)
                {
                    Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No Tasks to Display'));
                } 
                
            } 
            
            catch(Exception e){
                system.debug('getlinenumber-->'+ e.getMessage() +' line '+ e.getLineNumber());
            }
            
        }
    }
}
I would like to show all the open tasks across the Org based upon the Email ID. The below VF & Class is giving me the results of all the task irrespetive of Email ID. Can someone help me to fix the code here :

Class :

public class ActivitySearchController {

    Public List<Task> TaskList{get;set;}
    
    String currentEmail ; 
    public ActivitySearchController(ApexPages.StandardController controller) {
       
        currentEmail  = ApexPages.CurrentPage().getparameters().get('Email');
       
     TaskList = [Select subject,id, who.Email, Type, Who.Type, whoID, priority, status, ActivityDate
                FROM Task WHERE who.Email=:currentEmail AND Status = 'Open'];
     
    
    if(TaskList.size() == 0)
{
    Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No Tasks to Display'));
   } 
 }
      
       }

VF:

<apex:page standardController="Lead" extensions="ActivitySearchController"  >
    <apex:form >
        <apex:pageBlock id="pb">
            <apex:pageMessages ></apex:pageMessages>
            
            <apex:pageBlockTable value="{!TaskList}" var="d">
                
                 <apex:column headerValue="Record ID">   
                    <apex:outputField value="{!d.id}">                      
                    </apex:outputField> </apex:column>
                
                <apex:column headerValue="Subject">   
                    <apex:outputField value="{!d.subject}">  
                        </apex:outputField> </apex:column>
                
                <apex:column headerValue="Type">   
                    <apex:outputField value="{!d.Type}">                         
                    </apex:outputField> </apex:column>
                
                <apex:column headerValue="Status">   
                    <apex:outputField value="{!d.Status}">                      
                    </apex:outputField> </apex:column>
                
                
            </apex:pageBlockTable>   
        </apex:pageBlock>
    </apex:form>
</apex:page>
I would like to pull user web activity details like website page visit link from an external API and display the same of the lead object page in Salesforce. I am not able to find a solution how to integrate the REST Apex code to Visfualforce to display the data. Kindly help me with the solution for this.
I have successfully wrote a trigger which calculates all the newly completed activities (Email & Call) and update the total number of a custom filed on the lead object. Similary, I would like to do the same for the completed task which are already completed before the trigger was written however unable to get what the code should be. Below is the trigger that I wrote for the calulcated the New Task :

trigger NoOfEmail on task (after insert, after update) {
    id leadid;
    integer inr = 0;
    List <task> leadTask = new List <task>();
    if (trigger.new!= null) {
        for (task t : Trigger.new) {
            leadid = t.WhoId;
        }
    }
    leadTask = [select id, subject, Status from task where whoid=:leadid];
    for(task t : leadTask){
        if ((t.Subject == 'Email' || t.Subject == 'Call') && t.Status == 'Completed'){
            inr = inr+1;
        }
    }
    
    List <lead> led1 = new list <lead> ();
    List <Lead> led = [select id from lead where id = :leadid];
    for (lead l : led){
        led1.add(l);
        l.Number_of_Activity__c = inr;
    }    
    
    if(led1.size()>0){
        update led1;
    }
}
There is a Custom Object Workshop, which has one of the field "Course". The Course field will get updated by a product code from a external API.
We have to match this product code with the existing product code (field on standard Product object) and then pull out the Product Name corresponding to the product code and update the same on a custom field on Workshop object.

Please help me how to set up this.
Unable to Create Volunteer Job field because while creating Master Details relationship on Volunteer Shifts I am not getting Volunteer Jobs to select as a parent. Below is the screen shot :

User-added image
I am getting the error "'npm' is not recognised as an internal or external command" while creating project in VS code using Salesforce CLI. Don't know what I am missing out. Can anyone guide me.
I am looking for a solution where when I click on a button, the resulting page should open in the same window below the button. Below is my current VF page, right now the page is opening in a new tab.
 
<apex:page lightningStylesheets="true">
<style>
    body input.btn, body input.btnDisabled, body input.btnCancel {
    padding: 4px 3px;
    padding-left: 1rem;
    padding-right: 1rem;
    text-align: center;
    vertical-align: middle;
    justify-content: center;
    border: 1px solid #dddbda;
    transition: border .15s linear;
    background-color: #0070d2;
    border-color: #0070d2;
    /* color: #fff; */
    width: 300px;
    height: 35px;
    }
</style>

<apex:form target="_self" >

        <center>
            <apex:commandButton id="one" value="Lead Page" oncomplete="openDashboard(this.id);" />&nbsp;&nbsp;
            <apex:commandButton id="two" value="Account Page" oncomplete="openDashboard(this.id);"/> 
        </center>
        <br/>
</apex:form>

<script type="text/javascript">
function openDashboard(clicked_id) {
    if(clicked_id.includes('one')){
        window.open("Lead URL");
    }else if(clicked_id.includes('two')){
        window.open("Account URL");
    } 
}
</script>
<apex:page standardController="Order" extensions="orderPageLayoutController">    
    <apex:form id="fm">
<apex:pageBlock id="pbsk">	
            <apex:pageBlockSection title="Order Terms and Client POC Details" columns="2">
                <apex:pageblocksectionItem >
                    <apex:outputlabel value="Invoice Contact" />
                    <apex:actionRegion >
                        <apex:inputField value="{!Order.Invoice_Contact__c}" required="true">
                            <apex:actionSupport event="onchange" action="{!autoFillData}" reRender="conEmail,conPhone"/>   
                        </apex:inputField>
                    </apex:actionRegion>
                </apex:pageblocksectionItem>
                <apex:inputField value="{!Order.Invoice_Email__c}" id="conEmail"/>
                <apex:inputField value="{!Order.Invoice_Phone__c}" id="conPhone"/>
                <apex:repeat value="{!$ObjectType.Order.FieldSets.Contact_Name_and_Payment_Terms}" var="f">                             
                    <apex:inputField value="{!Order[f]}"  required="{!OR(f.required, f.dbrequired)}" />
                </apex:repeat>
            </apex:pageBlockSection>   
</apex:pageBlock>
</apex:form>			
            
    <!-- File Uplaod Section -->
    <apex:form enctype="multipart/form-data">
        <apex:pageBlock id="thePageBlock" >
            <apex:pageBlockSection title="Upload Related Files" columns="1">
                <apex:pageMessages />
            </apex:pageBlockSection>
            <apex:pageBlockSection showHeader="false" columns="1" id="block1">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="File Name" for="fileName"/>
                    <apex:inputField value="{!theConVer.title}" styleClass="slds-input slds-size_1-of-2"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="File" for="file"/>
                    <apex:inputFile value="{!theConVer.versionData}" fileName="{!fileName}" id="file" />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Document Type"/>
                    <apex:inputField value="{!theConVer.Document_Type__c}" styleClass="slds-listbox slds-input slds-size_1-of-2" required="true" />
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <input id="uploadButton" type="button" value="Upload file" name="uploadFile" onclick="uploadFileToTemp()" />			   
        </apex:pageBlock>
        <apex:actionFunction action="{!uploadFile}" name="uploadFile" reRender=""/>
    </apex:form> 
    
	<script type="text/javascript">
    function uploadFileToTemp(){
        document.getElementById ('uploadButton').disabled = true;
        uploadFile();    
    }
    </script>
	
</apex:page>

Hello,

Can anyone help me out to fix the rerender with apex:inputfile issue :

 
Component
<aura:if isTrue="{!v.leadRecord.Company!=null}">
            <div class="slds-form-element">
                <label class="slds-form-element__label" for="text-input-id-1">Company</label>
                <div class="slds-form-element__control">
                    <input type="text" aura:id="company" placeholder="" value="{!v.leadRecord.Company}" disabled="true" class="slds-input" />
                </div>
            </div>
            <aura:set attribute="else">
                <lightning:input aura:id="company" label="Company Name" required="true" value="{!v.company}"/>
            </aura:set>
        </aura:if>

JS
var company = component.find("company").get("v.value");

 
I am trying to create a view to show activity information. However the below code is not displaying any information, only header is showing. Please help.
HTML Component :

<template>
    <lightning-card class="slds-text-title_bold"  title = "Activity Information">
        <div class="slds-p-around_medium lgc-bg" style="height: 300px;">
            <lightning-datatable
                    key-field="id"
                    data={data}
                    columns={columns}>
            </lightning-datatable>
        </div>
    </lightning-card>
</template>
 
JS File:

import { LightningElement,api,wire,track} from 'lwc';
import ActivitySearchController from '@salesforce/apex/ActivityLeadPage.ActivitySearchController'

const columns = [
    { label: 'Subject', fieldName: 'Subject' },
    { label: 'Due Date', fieldName: 'ActivityDate' },
    { label: 'Status', fieldName: 'Status' },
];

export default class ActivityLeadPageComponent extends LightningElement {
    @api recordId;
    @track data = [];
    @track columns = columns;
    @wire(ActivitySearchController, { currentID: '$recordID'})
    TaskList;
}
 
Controller :

public class ActivityLeadPage{
    
    @AuraEnabled(cacheable=true)
    public static List<Task> ActivitySearchController(String currentID){
        List<Task> TaskList = new List<Task>();
        Map<Id,Lead> leadMap = new Map<Id,Lead>();
        if(currentID.startsWith('00Q')){
            try{
                List <Lead> leadList = [SELECT id, Email FROM Lead WHERE ID=:currentId];
                String ldEmail       = leadList[0].Email;
                Set<String> emailIds = new Set<string>();
                if(ldEmail!=null){
                    emailIds.add(ldEmail);
                }               
                
                TaskList = getTaskList(emailIds);
                
            }           
            catch(Exception e){
                system.debug('getlinenumber-->'+ e.getMessage() +' line '+ e.getLineNumber());
            } 
        }
        return TaskList;
    }
    
    public static List<Task> getTaskList (Set<String> emailIds) {  
        Map<Id,Lead> leadMap = new Map<Id,Lead>();      
        leadMap = new Map<Id,Lead>([SELECT id, Email FROM Lead Where Email IN:emailIds]);       
        
        Set<Id> leadID = new Set<Id>(); 
        for(Lead lE : leadMap.values()){
            leadID.add(lE.id);            
        }  
        
        List<Task> TaskList = [Select id, Subject, Description, who.Type, What.Type, Priority, Status, ActivityDate,CreatedDate, LastModifiedDate FROM Task 
                               WHERE whoId IN:leadID ORDER BY createddate DESC LIMIT 20];
        
        if(TaskList.size() == 0){
            Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No Tasks to Display'));
        }
        
        return TaskList;
    }   
}
Hello Folks,

Below is the sample code :
Map<Id, Lead> ledMap = //Consider this will give me 3 records
for(Lead l : leadMap.values()){
if(l.status = 'New'){
//logic here
}
else if(l.status = 'Dead'){
//logic here
}
}

What I am looking at here is, if any record meet the first creteria (l.status = 'New') then I don't want to iterate the remaining records (in this case remaining 2 records). And in case if none of the records meet the first creteria (l.status = 'New') then only I need to perform the logic inside the else if condition. 

Looking forward for your inputs.

Thanks,
Shravan
 
Hello There,

I have a Map i.e., Map<String, List<Account>> emailAccListMap
I am trying to access the account field from the above Map by saying emailAccListMap.get(String).Name, but this doesn't work.

Can anyone help?

Thanks
So the trigger i have is working fine in production except that when our pipeline is updating sfdc during off hours I get email notification 'Apex script unhandled trigger exception by user/organization: BlockUsers: System.LimitException: Too many SOQL queries: 101'

I am new to apex even newer to batch apex. Can someone help me with turning this code into batch apex trigger 
 
trigger BlockUsers on Account  (before insert, before update) {

Account accs = Trigger.new[0];
string accExec = accs.Assigned_AE__c;
integer i=[select count() from account where Assigned_AE__c= :accExec AND Assigned_AE__c!=null];
for(Account a: Trigger.new){
 If (trigger.isInsert || (trigger.isUpdate && trigger.newMap.get(a.Id).Assigned_AE__c != trigger.oldMap.get(a.Id).Assigned_AE__c))
     {          
                if(i >=100)
                a.addError('The AE you are trying to add already has 100 accounts in their name');
}
}
}

trigger gets activated whenever an update happens on assigned_ae__c field. This code is reteiving all accounts where that particualar AE is listed and then counts them and as long as the number is less than 100 allows the update to happen.
 
Hi! What I'm trying to do is pretty simple, but I'm not sure how to achieve it. On our Opportunity page, I'd like to show "Amount" in 2 places. I made a Formula field to pull the information from Amount using TEXT(Amount). I'm now seeing the number in both places, but it is displayed in the Amount field as "$824.00" and under the new field as "824". Is there anyway to pull this information into a new field and retain the currency format?
Hi ,

Im using trigger and class to check the duplicate lead using email and phone.It is working.When a lead exists a task should create under original lead and assigned to leadowner.How can i achieve this?
thanks
  • November 05, 2018
  • Like
  • 0
Hello everybody,

I'm new in this trailhead thing, it's been 2-3 weeks that I started and I'm already stuck in the Share CRM Data with Your Partners > Set Up Account Roles and the Role Hierarchy.

I keep getting the message : 
Step not yet complete... here's what's wrong:
Assign Barbara Levy the Express Logistics and Transport Partner Manager role.


I think that is a language problem, as in my playground instead of "Express Logistics and Transport Partner Manager" says "Express Logistics and Transport Socio Gestor".

I had my trailhead in Spanish but I've tried to change the language, the location, I already created new playgrounds and changed those things from the beging and started all over again.

I've tried to look for the role to try to change it manualy but it doesn't appear in the role list, I also tried to look for the data wich builds the picklist but nothing.

I don't know what else can I do. If somebody has any suggestions or something it would be really helpfull.

Thanks a lot!