• IamSRN
  • NEWBIE
  • 25 Points
  • Member since 2016
  • Senior Solution Specialist
  • Deloitte

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies
Okay fellas, this one is a toughie.

I have a trigger that is before update on object A. I have a field on the same object which is updated by a process.

I need to somehow make an if statement in the trigger NOT to fire if the value in the field is changed. This is a before update trigger. Is it even possible?
Hello,

I am facing this issue in many out of the box LWC components. I am trying to change the style of text area by defining a css class. But it is failing to override the slds style at run time? Any idea?
 
<template>
    <div class="row slds-m-vertical_large">
        <h2 class="header">Basic Examples</h2>
        <lightning-textarea 
        name="input1" 
        label="Enter some text"
        class="mytextarea">
        </lightning-textarea>
    </div>
</template>

.mytextarea{
    height: 150px;
}

You can find this live at : https://developer.salesforce.com/docs/component-library/tools/playground/QWa-zfwxW/1/edit
  • August 07, 2019
  • Like
  • 0
Hello,

I am using Progress Indicator component. But I want to hide this if user is accesing the page from mobile or tablet. What is the best way to do that? Thanks in adcance!!

( https://developer.salesforce.com/docs/component-library/bundle/lightning-progress-indicator/example)
Hello, what is the best way to see if my newly created LWC is working as expected? I am trying to get around creating a lightning app everytime.  In Aura we had an option to create an aura app, Is there anyway I can see the changes locally without pushing the changes to Salesforce org? Thanks for all the help!
When SOQL For loops used with ORDER by clause, list gives un-ordered list. We had to store the query in a local variable and loop through it to solve this issue. Any ides why this is happening?
  • December 02, 2016
  • Like
  • 0
We are trying to deploy an un-managed package from one Dev org to another. The source has Person account enabled and target does not have Person account. We are not using any feature provided by Person account or standard Account. All the objects, pages, controllers in this package are custom developed. What is the best way to deploy this package in target organization?
  • April 13, 2016
  • Like
  • 0
How to Write a trigger that automatically create a contact when account is created?

Hello all, I am having issues trying to rerender data on my VF page. My VF page has a place to enter a date. It should then use that date in the controller SOQL to filter records by. Then it should refresh the section of the VF page that contains the records using the date entered.  Can someone please help me with this? Thanks.

<apex:page controller="ForecastController" sidebar="false"  tabStyle="Opportunity" docType="html-5.0">
    
    <style>
        
        table {
        border-collapse: collapse;
        width: 100%;
        
        }
        
        th {
        text-align: left;
        padding: 4px;
        width:100px;
        
        }
        
        
        td {
        text-align: left;
        padding: 4px;
        
        }
        
        
        tr:nth-child(even) {background-color: #cccccc;}
        
    </style>
    
    <apex:sectionHeader title="Opportunities" subtitle="Forecast Review" description="Please enter the date below you would like to use for historical data."/>
    
    <apex:form id="searchForm">
        <apex:PageBlock mode="edit">        
            <apex:pageblockSection id="searchBlockSection">
                
                <apex:pageBlockSectionItem id="searchBlockSectionItem">
                    <apex:outputLabel >Enter Date (Format: YYYY-MM-DD)</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputtext id="searchDate" value="{!searchDate}" />
                        <strong>
                            <apex:commandButton Id="btnSearch" action="{!search}" rerender="renderBlock" status="status" title="Search" value="Search" >
                            </apex:commandButton>
                        </strong>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
            </apex:pageblockSection>
            <apex:actionStatus id="status" startText="Searching... please wait..."/> 
            
            <apex:repeat value="{!forecasts}" var="c" >
                <apex:pageBlock title="Close Date (Forecasted) {!c.month}"  >
                    <apex:repeat value="{!c.territories}" var="t" >
                        <apex:pageBlock title="Territory {!t}" >
                            <!-- access map variables -->
                            <table>
                                <tr> 
                                    <th>Account Name</th>
                                    
                                    <th>Territory Manager</th>
                                    
                                    <th>Stage</th>
                                    
                                    <th>Prev Stage</th>
                                    
                                    <th>AD/RBD Close Date</th>
                                    
                                    <th>Prev AD/RBD Close Date</th>
                                    
                                    <th>Close Date</th>
                                    
                                    <th>Prev Close Date</th>
                                    
                                    <th>Opportunity Name</th>
                                    
                                    <th>Total FS + Modules</th>
                                    
                                    <th>Prev Total FS + Modules</th>
                                    
                                    <th>Total Instr Rev</th>
                                    
                                    <th>Prev Total Instr Rev</th>
                                </tr>
                                
                                <apex:repeat var="opps" value="{!opportunities}" >
                                    <apex:variable var="v" value="" rendered="{!IF(c.month=opps.Close_Month_Forecasted__c && t=opps.Account.Terr_From_Zip__c,true,false)}" id="renderBlock">
                                        <tr>
                                            <td style="width:300px;"> {!opps.Account.Name} </td>
                                            
                                            <td> {!opps.Account.Territory_Manager__c} </td>
                                            
                                            <td>{!opps.StageName}</td>
                                            
                                            <td>
                                                <apex:outputText rendered="{!IF(opps.Opportunity_Snapshots__r.size > 0,true,false)}">
                                                    {!opps.Opportunity_Snapshots__r[0].Stage__c}
                                                </apex:outputText>
                                            </td>
                                            
                                            <td>
                                                <apex:outputText value="{0,date,MM-dd-yyyy}">
                                                    <apex:param value="{!opps.AD_RBD_Forecast_Close_Date__c}"/>
                                                </apex:outputText>
                                            </td>
                                            
                                            <td>   
                                                <apex:outputText value="{0,date,MM-dd-yyyy}" rendered="{!IF(opps.Opportunity_Snapshots__r.size > 0,true,false)}">
                                                    <apex:param value="{!opps.Opportunity_Snapshots__r[0].ADRBD_Forecast_Close_Date__c}" />
                                                </apex:outputText>
                                            </td>
                                            
                                            <td>
                                                <apex:outputText value="{0,date,MM-dd-yyyy}">
                                                    <apex:param value="{!opps.CloseDate}"/>
                                                </apex:outputText>  
                                            </td>
                                            
                                            <td>
                                                <apex:outputText value="{0,date,MM-dd-yyyy}" rendered="{!IF(opps.Opportunity_Snapshots__r.size > 0,true,false)}">
                                                    <apex:param value="{!opps.Opportunity_Snapshots__r[0].Close_Date__c}" />
                                                </apex:outputText>
                                            </td>
                                            
                                            <td style="width:250px;">{!opps.Name}</td>
                                            
                                            <td>{!opps.Total_FS_Modules__c}</td>
                                            
                                            <td>
                                                <apex:outputText rendered="{!IF(opps.Opportunity_Snapshots__r.size > 0,true,false)}">
                                                    {!opps.Opportunity_Snapshots__r[0].Total_FS_Modules__c}
                                                </apex:outputText>
                                            </td>
                                            
                                            <td>
                                                <apex:outputText value="{0,number,currency}">
                                                    <apex:param value="{!opps.Total_Instr_Revenue__c}"/>
                                                </apex:outputText></td>
                                            
                                            <td>
                                                <apex:outputText value="{0,number,currency}" rendered="{!IF(opps.Opportunity_Snapshots__r.size > 0,true,false)}">
                                                    <apex:param value="{!opps.Opportunity_Snapshots__r[0].Total_Instr_Revenue__c}" />
                                                </apex:outputText>
                                            </td>
                                        </tr>
                                    </apex:variable>
                                </apex:repeat> 
                            </table>
                        </apex:pageBlock>
                    </apex:repeat>
                </apex:pageBlock>
            </apex:repeat>
            
        </apex:PageBlock>
    </apex:form>
</apex:page>
 
public class ForecastController {
    public Map<String, Map<String, List<Opportunity>>> values {get;set;}
    public List<ForecastWrapper> forecasts {get;set;}
    public List<Opportunity> notForecasted {get;set;}
    public List<Opportunity> forecasted {get;set;}
    public List<Opportunity> opportunities {get;set;}
    public List<Opportunity> searchResults {get;set;}
    public Date startSearch {get;set;}
    public Date endSearch {get;set;}
    
    
    // Create Constructor
    public ForecastController(){
        // Load all the data into a map
        Map<String, Map<String, List<Opportunity>>> values = new Map<String, Map<String, List<Opportunity>>>();
        
        // queries for opps whose stageName = closed recognized but were not forecasted ***NOTE THERE SHOULD BE FIELDS ADDED TO VF PAGE THAT ASK FOR START & END DATES AND ARE THEN USED IN THIS QUERY WHERE CloseDate >= START DATE & <= END DATE
        notForecasted = [SELECT Id, Name, Account.Name, Account.Territory_Manager__c, StageName, AD_RBD_Forecast_Close_Date__c, CloseDate, Forecastable__c, 
                         Forecasted_Close_Date_30_60_90__c, Owner.Name, RecordType.Name, Total_FS_Modules__c, Total_Instr_Revenue__c, Opp_Safe_ID__c, 
                         Close_Month_Forecasted__c, Account.Terr_From_Zip__c, (Select Id FROM Opportunity_Snapshots__r)
                         FROM Opportunity    
                         WHERE (NOT Name LIKE 'Test')
                         AND (Account.BillingCountryCode = 'US' OR Account.BillingCountryCode = 'CA')
                         AND Forecastable__c = false
                         AND StageName = 'Closed / Recognized'
                         AND CloseDate = THIS_MONTH
                         ORDER BY Account.Name];
        // queries opps for currently forecasted records along with subquery of opportunity_snapshot__c -- This shows opps that are now forecasted along with their snapshots if they were also forecasted on the searchDate **NOTE THIS SHOULD USE THE DATE FROM VF PAGE IN THE SUBQUERY TO FIND THOSE SNAPSHOT RECORDS THAT WERE CREATED ON searchDate. I don't know how to make this work.
        foreCasted =  [SELECT Id, Name, Account.Name, Account.Territory_Manager__c, StageName, AD_RBD_Forecast_Close_Date__c, CloseDate, Forecastable__c, 
                       Forecasted_Close_Date_30_60_90__c, Owner.Name, RecordType.Name, Total_FS_Modules__c, Total_Instr_Revenue__c, Opp_Safe_ID__c, 
                       Close_Month_Forecasted__c, Account.Terr_From_Zip__c, 
                       (Select Id, Account_Name__c, ADRBD_Forecast_Close_Date__c, Close_Date__c, Close_Month_Forecasted__c, Install_Date_Instruments_only__c, Opportunity__c, 
                        Opportunity_Name__c, Opp_Safe_ID__c, Quantity__c, Stage__c, Territory__c, Territory_Manager__c, Total_FS_Modules__c, Total_Instr_Revenue__c, Total_Price__c, CreatedDate 
                       FROM Opportunity_Snapshots__r Where DAY_ONLY(createdDate) >=: startSearch AND DAY_ONLY(createdDate) <=: endSearch)
                       FROM Opportunity    
                       WHERE (NOT Name LIKE 'Test')
                       AND (Account.BillingCountryCode = 'US' OR Account.BillingCountryCode = 'CA')
                       AND Forecastable__c = true
                       AND Forecasted_Close_Date_30_60_90__c <> null
                       ORDER BY Account.Name
                      ];
        
        // Need to query for snapshots that are not included in the foreCasted List but were created on searchDate -- This will show records that were previously forecasted on searchDate but are no longer showing as forecasted.
        
        // add both notForecasted & forecasted Lists to Opportunities List
        Opportunities = new List<Opportunity>(notForecasted);
        Opportunities.addAll(forecasted);
        
        
        // Search through all Opportunities List and get both the Close_Month_Forecasted__c & Account.Terr_From_Zip__c and build Map to display on VFP
        for(Opportunity record: Opportunities) {
            
            Map<String, List<Opportunity>> dateRange = values.get(record.Close_Month_Forecasted__c);
            
            if(dateRange == null) {
                values.put(record.Close_Month_Forecasted__c, dateRange = new Map<String, List<Opportunity>>());
            }
            List<Opportunity> territoryList = dateRange.get(record.Account.Terr_From_Zip__c);
            if(territoryList == null) {
                dateRange.put(record.Account.Terr_From_Zip__c, territoryList = new List<Opportunity>());
            }
            territoryList.add(record);
        }
        
        forecasts = new ForecastWrapper[0];
        
        // Load the "keys" into our specified order
        List<String> months = new List<String>(values.keySet());
        months.sort();
        
        for(String month: months) {
            Map<String, List<Opportunity>> territoryList = values.get(month);
            String[] territories = new List<String>(territoryList.keySet());
            territories.sort();
            
            ForecastWrapper wrap = new ForecastWrapper();
            wrap.month = month;
            wrap.territories = territories;
            forecasts.add(wrap);
        }
    }
    
    
    public Date searchDate {
        get
        { 
            return searchDate;
        }
        set;
    }
    
    public PageReference search(){
        if(SearchResults == null){
            SearchResults = new List<Opportunity>();
        } else {
            SearchResults.Clear();
        }
        Date startSearch = searchDate - 1;
        Date endSearch = searchDate + 1;
        String qry = 'SELECT Id, Name, Account.Name, Account.Territory_Manager__c, StageName, AD_RBD_Forecast_Close_Date__c, CloseDate, Forecastable__c, Forecasted_Close_Date_30_60_90__c, Owner.Name, RecordType.Name, Total_FS_Modules__c, Total_Instr_Revenue__c, Opp_Safe_ID__c, Health_System_Opportunity__c, Close_Month_Forecasted__c, Account.Terr_From_Zip__c,(Select Id, Account_Name__c, ADRBD_Forecast_Close_Date__c, Close_Date__c, Close_Month_Forecasted__c, Install_Date_Instruments_only__c, Opportunity__c, Opportunity_Name__c, Opp_Safe_ID__c, Quantity__c, Stage__c, Territory__c, Territory_Manager__c, Total_FS_Modules__c, Total_Instr_Revenue__c, Total_Price__c, CreatedDate FROM Opportunity_Snapshots__r Where DAY_ONLY(createdDate) >=:' + startSearch + ' AND DAY_ONLY(createdDate) <=:' + endSearch + ') FROM Opportunity WHERE (NOT Name LIKE \'Test\') AND (Account.BillingCountryCode = \'US\' OR Account.BillingCountryCode = \'CA\') AND Forecastable__c = true AND Forecasted_Close_Date_30_60_90__c <> null ORDER BY Account.Name' ;
        SearchResults = Database.query(qry);
        return null;
    }
    
    // Defines Wrapper data types
    public class ForecastWrapper {
        public String month {get;set;}
        public String[] territories {get;set;}
    }
}
  • February 18, 2020
  • Like
  • 0
Okay fellas, this one is a toughie.

I have a trigger that is before update on object A. I have a field on the same object which is updated by a process.

I need to somehow make an if statement in the trigger NOT to fire if the value in the field is changed. This is a before update trigger. Is it even possible?
Hello,

I am facing this issue in many out of the box LWC components. I am trying to change the style of text area by defining a css class. But it is failing to override the slds style at run time? Any idea?
 
<template>
    <div class="row slds-m-vertical_large">
        <h2 class="header">Basic Examples</h2>
        <lightning-textarea 
        name="input1" 
        label="Enter some text"
        class="mytextarea">
        </lightning-textarea>
    </div>
</template>

.mytextarea{
    height: 150px;
}

You can find this live at : https://developer.salesforce.com/docs/component-library/tools/playground/QWa-zfwxW/1/edit
  • August 07, 2019
  • Like
  • 0
i am trying to deactivate the users and send and email for the same , but i am getting the error.Please suggest 

Try{
            
            update Userdeactivated;
            system.debug(Userdeactivated);
            sendemailalert(Userdeactivated);
           
        }
        Catch(Exception e){
            System.debug(e);
        }
        
 }
    Public void sendemailalert(list<user> userr) {
        Integer i =1;
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        List<String> ToAddress = new List<String>();
      
        String[] finalemail = a.email__c.split(','); 
        
        
        system.debug(finalemail.size());
        for(Integer p = finalemail.size();p>0;p--){
            
            Toaddress.add(finalemail[p-1]);

            }
        message.setToAddresses(Toaddress);
        
        message.subject = 'Notification for the users deactivated  Today';
         String plainTextBody = 'List of the Users deactivated due to 90 days of inactivity: ';
                              
        for(Integer n = userr.size();n>0;n--){
               
              plainTextBody += '\n'+i+')Name: '+userr[n-1].name+ ' ,UserName: '+userr[n-1].username+' \n';
               i++;
               system.debug(userr[n-1].name);
               system.debug(userr[n-1].username);
        }
         message.setplainTextBody(plainTextBody);
         
         Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {message};

         Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);

         if (results[0].success) {

         System.debug('The email was sent successfully.');

         } 
         else {

             System.debug('The email failed to send: ' + results[0].errors[0].message);

         

}
 
We are trying to deploy an un-managed package from one Dev org to another. The source has Person account enabled and target does not have Person account. We are not using any feature provided by Person account or standard Account. All the objects, pages, controllers in this package are custom developed. What is the best way to deploy this package in target organization?
  • April 13, 2016
  • Like
  • 0