• karthikeyan perumal
  • PRO
  • 3768 Points
  • Member since 2015

  • Chatter
    Feed
  • 103
    Best Answers
  • 0
    Likes Received
  • 4
    Likes Given
  • 1
    Questions
  • 681
    Replies
Hey all, I'm absolutely NOT a developer so this is probably straightforward ... looking for some help on trigger code. Basically I need to catch if an incoming email does NOT have a user record. This works as expected if the email has a user attached to it, posts correctly, but the else statement just never happens if the user does not exist, throws a list exception error. What am I doing wrong? Thanks!
 
public class EmailMessageCopyToCaseCommentsTrigger
{
    public static void copyEmailMessagesToCaseComments(List<EmailMessage> emails)
    {
        List<CaseComment> comments = new List<CaseComment>();
        for (EmailMessage email:emails)
        {
            Id caseId = email.ParentId;
            CaseComment comment = new CaseComment(ParentId=caseId);
            comment.IsPublished=true;
           Id UserDetails = [select id from user where email = :email.FromAddress].get(0).Id;
           String strId=Id.valueOf(UserDetails);
            if (!string.isEmpty(strId)){
                    comment.CreatedbyID = UserDetails;}
            else {comment.CreatedbyID = '0054x000005MWmAAAW';}
               
            String header = 'From: '+ email.FromName + ' <' + email.FromAddress + '>\n';
            header += 'To: '+ email.ToAddress + '\n';
            header += email.CcAddress!=null?'CC: '+ email.CcAddress + '\n\n':'\n';
            if (email.TextBody!=null) {
                comment.CommentBody = header + email.TextBody;
            } else if (email.HtmlBody!=null) {
                comment.CommentBody = header + email.HtmlBody.replaceAll('\\<.*?>','');
            }
            
            comments.add(comment);
        }
        
        if (!comments.isEmpty())
        {
            insert comments;
        }
    }

 
We have some software that attempts to log into Salesforce and get information from Salesforce on purchase orders. This was working until we updated the Windows OS to Server 2012 R2 from Server 2008 R2.

The login fails with a "The request was aborted: Could not create SSL/TLS secure channel" error.

It appears that the software uses a Salesforce web service to login and get the data.

How can this error be diagnosed? Is there documentation that explains how to use the web service and any computer configuration that is required?

I did not write the code so my knowledge is quite limited in this area.
I'm creating a visualforce page that displays data for confirmation when changes are made to a record and I wanted an email to be triggered when the changes are confirmed/ submitted. I added a picklist to the object and reference it in the page using

<td><apex:inputField value="{!RMA__c.Changes_have_been_review__c}"/>        
            </td>

It shows up fine and has the values from the picklist field but whenever you select your value and hit submit it doesn't update the objects field. 

Any help would be appreciated.

-Tyler
I am using equals and hashcode methods. I am unable to include hashcode method in test class.
public class WrapperClassWrapperClass
{
    public string lastName;
    public string email;
    public string phone;
    public string company;
    public string ownerid;
    public WrapperClassWrapperClass(string leadName , string leadEmail, string leadphone , string leadcompany, string leadOwnerId){
            this.lastName = leadName != null ? leadName:null;
            this.email = leadEmail !=null ? leadEmail:null;
        	this.phone = leadphone != null ? leadphone:null;
        	this.company = leadcompany != null ? leadcompany:null;
        	this.ownerid = leadOwnerId != null ? leadOwnerId:null;
        }
    public Boolean equals(Object obj) {
        if (obj instanceof WrapperClassWrapperClass) {
            WrapperClassWrapperClass p = (WrapperClassWrapperClass)obj;
            return ((((lastName==p.lastName) && (email==p.email) && (phone==p.phone) && (company==p.company))||
                    (((lastName==p.lastName) &&  (company==p.company)) &&
                     ((email==p.email) || (phone==p.phone))))&& ownerid==p.ownerid);
        }
        return false;
    }
    public Integer hashCode() {
        return !test.isRunningTest() ? (1 * (lastName.hashCode() + phone.hashCode() + company.hashCode() + ownerid.hashCode())) ^ email.hashCode() : 123456;     
    }
}

I am calling using this wrapper class in a trigger.
 
Hi, I created a VF page and loaded Google GeoChart with static data and it worked fine. But then I wrote a controller to query the db as AggerateResult. Now my map does not work when I loop though the AggregateResult in VF page to populate the data for GeoChart.

I’m new to coding and not sure if I’m referencing the Aggregate Result properly in Vuisualforce page. Please help.

Here is the apex code:
public with sharing class testCon 
{
    Public AggregateResult[] myData{get; set;}
    Public Integer Count{get; set;}
   
    Public testCon()
    {     
       myData = [SELECT Collateral_State__c  State, Count(Name) NbrOfCollaterals FROM 
                        Collateral__c where Overall_Status__c = 'Active' and                                                              Collateral_State__c != null group by Collateral_State__c ];
       Count = Integer.valueOf(myData.size());
    }
  
    Public AggregateResult[] getmyData()
    {
       return myData;
    }
}

Here is the VF code:
<apex:page controller="testCon" readOnly="true">
    <apex:includeScript value="https://www.gstatic.com/charts/loader.js" />
    <apex:includeScript value="https://www.google.com/jsapi" />
    
    <script type="text/javascript">
        google.charts.load('current', {
        'packages':['geochart'],'mapsApiKey': 'MyKey'
      });
       
        var cnt = {!Count};
       
         google.charts.setOnLoadCallback(drawRegionsMap);
   
        function drawRegionsMap() {
   
            
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'State');
            data.addColumn('number', 'Number of Collaterals');
            
            data.addRow(['Illinois',1]); // Just a sample static data for illustration
           
            for(AggregateResult rs : {!myData})
            {
                data.addRow([rs.State,rs.NbrOfCollaterals]);
            }
            
            var options = {
            region: 'US',
            displayMode: 'markers',
            backgroundColor: '#75a3e7',
            datalessRegionColor: '#f2f2f2',
            colorAxis: {colors: ['green', 'blue']
      
            }
      };

  
     //Getting the GeoChart Div Container
       var chart = new 
       google.visualization.GeoChart(document.getElementById('chart_div'));
 
     //Drawing the GeoChart with Data and Options
       chart.draw(data, options);
  }
   
   </script>
   <div id="chart_div" style="width: 900px; height: 500px;"></div>
</apex:page>

The part of the VF code which is an issue is:
 
for(AggregateResult rs : {!myData})
 {
        data.addRow([rs.State,rs.NbrOfCollaterals]);
 }

 
what settings can be transferred threw metadata api
          web to case 
          web to lead
          case settings
          lead conversion
Please let me know the answer for the above question?

Good afternoon people,

I have a list of records in a custom metadata and need to list them in a pickilist of a form of a component that I'm creating. Could someone help me with a code?

Thanks

 

<!-- Subscription Table -->
<div class="slds-scrollable_y" style="height: 30rem;">
	<table class="slds-table slds-table_bordered">
		<tbody>
			<aura:iteration items="{!v.subscriptions}" var="sub">
				<tr class="slds-hint-parent">
					<td>
						<div class="slds-grid">
							<div class="slds-col slds-size_1-of-8 slds-p-left_small" ondblclick="{!c.editOn}">
								<aura:if isTrue="{!v.edit}">
									<ui:inputCheckbox value="{!sub.subscribed}"/>
									<aura:set attribute="else">
										<ui:outputCheckbox value="{!sub.subscribed}"/>
									</aura:set>
								</aura:if>
							</div>
							<div class="slds-col slds-size_7-of-8 slds-text-align_left slds-has-flexi-truncate">
								<p class="slds-truncate" title="{!sub.productName}">
									{!sub.productName}
								</p>
							</div>
						</div>
					</td>
				</tr>
			</aura:iteration>
		</tbody>
	</table>
</div>
<!-- Subscription Table -->
User-added image
I'm developing a component that allows users to mass subscribe customers to Product email alerts. I want the listed product names to truncate once the length reaches the width of the component. However, the names are currently extending past the component and not truncating as expected. I've attached the portion of my markup in question and the resulting component. Any and all help is appreciated.

Thanks
Hi,
I'm trying to test a class wher I get current User Ip
@AuraEnabled    
public static String GetUserIPAddress() {
string ReturnValue = Auth.SessionManagement.getCurrentSession().get('SourceIp');

return ReturnValue;
} // GetUserIPAddress



Test class:

 public static testmethod void Test1()
 {System.runAs(new User(Id = UserInfo.getUserId())){
     
     String ip = siteLeadForm.GetUserIPAddress();}
       
        

    }

In sandbox it is ok, but in production I receive this error:
System.UnexpectedException: Current session unavailable 
Stack Trace: Class.Auth.SessionManagement.getCurrentSession: line 5, column 1 Class.siteLeadForm.GetUserIPAddress: line 18, column 1 Class.siteLeadFormTEST.Test1: line 17, column 1


Any Ideas?
thankyou in advance

Hi guys, I'm wondering of how I am going to write a Test Class for Apex Class and a Trigger. This is just a simple Class and a Trigger please see below exact codes I am using.

trigger LeadUpdateListener on Lead (after update) {

    for ( Lead updatedLead : Trigger.New ) {
        CalloutExternal.pipelineConnect(updatedLead.Id);
	}
    
}
public class CalloutExternal {

    @future(callout=true)
    
    public static void pipelineConnect (String id) {
        
        String token = 'xxxxxxxxx';
        
        HttpRequest request = new HttpRequest();
        String endpoint = 'https://xxx.xxxxxxx.com/trigger/'+ token + '/' + id;
        request.setEndpoint(endpoint);
        request.setMethod('GET');
               
        HttpResponse response = new HTTP().send(request);
        
        System.debug('xxxx Response...' + response);
    }

}
I tried creating a Test Class but it doesn't let me through. If anyone who could show me here that would be much appreciated. Thank you!
global class CsvFileExporter implements System.Schedulable {
   global void execute(SchedulableContext sc) {
List<Account> accList = [Select Id,Name, AccountNumber, Industry, CreatedDate,LastModifiedDate,Phone from Account where CreatedDate=TODAY];
       List<Account> latestModiaccList = [Select Id,Name, AccountNumber, Industry, CreatedDate,LastModifiedDate,Phone from Account where LastModifiedDate=TODAY AND CreatedDate !=TODAY];

       String header = '\bAccounts inserted Today\b\r\n'+ '\bId, Name, Account Number, Industry,Phone\b\r\n';
       String header1 ='\r\n\bAccounts Modified Today\b\r\n'+ '\bId, Name, Account Number, Industry,Phone\b\r\n';
String generatedCSVFile = header+'';
List<String> queryFields = new List<String>{'Id','Name','AccountNumber','Industry','Phone'};
       String fileRow = '';
for(Account a: accList){            
fileRow = '';
fileRow = fileRow +','+ a.Id;
fileRow = fileRow +','+ a.Name;
       fileRow = fileRow +','+ a.AccountNumber;
fileRow = fileRow +','+ a.Industry;
       fileRow = fileRow +','+ a.Phone;
fileRow = fileRow.replaceFirst(',','');
generatedCSVFile = generatedCSVFile + fileRow + '\n';
}
       generatedCSVFile = generatedCSVFile+header1+'';
       for(Account ac: latestModiaccList){
fileRow = fileRow +','+ ac.Id;
fileRow = fileRow +','+ ac.Name;
        fileRow = fileRow +','+ ac.AccountNumber;
fileRow = fileRow +','+ ac.Industry;
        fileRow = fileRow +','+ ac.Phone;
           fileRow = fileRow.replaceFirst(',','');
           generatedCSVFile = generatedCSVFile + fileRow + '\n';
       }
       system.debug('File:'+generatedCSVFile);
Messaging.EmailFileAttachment csvAttachment = new Messaging.EmailFileAttachment();
Blob csvBlob = blob.valueOf(generatedCSVFile);
String csvName = 'Accounts data inserted and modified Today.csv';
csvAttachment.setFileName(csvName);
csvAttachment.setBody(csvBlob);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[]{'ranga.vangalapudi@gmail.com'};
String subject = 'Accounts data inserted and modified Today';
email.setSubject(subject);
email.setToAddresses(toAddresses);
I want to use 2 constructors within my Controller class, one for a VF component and another for VF page.is it possible to have the same SOQL within 2 constructors.Please give an example
Hello, I've just started to learn about Apex and I'm having difficulty writing a test class for the following Apex class. 

The following Apex class has code to retrieve Account records and logic to iterate over a list of Account records and update the Description field.  I learned this Apex class through Trailhead and wanted to write a test class for it but couldn't figure out how.
public class OlderAccountsUtility {
    public static void updateOlderAccounts() {
      // Get the 5 oldest accounts
      Account[] oldAccounts = [SELECT Id, Description FROM Account ORDER BY CreatedDate ASC LIMIT 5];
      // loop through them and update the Description field
      for (Account acct : oldAccounts) {
          acct.Description = 'Heritage Account';
      }
      // save the change you made
      update oldAccounts;
    }
}
This is what I have written.  Can anyone show me how to fix this Apex test unit so it works?  Any help would be much appreciated!
@isTest
private class OlderAccountsUtilityTest {
    
    @isTest static void createAccount() {
    
    List <Account> accts = new List<Account>();
      for(integer i = 0; i<200; i++) {
         Account a = new Account(Name='testAccount'+'i');
         accts.add(a);
    }
        
   	insert accts;

    Test.StartTest();	
        
        List<Account> accList = [SELECT Id, Description FROM Account ORDER BY CreatedDate ASC LIMIT 5];
     
 		for (Account acct : accList) {
        acct.Description = 'Heritage Account';
        }

    Test.StopTest();

	System.AssertEquals(
    
    	database.countquery('SELECT COUNT() FROM Account WHERE Description' = 'Heritage Account'), 5);
             
    }
}

 
Hello,
I have a batch job which runs to populate two objects.. Monthly Activity(MonAct) and URL Individual monthly Activity (URLIndMonAct)...
The problem with the response is that I am quering for MonAct records and I am getting back 5 of them . And each of those MonAct records contains with it thousands of URLIndMonAct records...

I have limited my query to just 2 records per batch but I am still getting DML Rows : 10001 error ..
If I redice the size to 1 record, the batch is running for too long...

Can any one please guide me, how can I modify my code to prevent this error and not lose any records while processing...
Any help is appreciated.

Thanks!
global class BatchToUpdateGARecords implements Database.Batchable<sObject>, Database.Stateful, Schedulable, Database.AllowsCallouts{

    private List<String> EMAIL_BATCH_RESULTS = new List<String>{System.Label.Email_List};  
    global  IndividualMonthlyGARecords.BatchResponse runningBatchResponse;
    private String query;
    private Integer queryYear;
    private Integer queryMonth;

    global BatchToUpdateGARecords(Integer year, Integer month){
        runningBatchResponse = new IndividualMonthlyGARecords.BatchResponse();

        // Validate user input, if request to run batch is not for todays date
        if(month != null && year != null && month >= 0 && month <= 12 && year > 1950){
            this.queryYear  = year;
            this.queryMonth = month;
        }
        else{
            Date yesterdaysDate = Date.today().addDays(-1);

            this.queryYear  = yesterdaysDate.year();
            this.queryMonth = yesterdaysDate.month();
        }

        this.query  = 'SELECT Id, GID__c ';
        this.query += 'FROM Monthly_Activity__c ';
        this.query += 'WHERE Year__c = ' + queryYear + ' ';
        this.query += 'AND Month__c = ' + queryMonth + ' ';
        this.query += 'AND GID__c <> null ';
        this.query += 'AND GID__c > 0 ';
        
    }

    global BatchToUpdateGARecords(){
        this(null, null);
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Monthly_Activity__c> currentBatchRecords){
	
        List<Monthly_Activity__c> MonthlyActivities = [
            SELECT Id, GID__c, Month__c, Year__c
            FROM Monthly_Activity__c 
            WHERE Year__c =: queryYear
            AND Month__c =: queryMonth
            AND GID__c IN: Pluck.decimals('GID__c', currentBatchRecords)
        ];        

        List<URL_Individual_Monthly_Activity__c> urlIndividualMonthlyActivities = [
            SELECT Id, GID__c, URL__c, Month__c, Year__c
            FROM URL_Individual_Monthly_Activity__c 
            WHERE Year__c =: queryYear
            AND Month__c =: queryMonth
            AND GID__c IN: Pluck.decimals('GID__c', currentBatchRecords)
        ];        
         
        if(MonthlyActivities.isEmpty()){
            return;
        }
    
        try{           
            IndividualMonthlyGARecords.batchHandlerToUpdateRecords(
                runningBatchResponse,
                MonthlyActivities,
                urlIndividualMonthlyActivities,
                queryYear,
                queryMonth
            );
        
       }catch(exception ex){
            system.debug('exception call :'+ ex.getMessage());
            system.debug('exception call line :'+ ex.getStackTraceString());
        }
        if(runningBatchResponse != null && !runningBatchResponse.getSuccessRecords().isEmpty()){
            List<Database.SaveResult> updateResults =
                Database.update(runningBatchResponse.getSuccessRecords(), false);

            for(Database.SaveResult updateResult : updateResults){
              if(!updateResult.isSuccess()){
                for(Database.Error err : updateResult.getErrors()){
                  runningBatchResponse.addDatabaseError(err.getMessage());
                }
              }
            }
        }

        runningBatchResponse.clearSuccessRecords();
    
        if(runningBatchResponse != null && !runningBatchResponse.getSuccessRecordsIMA().isEmpty()){

            List<Database.SaveResult> updateResults1 =
                Database.update(runningBatchResponse.getSuccessRecordsIMA(), false);

            for(Database.SaveResult updateResult1 : updateResults1){
              if(!updateResult1.isSuccess()){
                for(Database.Error err : updateResult1.getErrors()){
                  runningBatchResponse.addDatabaseError(err.getMessage());
                }
              }
            }
        }

        runningBatchResponse.clearSuccessRecords();
  
    }

    global void execute(SchedulableContext SC){
        Database.executeBatch(new BatchToUpdateGARecords(), 2);                            //Changed from 5    }
    
    global void finish(Database.BatchableContext BC){
        AsyncApexJob apexBatchResult = [
            SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email
            FROM AsyncApexJob
            WHERE Id =: BC.getJobId()
        ];
    
        // Generate email body
        String emailBody = 'Apex Batch to Update PageviewSessions processed '
            + apexBatchResult.TotalJobItems + ' batches with '+ apexBatchResult.NumberOfErrors + ' failures.\n\n'
            + 'Database errors (if any): ' + JSON.serialize(runningBatchResponse.getDatabaseErrors()) + '\n';
        
        // Extract error string from batch response
        //emailBody += runningBatchResponse.generateErrorString();

        // Send email
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(EMAIL_BATCH_RESULTS);
        mail.setSenderDisplayName('About.com Experts - Batch Results');
        mail.setSubject('About.com - Batch to Update PageviewSessions - status: ' + apexBatchResult.Status);
        mail.setPlainTextBody('Batch Process has completed\n\n' + emailBody);

        Messaging.sendEmail(new List<Messaging.SingleEmailMessage>{mail});
    }
}

 
I am trying to write a trigger on my Lead Object that will not allow a user to click Convert unless a boolean field is True. I need help with some sample code to get started. 

I plan to create an Approval Process on the lead record, then with the final Approver action have a field update to have my custom checkbox (Approved) set to True. 

Once this happens I want the user to be able to click Convert, but only once the checkbox is set to true. If it has not gone through the approval process, the user shoudnt be able to click convert. 

I should also note I would only want this for a specific record type of my lead object.
Can you send data (via SOAP) out from Sandbox to another System (not Salesforce)?
#newbie
Do requests with the If-None-Match header, that return a 304 response, count towards my API limit?
So I have an issue with a flow.  When I did a test it worked but now its not and I have no idea why.  The error message makes very little sense to me but appears to be an issue with the student field?

Can anyone help me with this:
Error element myRule_1_A1 (FlowRecordCreate).
This error occurred when the flow tried to create records: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: Meal_Transaction_AIAIAD: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0 Trigger.Meal_Transaction_AIAIAD: line 24, column 1. For details, see API Exceptions.
This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Payment_Meals_Update_Ver_3
Type: Workflow
Version: 1
Status: Active
Flow Interview Details
Interview Label: Payment_Meals_Update_Ver_3-1_InterviewLabel
Current User: Scott Walker (00XX000000#XXXXXXX)
Start time: 4/3/2017 4:46 PM
Duration: 0 seconds
How the Interview Started
Scott Walker (00X0000000000) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = null
myVariable_current = a00000000aa0000008
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "4/3/2017 4:46 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Payment_for__c} (Lunch Billing) Equals Lunch Billing
Logic: All conditions must be true (AND)
RECORD CREATE: myRule_1_A1
Create one Meal_Transaction__c record where:
Student__c = {!myVariable_current.Student__c} (null)
Transaction_Amount__c = {!myVariable_current.Amount_Paid__c} (1)
Transaction_Date__c = {!myVariable_current.CreatedDate} (4/3/2017 4:46 PM)
Transaction_Type__c = Credit
Result
Failed to create record.

Error Occurred: This error occurred when the flow tried to create records: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: Meal_Transaction_AIAIAD: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0 Trigger.Meal_Transaction_AIAIAD: line 24, column 1. For details, see API Exceptions.

I have mapped the fields and I believe they are correct, as follows:

User-added image

the fields on the right are:

Student__c
Amount_Paid__c
CreatedDate


Any help really appreciated I really need to get this to work
 
We have users in both Classic and Lightning using the standard "New" button on leads.  I need to override the standard "New" button and redirect the user to a lightning app.  I created a VF page action that will redirect the user to the lightning app.  Everything works great however for lightning users, the redirect opens a new tab in the browser.  How do I keep the redirect on the same browser window in lightning?  Do I need to create a VF page pulling in a lightning component?
My salesforce for outlook account was automatically logged out but when I click to log back in and enter my credentials I get this message: 
User-added image
 
Hey all, I'm absolutely NOT a developer so this is probably straightforward ... looking for some help on trigger code. Basically I need to catch if an incoming email does NOT have a user record. This works as expected if the email has a user attached to it, posts correctly, but the else statement just never happens if the user does not exist, throws a list exception error. What am I doing wrong? Thanks!
 
public class EmailMessageCopyToCaseCommentsTrigger
{
    public static void copyEmailMessagesToCaseComments(List<EmailMessage> emails)
    {
        List<CaseComment> comments = new List<CaseComment>();
        for (EmailMessage email:emails)
        {
            Id caseId = email.ParentId;
            CaseComment comment = new CaseComment(ParentId=caseId);
            comment.IsPublished=true;
           Id UserDetails = [select id from user where email = :email.FromAddress].get(0).Id;
           String strId=Id.valueOf(UserDetails);
            if (!string.isEmpty(strId)){
                    comment.CreatedbyID = UserDetails;}
            else {comment.CreatedbyID = '0054x000005MWmAAAW';}
               
            String header = 'From: '+ email.FromName + ' <' + email.FromAddress + '>\n';
            header += 'To: '+ email.ToAddress + '\n';
            header += email.CcAddress!=null?'CC: '+ email.CcAddress + '\n\n':'\n';
            if (email.TextBody!=null) {
                comment.CommentBody = header + email.TextBody;
            } else if (email.HtmlBody!=null) {
                comment.CommentBody = header + email.HtmlBody.replaceAll('\\<.*?>','');
            }
            
            comments.add(comment);
        }
        
        if (!comments.isEmpty())
        {
            insert comments;
        }
    }

 
This is for my project. I created a field that would fetch a formula field's value and store it in. It was working fine until I changed the API name of one field, which was used in the formula of the formula field. I did update it, but it isn't working anymore. Help?

Error:
Assembly Number is a fomula field which is generated based on Assembly Digit 1, Assembly Digit 2,3 and Assembly Digit 4,5,6&7. It is working fine. And then i have added one trigger to copy the Assembly Number (or any of the four total such fields, any one of which would have any value) and store it in Part Number field. But it is copying only partially. On updating the record, it takes the other numeric half of the Assembly Number as it's value.
User-added image

Formula Code in Assembly Code formula field to generate Assembly Code:
IF(ISPICKVAL(Assembly_Digit_1__c, ""),'', CASE(Assembly_Digit_1__c,
"M - MECHANICAL",'M',
"E - ELECTRICAL",'E',
'X')) +

IF(ISPICKVAL(Assembly_Digit_2_3__c, ""),'', CASE(Assembly_Digit_2_3__c,
"01 - Guide Bracket Assy-Car",'01',
"02 - Guide Bracket Assy- Cwt/Combined",'02',
"03 - Tee Guide Assy-Car",'03',
"04 - Tee Guide Assy-Cwt",'04',
"05 - Guide Base Assy-Car",'05',
"06 - Guide Base Assy-Cwt",'06',
"07 - Landing Sill Assy",'07',
"08 - Landing Entrance Assy",'08',
"09 - Landing Door Assy",'09',
"11 - Emergency key",'11',
"12 - Counterweight Frame Assy",'12',
"13 - Concrete Fillers",'13',
"14 - Cast Iron Fillers",'14',
"15 - CWT Guide Shoe Assy",'15',
"16 - Eye bolt Assy - Cwt",'16',
"17 - Cwt Divertor Assy",'17',
"18 - CWT Guard Assy",'18',
"19 - Machinery Unit Assy",'19',
"20 - Isolation Rubber",'20',
"21 - Machine Room Divertor Assy",'21',
"22 - Car Sling Assy",'22',
"23 - Car Guide Shoe Assy",'23',
"24 - Car Suspension Assy",'24',
"25 - Car Divertor Assy",'25',
"26 - Suspension Rope Assy",'26',
"27 - Car Body Assy",'27',
"28 - Car gate contact fixing bracket Assy",'28',
"29 - Car gate contact Assy",'29',
"30 - Car door/Cabin Assy",'30',
"31 - Toe Guard",'31',
"32 - OSG Assy",'32',
"34 - OSG Rope Assy",'34',
"35 - Controller Assy",'35',
"36 - Wiring Materials",'36',
"37 - Buffer Spring-Car",'37',
"38 - Buffer Spring-Cwt",'38',
"39 - COP Assy",'39',
"40 - Retiring Cam & Bracket Assy",'40',
"41 - TLS Assy",'41',
"42 - TLS Cam Assy",'42',
"43 - Name Plate Assy",'43',
"44 - Cabin Light Assy",'44',
"45 - Inspection Panel Assy",'45',
"46 - Oscillator Switch",'46',
"47 - LPB Assy",'47',
"48 - Reed Switch Assy",'48',
"49 - Voice announciator",'49',
"50 - Machine Beams",'50',
"54 - D&P Indicator Assy",'54',
"55 - Fireman Switch Assy",'55',
"57 - Car Balance Weight & Fixing Assy",'57',
"58 - Automatic Rescue Device Assy",'58',
"59 - Floor Announciator",'59',
"62 - Seperator Channel",'62',
"63 - Power Door Safety Assy",'63',
"65 - Emergency Light Assy",'65',
"66 - Instructions Display Boards",'66',
"67 - Emergency Alarm Box",'67',
"68 - Consumables",'68',
"69 - Tools",'69',
"70 - Fasteners",'70',
"71 - PPE items",'71',
"72 - Pit",'72',
"73 - Compensating Chain",'73',
"74 - Packing Materials",'74',
"75 - Machine Room",'75',
"76 - Flame Proof or Explosion Proof",'76',
"77 - Scrap Boughtout",'77',
"78 - Scrap Manufacturing",'78',
"79 - Structure",'79',
'00')) +

IF(ISBLANK(Assembly_Digit_4_5_6_7__c),'', Assembly_Digit_4_5_6_7__c)
Trigger to update Part Number field:
trigger UpdatePartNumber on Part_Number_Creation__c (before insert, before update) {
    for(Part_Number_Creation__c PartList: trigger.new){
        if(PartList.IndividualPartNumber__c!=null){
            PartList.Part_Number__c=PartList.IndividualPartNumber__c;
        } else if(PartList.AssemblyNumber__c!=null){
            PartList.Part_Number__c=PartList.AssemblyNumber__c;
        }else if(PartList.KitNumber__c!=null){
            PartList.Part_Number__c=PartList.KitNumber__c;
        }else if(PartList.RawMaterialNumber__c!=null){
            PartList.Part_Number__c=PartList.RawMaterialNumber__c;
        }else{
            PartList.Part_Number__c='';
        }
    }
}

i am confused as to why is this kind of error is happening. This seem to be logically right. Help anyone?

 
I have these addresses Inbound, Outbound, and Billing Information. Inbound is the current address: set default billing, set default shipping address. I want that if I go to Outbound shipping and click the "Edit Address" and tick "Make Default" checkbox, the amended Address should show in the Addresses list view and the "Default Shipping" is ticket on the list view BUT this is not working. Same with Billing Information, if I click "New Address" and check the "Make Default," the new address should be added in the Addresses list view and the Default Billing should be ticked BUT this is also not working. What is happening now is that the current address that was set to default billing, default shipping is still the one having the tick in default shipping and default billing even if there is an amended address and new default billing.
User-added image
User-added image
Here is my code in AURA:
Cmp:
User-added image
Controller:
User-added image
Helper:User-added image

I want to get the Id of the Parent From the related List View, as I have made aura CMP Which override
NEW button ,when  I press New button it redirect me different page , so component.get("v.recordId")
is UNDEFINED.
I have created 4 queues for case object and assigned few users under each queue.
system admins are able to change the case owner to queue, but not non system admion users.
non system admin users have trasfer case and edit case access, they are able to transfer to other users but not queue.
when they search for the queue name it returns empty, any idea where it would have went wrong?
my UI team has an Internal React Library which we want to use to uniform the Force.com site styles similar to React js library styles.
I have react native library bundle but don't know how I can use that in VF Page.
The idea is to copy the styles of button, picklist and banners from react js.
Can someone please direct me to a document or link to understand the usage or help me on how to do it.

Hi Team,

Can it be possible to call wired method in another wired method.
Sporadically the name value is being sent to Apex class empty, i am thinking this might be because of the order of invoking the wired is not coming before the getrecord. Is there any way to call one wired function in another wired method.

Attaching the sample code.
Thanks for your help with this.
Thanks and Regards,
Venkata.

import {getRecord} from 'lightning/uiRecordAPi';
import dataBasedonName from 'apex/class/test.getName;

@track name;
@api recordId;
@wire (getRecord,{recordId:$recordId,fields:['Name']}
wiredInfo({data}){
   if (data)
{
  this.name=data.fields.name;
}
}

@wire (dataBasedonName,{name:$name})
wiredNameList({data}){
if(data){

}
}

Hey guys: I'm getting an error on my scratch org when I run the force:source:pull/push commands on my Mac terminal.

The error is: 

(node:1196) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 response listeners added. Use emitter.setMaxListeners() to increase limit

Tried:

  • It happens in a brand new scratch org that I created for troubleshooting this issue.
  • It happens after uninstalling/reinstalling SFDX
  • It happens when I install using npm.
  • At some point in my scratch org, I noticed a "Logged in too many times" error, so upon checking my login history for one attempt, I get 75 login attempts within a minute's timeframe.

This started happening fairly recently, as I have been working in my scratch org for the past month. It only started yesterday.

It doesn't happen when I run sfdx force:org:list. I get the expected list of several orgs.

Has anybody else come across this?

Hi All,
    I am looking for a solution to replace all newline character occuring between two double quotes. I have already referred below URL  https://stackoverflow.com/questions/26337474/regexp-to-find-replace-newlines-within-double-quotes-not-affecting-newlines-out and tried to execute below code but seems like something is missing. 

String rawString = Label.TestLable;
String result = rawString.Replace('([^"\n]*)\r?\n(?!(([^"]*"){2})*[^"]*$)/g', '<br>');

The TestLabel custom label has string with multiple newline characters and enclosed within double quotes below:

"
Hello Team
Requesting you to join us at marathod event happening at below venue

"

And the out put expected is:
Hello Team <br>Requesting you to join us at marathod event happening at below venue


 
Hi Team,

I have a wrapper class in my apex controller.
 
global class variableDTO {
        @AuraEnabled
        public String bkImgURL { get; set; }
        @AuraEnabled
        public List<String> monthListBefore {get; set;}
}

And I am trying to to access the monthListBefore list in LWC. My code is below.
 
@track background; 
@track MonthList;

@wire(getAllDTOs) wrappers ({
        error,
        data
    }) {
        if(data) {
            this.objects = data;
            this.background = data[0].bkImgURL;
            this.MonthList = data[0].MonthListBefore;
            console.log(this.background );
            console.log(this.MonthList );
        

        } else {
            this.error = error;
        }
    }
Here I got value for this.background but I got undefined for this.MonthList. Is there anything wrong in my code?

I got value MonthListBefore in json when I debug.
"monthListBefore":[ 
"Avr",
"Mai",
"Jui",
"Jui",
"Aoû",
"Sep",
"Oct",
"Nov",
"Déc"
],

Thank you.

 
that apex class using update the record fields
Hi Team,

I have for-each loop in my LWC component. And I want to check below condition inside  the loop.
 
<template for:each={object.MonthListBefore} for:item="month" >
      <template if:true={month == 'Jan'}> 
       <li key={object.Id} class="year">{object.currentYear}</li>       
</template>
</template>



But this is not working.  I am not sure how could I use the arithmetic comparison in HTML file of LWC. Could anyone please help me to resolve this?
I have the following method that has been working fine until today, I have not changed anything with the code.

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); if(cc != null) { mail.setCcAddresses(cc); } mail.setToAddresses(toAddresses); mail.setReplyTo('******'); mail.setSenderDisplayName('Salesforce Messaging'); mail.setSubject(subject); mail.setHtmlBody(htmlBody); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

When I try to deploy I get:
Error: Compile Error: Method does not exist or incorrect signature: void sendEmail(List) from the type Messaging

This started today in both Sandbox and Production.

Does anyone know whats going on?
  • November 25, 2019
  • Like
  • 0
Created my first VF Page today.
How do I get rid of the white space that takes up half of the component in a Lightning page?

User-added image
Hi All,

Help me on this issue
I am trying to do now apex code.later i will start doing Batch apex.

public PageReference SendEmail()
    {
        List<user>userlist=[select id,name,email,lastlogindate from user where lastlogindate < last_N_days:38];
        List<Id> lstids= new List<Id>(); 
        for(User c:userlist) { 
            lstids.add(c.id);
        }         
        EmailTemplate et=[Select id from EmailTemplate where name = 'EmailTemplatename' limit 1];  
        Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage(); 
        mail.setTargetObjectIds(lstids); 
        mail.setSenderDisplayName('System Admin'); 
        mail.setTemplateId(et.id); 
        Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail }); 
        return null;
    } 
Hi, I created a VF page and loaded Google GeoChart with static data and it worked fine. But then I wrote a controller to query the db as AggerateResult. Now my map does not work when I loop though the AggregateResult in VF page to populate the data for GeoChart.

I’m new to coding and not sure if I’m referencing the Aggregate Result properly in Vuisualforce page. Please help.

Here is the apex code:
public with sharing class testCon 
{
    Public AggregateResult[] myData{get; set;}
    Public Integer Count{get; set;}
   
    Public testCon()
    {     
       myData = [SELECT Collateral_State__c  State, Count(Name) NbrOfCollaterals FROM 
                        Collateral__c where Overall_Status__c = 'Active' and                                                              Collateral_State__c != null group by Collateral_State__c ];
       Count = Integer.valueOf(myData.size());
    }
  
    Public AggregateResult[] getmyData()
    {
       return myData;
    }
}

Here is the VF code:
<apex:page controller="testCon" readOnly="true">
    <apex:includeScript value="https://www.gstatic.com/charts/loader.js" />
    <apex:includeScript value="https://www.google.com/jsapi" />
    
    <script type="text/javascript">
        google.charts.load('current', {
        'packages':['geochart'],'mapsApiKey': 'MyKey'
      });
       
        var cnt = {!Count};
       
         google.charts.setOnLoadCallback(drawRegionsMap);
   
        function drawRegionsMap() {
   
            
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'State');
            data.addColumn('number', 'Number of Collaterals');
            
            data.addRow(['Illinois',1]); // Just a sample static data for illustration
           
            for(AggregateResult rs : {!myData})
            {
                data.addRow([rs.State,rs.NbrOfCollaterals]);
            }
            
            var options = {
            region: 'US',
            displayMode: 'markers',
            backgroundColor: '#75a3e7',
            datalessRegionColor: '#f2f2f2',
            colorAxis: {colors: ['green', 'blue']
      
            }
      };

  
     //Getting the GeoChart Div Container
       var chart = new 
       google.visualization.GeoChart(document.getElementById('chart_div'));
 
     //Drawing the GeoChart with Data and Options
       chart.draw(data, options);
  }
   
   </script>
   <div id="chart_div" style="width: 900px; height: 500px;"></div>
</apex:page>

The part of the VF code which is an issue is:
 
for(AggregateResult rs : {!myData})
 {
        data.addRow([rs.State,rs.NbrOfCollaterals]);
 }

 

I have multiple communities in my org.

User-added image

When I purposely try to show an error in the community it show different URL in the error message.
Community that being access is "Trial3", but the error is show as another community ("Trial").
User-added image

Why is this happening?

How to overcome this issue?

Unable to login  @ Dev Org. dectivate a flow assicated with login flow for system admin. unable to login  thrown error message while login " no active flow"
Hi,
I am new in salesforce. I have question about relationships. Is it possible to generate dynamically a generic link between objects? My scenario is to have a custom object with fields like object_id,object_name, field_id, field_name. I would like to build  links between my custom object and other objects.