• katta srini 6
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hi All,
     I had a LWC component which simply update an child (contact) record using Inline Edit. I am getting this error : Uncaught (in promise) TypeError: Cannot read property 'message' of undefined at eval (lwc_utils.js:4). I am using this LWC component Account record detail page to display associate child (contact) records. Please any one guide me how to fix this issue. 

Unable to edit this record using inline edit. Got this error
Error
Apex Class: ContactController
----------------------------------------- 
public with sharing class ContactController {
    @AuraEnabled(Cacheable = true)
    public static List<Contact> getRecords(String recordId) {        
       return [SELECT Name, Email,Phone,Maximum__c,Minimum__c FROM Contact WHERE AccountId =: recordId];
    }

    @AuraEnabled
    public static void saveContacts(List<Contact> conList){
        Insert conList;        
    } 
}
Java Script: 
----------------
import { LightningElement, track, wire, api } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import CONTACT_OBJECT from '@salesforce/schema/Contact';
import ID_FIELD from '@salesforce/schema/Contact.Id';
import FIRSTNAME_FIELD from '@salesforce/schema/Contact.FirstName';
import LASTNAME_FIELD from '@salesforce/schema/Contact.LastName';
import EMAIL_FIELD from '@salesforce/schema/Contact.Email';
import PHONE_FIELD from '@salesforce/schema/Contact.Phone';
import MAX_FIELD from '@salesforce/schema/Contact.Maximum__c';
import MIN_FIELD from '@salesforce/schema/Contact.Minimum__c';
import getRecords from '@salesforce/apex/ContactController.getRecords';
import saveContacts from '@salesforce/apex/ContactController.saveContacts';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import { refreshApex } from '@salesforce/apex';
import { updateRecord } from 'lightning/uiRecordApi';

const columns = [
    { label: 'Name', fieldName: 'Name' , type: 'Text', editable: true},
    { label: 'Email', fieldName: 'Email', type: 'Email', editable: true },
    { label: 'Phone', fieldName: 'Phone', type: 'Phone', editable: true },
    { label: 'Maximum', fieldName: 'Maximum__c', type: 'number', editable: true },
    { label: 'Minimum', fieldName: 'Minimum__c', type: 'number', editable: true },
];

export default class DatatableBasic extends NavigationMixin(LightningElement) {
@api recordId;
@track data;
@track contactList = [];
@track draftValues = []; 
@track firstName = FIRSTNAME_FIELD;
@track lastName = LASTNAME_FIELD;
@track email = EMAIL_FIELD;
@track phone = PHONE_FIELD;
@track max = MAX_FIELD;
@track min = MIN_FIELD;
@track columns = columns;
@track tableLoadingState = true;
@track noRecordsFound = true;
error;
wiredDataResult;

con = {
    FirstName : this.firstName,
    LastName : this.lastName,
    Email : this.email,
    Phone : this.phone,
    AccountId : this.recordId,
    Maximum__c : this.max,
    Minimum__c : this.min,
    key : ''
}

concCellChange(event){
    console.log(event.detail);
}

handleSave(event) {

    const fields = {};
    fields[ID_FIELD.fieldApiName] = event.detail.draftValues[0].Id;
    fields[FIRSTNAME_FIELD.fieldApiName] = event.detail.draftValues[0].FirstName;
    fields[LASTNAME_FIELD.fieldApiName] = event.detail.draftValues[0].LastName;
    fields[EMAIL_FIELD.fieldApiName] = event.detail.draftValues[0].Email;
    fields[PHONE_FIELD.fieldApiName] = event.detail.draftValues[0].Phone;
    fields[MAX_FIELD.fieldApiName] = event.detail.draftValues[0].Maximum__c;
    fields[MIN_FIELD.fieldApiName] = event.detail.draftValues[0].Minimum__c;

    const recordInput = {fields};

    updateRecord(recordInput)
    .then(() => {
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Success',
                message: 'Contact updated',
                variant: 'success'
            })
        );
        // Clear all draft values
        this.draftValues = [];
        // Display fresh data in the datatable
        return refreshApex(this.recordInput);
    })
    .catch(error => {
        this.message = undefined;
        this.error = error;
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Error creating record',
                message: error.body.message,
                variant: 'error'
            })
        );
        console.log("error", JSON.stringify(this.error));
    });
}

@wire(getRecords , { recordId: '$recordId' })  
    wiredRecordsMethod(result) {
        this.wiredDataResult = result;
        if (result.data) {
            this.data = result.data;
            this.error = undefined;
            if(this.data.length > 0){
                this.noRecordsFound = false;
            }
            else{
                this.noRecordsFound = true;
            }
   
        } else if (result.error) {
            this.error = result.error;
            this.data = undefined;
        }        
    }
}
HTML:
---------
<template>
    <lightning-card title="Contacts" icon-name="standard:Contact" > <br/>
        <div style="width: auto;">
            <template if:true={data}>   
            <div class="slds-p-around_medium lgc-bg" style="height: 300px;">
                <lightning-datatable
                        key-field="id"
                        data={data}
                        columns={columns}
                        show-row-number-column="true"
                        hide-checkbox-column="true"
                        oncellchange={concCellChange}
                        onsave={handleSave}
                        draft-values={draftValues} >
                </lightning-datatable>
                <template if:true= {noRecordsFound}>
                    --No Contact Records Found--
                </template>
            </div>  
            </template>
            
        </div>
    </lightning-card>   
</template>

Thanks
Siva

 
Hi all,

I have some apex code that looks like the code below. In my test class, I have a testMethod for successful execution, but I'm having trouble creating a testMethod for the exception. I've been able to trigger the exception, but the test is marked as Fail and I recieve "System.AuraHandledException: Script-thrown exception". As a result, I'm not getting code coverage for this exception.

How can I successfully test an AuraHandledException from a testMethod without breaking the test and having it result in a Fail?
try{
   update account;
}
catch(Exception e){
   throw new AuraHandledException('error updating account');
}

 
While working on Secure Identity and Access Management trailhead i have used authenticator.
Now that i have lost my mobile phone which has salesforce authenticator, now i am not able to login to my org.
Everytime i am trying to log in, its restricting me.
i tried to contact saleforce using help option in mydeveloper org, but the help desk is not fuctioning as per the requirement.

Hi Folks,

 

I'm trying to run an insert using Data loader with command line interface. Below is my command:

 

        C:\Program Files\salesforce.com\Data Loader\bin>process.bat "C:\Program Files\Salesforce.com" accountInsert

 

 

Below is the output:

         

2013-08-22 12:45:14,402 INFO [main] controller.Controller initLog (Controller.java:382) - Reading log-conf.xml in C:\Program Files\salesforce.com\Data Loader\bin\log-conf.xml
2013-08-22 12:45:15,651 INFO [main] controller.Controller initLog (Controller.java:391) - The log has been initialized
2013-08-22 12:45:15,687 INFO [main] process.ProcessConfig getBeanFactory (ProcessConfig.java:103) - Loading process configuration from config file: C:\program files\salesforce.com\process-conf.xml
2013-08-22 12:45:16,506 INFO [main] xml.XmlBeanDefinitionReader loadBeanDefinitions (XmlBeanDefinitionReader.java:315) - Loading XML bean definitions from file [C:\program files\salesforce.com\process-conf.xml]
2013-08-22 12:45:16,708 INFO [accountInsert] controller.Controller initConfig (Controller.java:327) - config dir created at C:\program files\salesforce.com
2013-08-22 12:45:17,117 INFO [accountInsert] controller.Controller initConfig (Controller.java:355) - The controller config has been initialized
2013-08-22 12:45:17,150 INFO [accountInsert] process.ProcessRunner run (ProcessRunner.java:116) - Initializing process engine
2013-08-22 12:45:17,150 INFO [accountInsert] process.ProcessRunner run (ProcessRunner.java:119) - Loading parameters
2013-08-22 12:45:19,342 ERROR [accountInsert] config.Config decryptProperty (Config.java:692) - Error loading parameter: sfdc.password of type: java.lang.String
javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)
at com.salesforce.dataloader.security.EncryptionUtil.decryptString(EncryptionUtil.java:210)
at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:686)
at com.salesforce.dataloader.config.Config.postLoad(Config.java:638)
at com.salesforce.dataloader.config.Config.loadParameterOverrides(Config.java:664)
at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:120)
at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:100)
at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:253)
2013-08-22 12:45:19,344 FATAL [main] process.ProcessRunner topLevelError (ProcessRunner.java:238) - Unable to run process accountInsert
java.lang.RuntimeException: com.salesforce.dataloader.exception.ParameterLoadException: Error loading parameter: sfdc.password of type: java.lang.String
at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:162)
at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:100)
at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:253)
Caused by: com.salesforce.dataloader.exception.ParameterLoadException: Error loading parameter: sfdc.password of type: java.lang.String
at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:693)
at com.salesforce.dataloader.config.Config.postLoad(Config.java:638)
at com.salesforce.dataloader.config.Config.loadParameterOverrides(Config.java:664)
at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:120)
... 2 more
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.DESCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)
at com.salesforce.dataloader.security.EncryptionUtil.decryptString(EncryptionUtil.java:210)
at com.salesforce.dataloader.config.Config.decryptProperty(Config.java:686)
... 5 more

 

 

I first need to figure out the sfdc.password error. I am encrypting with encrypt.bat, and it is a concatenated value of my salesforce password + salesforce security token. I am under the impression this is how it should be encrypted. 

 

Any advice would be greatly appreciated!

 

Thanks,

 

 

  • August 22, 2013
  • Like
  • 0
Hi all,

I have some apex code that looks like the code below. In my test class, I have a testMethod for successful execution, but I'm having trouble creating a testMethod for the exception. I've been able to trigger the exception, but the test is marked as Fail and I recieve "System.AuraHandledException: Script-thrown exception". As a result, I'm not getting code coverage for this exception.

How can I successfully test an AuraHandledException from a testMethod without breaking the test and having it result in a Fail?
try{
   update account;
}
catch(Exception e){
   throw new AuraHandledException('error updating account');
}