• Siva Sakthi
  • NEWBIE
  • 185 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 92
    Questions
  • 86
    Replies
Hello everyone,

Here is my issue: Modal
Basically I have a Modal in a Modal and i am trying to overwrite the title in the Header and the Footer so my buttons appear insted of the Cancel button.

Here is a partial of my component code :
<aura:component controller="************" implements="force:hasRecordId,force:appHostable,force:lightningQuickAction">
	<aura:attribute name="recordId" type="String" default="{!recordId}"/>
   	<aura:handler name="init" value="{!this}" action="{!c.getrecord}" />
    <div class="slds-modal__container slds-fade-in-open">
        <header class="slds-modal__header">
          <h2 id="modal-heading-01" class="slds-text-heading--medium">Share History Call Reports</h2>
        </header>
        
        <div class="slds-modal__content slds-p-around_medium slds-align_absolute-center" id="modal-content-id-1">
            <p>Would you like to share the history call report to the cluster owner?</p>
        </div>
        
        <footer class="slds-modal__footer">
            <lightning:button class="slds-button slds-button_neutral" onclick="{!c.yesResponse}" label="Yes" />
            <lightning:button class="slds-button slds-button_brand" onclick="{!c.noResponse}" label="No"/>
        </footer>
    </div>
</aura:component>

Thanks for your help :)
Hi Forum,

First-time on Trailhead, excellent platform for learning. However I'm stuck on an issue. The custom object looks fine, but I'm getting the error:
"All the expected custom fields for the Trail__c object could not be found."

The object and fields looks ok.  I have looked at other advice and it seems the Sys Admin has view access to the Custom Objects.
I'm hoping its something simple I've missed off...

Custom Object View for Trail

Any advice is greatly appreciated.

Kind Regards
Mark
 
Hi All,
I am struggling in Build a solution using Lightning Web Components to display Similar Boats (LWC Specialist #15). Please help me to solve this issue. Thanks in advance 

display Similar Boats #15 Error Message
similarBoats.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>57.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordPage">
            <property label="Enter the property you want to compare by" name="similarBy" type="String" datasource="Type,Price,Length"/>
            <objects>
                <object>Boat__c</object>
            </objects>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>
similarBoats.js

import { api, LightningElement, wire } from 'lwc';
import { NavigationMixin } from 'lightning/navigation'
import getSimilarBoats from '@salesforce/apex/BoatDataService.getSimilarBoats';

const BOAT_OBJECT = 'Boat__c';

export default class SimilarBoats extends NavigationMixin(LightningElement) {
    // Private
    currentBoat;
    relatedBoats;
    boatId;
    error;
    
    @api
    get recordId() {
        return this.boatId;
    }
    set recordId(value) {
        //sets boatId attribute
        this.setAttribute('boatId', value);        
        //sets boatId assignment
        this.boatId = value;
    }
    
    @api
    similarBy;
    
    // Wire custom Apex call, using the import named getSimilarBoats
    // Populates the relatedBoats list
    @wire(getSimilarBoats, {boatId: '$boatId', similarBy: '$similarBy'})
    similarBoats({ error, data }) {
        if (data) {
            this.relatedBoats = data;
            this.error = undefined;
        } else if (error) {
            this.error = error;
        }
    }

    get getTitle() {
      return 'Similar boats by ' + this.similarBy;
    }

    get noBoats() {
      return !(this.relatedBoats && this.relatedBoats.length > 0);
    }
    
    // Navigate to record page
    openBoatDetailPage(event) {
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: event.detail.boatId,
                objectApiName: BOAT_OBJECT,
                actionName: 'view'
            },
        });
    }
}
similarBoats.html

<template>
    <lightning-card title={getTitle} icon-name="custom:custom54">
        <lightning-layout multiple-rows="true">
            <template if:true={noBoats}>
                <p class="slds-align_absolute-center">There are no related boats by {similarBy}!</p>
            </template>
            <!-- Loop through the list of similar boats -->
            <template for:each={relatedBoats} for:item="boat">
                <!-- Responsive lightning-layout-item -->
                <lightning-layout-item key={boat.Id} padding='around-small' size='12' small-device-size='6' medium-device-size='4' large-device-size='4'>
                    <!-- Each boat tile goes here -->
                    <c-boat-tile boat={boat} onboatselect={openBoatDetailPage}></c-boat-tile>
                </lightning-layout-item>
            </template>
      </lightning-layout>
    </lightning-card>
</template>


 
Hi All,
     This below test class covers 36% only how to increase the coverage more than 75%. Please guide me to get more coverage. Thanks in advance.
Apex Class:
=========
public with sharing class MultiSelectLookupController {

    @AuraEnabled
    public static List<RecordsData> fetchRecords(String objectName, String filterField, String searchString, String values) {
        try {
            List<RecordsData> recordsDataList = new List<RecordsData>();
            List<String> selectedvalues = (List<String>) JSON.deserialize(values, List<String>.class);
            String query = 'SELECT Id, ' + filterField + ' FROM '+objectName;
            if(selectedvalues != null && selectedvalues.size() > 0) {
                query += ' WHERE Id IN: selectedvalues LIMIT 49999';
            } else {
                query += ' WHERE '+filterField+
                		' LIKE ' + '\'' + String.escapeSingleQuotes(searchString.trim()) + '%\' LIMIT 49999';
            }
	        for(SObject s : Database.query(query)) {
	            recordsDataList.add( new RecordsData((String)s.get(filterField), (String)s.get('id')) );
	        }
            return recordsDataList;
	    } catch (Exception err) {
	    	if ( String.isNotBlank( err.getMessage() ) && err.getMessage().contains( 'error:' ) ) {
                throw new AuraHandledException(err.getMessage().split('error:')[1].split(':')[0] + '.');
            } else {
                throw new AuraHandledException(err.getMessage());
            }
	    }
    }

    public class RecordsData {
        @AuraEnabled public String label;
        @AuraEnabled public String value;
        public RecordsData(String label, String value) {
            this.label = label;
            this.value = value;
        }
    }
}


Test Class:
========

@isTest
public class MultiSelectLookupControllerTest {

    @istest
    static void QLIeditMethod_Test(){
        List<Quote> quoteList= [select id from quote];
        string recType = 'Commercial products';
        Product2 prod = new Product2();
        prod.Name = 'Test Bulk';
        
        String objectName = 'Product2';
        String filterField = 'Name';
        String searchString = 'unit Bulk';
        String values = 'Name';
        //String myJSON = JSON.stringify(prod);
        
        Test.startTest();
        try {
        MultiSelectLookupController.fetchRecords(objectName,filterField,searchString,values);
        }Catch(exception e){}
        Test.stopTest(); 
    }    
    
    public static testMethod void testGetProductValues() {        
        MultiSelectLookupController controller = new MultiSelectLookupController();            
    }
}
User-added image
 
Hi All, 
    How to give the cusotm validation in LWC. I have added the JS function for each Lightning-Input field Validation. How to check fiels Value != Null or Not Empty.I am getting this below error. Please guide me where I made mistake and how to solve this.
Validation
HTML:
---------

<div class="container-fluid">        
            <table class="slds-table slds-table_bordered slds-table_cell-buffer"> 
                <thead>
                    <tr class="slds-text-title_caps">
                        <th scope="col">
                            <div class="slds-truncate">#</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Contact FirstName">Contact FirstName</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Contact LastName">Contact LastName</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Email">Email</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Phone">Phone</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Maximum">Maximum</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Minimum">Minimum</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Action">Action</div>
                        </th>
                    </tr>
                </thead>   
                <tbody>      
                    
                    <template for:each={contactList} for:item="con" for:index="indx">
                        <tr key={con.key} id={con.key}> 
                            <td>{indx}</td>                                                  
                            <td>
                                <lightning-input name="firstName" data-id={indx} value={con.FirstName} onchange={handleFirstNameChange} onblur={handleCustomValidationFirstName}></lightning-input>                               
                            </td>
                            <td>
                                <lightning-input name="lastName" data-id={indx} value={con.LastName} onchange={handleLastNameChange} onblur={handleCustomValidationLastName}></lightning-input>                               
                            </td>
                            <td>
                                <lightning-input data-id={indx} value={con.Email} onchange={handleEmailChange}></lightning-input>                        
                            </td>
                            <td>
                                <lightning-input data-id={indx} value={con.Phone} onchange={handlePhoneChange}></lightning-input>
                            </td>
                            <td>
                                <lightning-input data-id={indx} value={con.Maximum__c} onchange={handleMaximumChange}></lightning-input>                        
                            </td>
                            <td>
                                <lightning-input data-id={indx} value={con.Minimum__c} onchange={handleMinimumChange}></lightning-input>
                            </td>
                            <td>
                                <lightning-button-icon icon-name="utility:delete"
																		  data-id={indx}       
																		  alternative-text="Delete"     
																		  class="slds-m-left_xx-small"
																		  onclick={removeRow} 
																		  title="Delete"></lightning-button-icon>
                            </td>
                        </tr>
                    </template>
                     
                </tbody>
            </table>
            <div class="slds-align_absolute-center slds-p-top_small">                
                <lightning-button name="Save" label="Save" onclick={saveRecord} if:true={addSaveNewRow}></lightning-button>
            </div>
        </div>  

JS:
------

handleCustomValidationFirstName(event) {
    let element = this.template.querySelector("[data-id='firstName']");
    let value = element.value;

    if (value == '' || value ==  null ) {
    element.setCustomValidity("Error!");
    } else {
    element.setCustomValidity("");
    }

    element.reportValidity();
}
handleCustomValidationLastName(event) {
    let element = this.template.querySelector("[data-id='lastName']");
    let value = element.value;

    if (value == '' || value ==  null) {
    element.setCustomValidity("Error!");
    } else {
    element.setCustomValidity("");
    }

    element.reportValidity();
}

handleSave(event) {

    let element = this.template.querySelector("lightning-input");
    let value = element.value;

    if (value == '' || value == null)  {
        element.setCustomValidity("Error!");
    } else {
        element.setCustomValidity("");
    }

    element.reportValidity();

    const recordInputs = event.detail.draftValues.slice().map(draft => {
        const fields = Object.assign({}, draft);
        return {fields};
    });

    //const recordInput = {fields};
    const promises = recordInputs.map(recordInput => updateRecord(recordInput));
        Promise.all(promises).then(() => {
            // Clear all draft values
            this.draftValues = [];
            // Display fresh data in the datatable
            return refreshApex(this.wiredDataResult);
        }).catch(error => {
            // Handle error
        });
}

Thanks
Siva

   
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,

   Is there a way I can create the new folder in my library to store records as pdf in a custom object I've created after approval ( Approval Proess = Approved) usering apex controller or trigger ? Thanks for any help

Thanks
Siva
Hi, I am new to LWC ​​​​​​, trying dynamically add/remove rows for a table scenario. I can able to add the row by click on the + button. After added that rows I want to enter some values in text boxes and save into account object by click on save buttton. Also do the delete action as well to delete the specific row by click on delete button. 

I am facing issue with save & delete records. How I can solve this? Can anyone give me some guidence to solve.

AddDeleteRow
dynamicAddRow.html

<template>
                  
    <div class="slds-m-around--xx-large">
        <div class="slds-float_right slds-p-bottom_small">
            <h1 class="slds-page-header__title">Add Row
                <lightning-button-icon icon-name="utility:add"  size="large" variant="bare" alternative-text="Add" onclick={addRow}> </lightning-button-icon>
            </h1>
        </div>
        <div class="container-fluid">        
            <table class="slds-table slds-table_bordered slds-table_cell-buffer"> 
                <thead>
                    <tr class="slds-text-title_caps">
                        <th scope="col">
                            <div class="slds-truncate">#</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Account Name">Account Name</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Account Number">Account Number</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Phone">Phone</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Action">Action</div>
                        </th>
                    </tr>
                </thead>   
                <tbody>      
                    
                    <template for:each={accountList} for:item="acc" for:index="index">
                        <tr key={acc.Id}> 
                            <td>{index}</td>                                                  
                            <td>
                                <lightning-input label="Name" value={acc.Name} onchange={handleNameChange}></lightning-input>                               
                            </td>
                            <td>
                                <lightning-input label="Account Number" value={acc.AccountNumber} onchange={handleAccountNumberChange}></lightning-input>                        
                            </td>
                            <td>
                                <lightning-input label="Phone" value={acc.Phone} onchange={handlePhoneChange}></lightning-input>
                            </td>
                            <td>
                                <a onclick={removeRow}> 
                                    <lightning-icon icon-name="utility:delete" size="small" style="margin-top: -4px; margin-right: 0px;" ></lightning-icon>
                                    <span class="slds-assistive-text">Delete</span>
                                </a>
                            </td> 
                        </tr>
                    </template>
                     
                </tbody>
            </table>
            <div class="slds-align_absolute-center slds-p-top_small">                
                <lightning-button name="Save" label="Save" onclick={saveRecord} ></lightning-button>
            </div>
        </div>
    </div>

</template>
 
dynamicAddRow.js

import { LightningElement, track,api } from 'lwc';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import ACCOUNTNUMBER_FIELD from '@salesforce/schema/Account.AccountNumber';
import PHONE_FIELD from '@salesforce/schema/Account.Phone';
import saveAccounts from '@salesforce/apex/AccountController.saveAccounts';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class CreateDynamicRecord extends LightningElement {
    @track accountList = []; 
    @track index = 0;
    @api recordId;
    @track name = NAME_FIELD;
    @track industry = ACCOUNTNUMBER_FIELD;
    @track phone = PHONE_FIELD;

    @api record = {
        firstName : '',
        lastName : '',
        Email : '',
        Phone : '',
        Title : ''
    }

    addRow(){

        this.index++;
   
        this.accountList.push ({
            sobjectType: 'Account',
            Name: '',
            AccountNumber : '',
            Phone: ''
        });

        console.log('Enter ',this.accountList);
        
       // this.accountList.push(this.record);
        //console.log(' After adding Record List ', this.accountList);
    }
    
    removeRow(){

        var index = this.index;
      
        if(this.accountList.length>1)
           this.accountList.splice(index, 1);

        //this.dispatchEvent(new CustomEvent('deleterow', {detail: this.index}));
        //console.log(' After adding Record List ', this.dispatchEvent);
    } 

    acc = {
        Name : this.name,
        AccountNumber : this.accNumber,
        Phone : this.phone
    }

    handleNameChange(event) {
        this.acc.Name = event.target.value;
        console.log("name", this.acc.Name);
    }
    
    handleAccountNumberChange(event) {
        this.acc.AccountNumber = event.target.value;
        console.log("AccountNumber", this.acc.AccountNumber);
    }
    
    handlePhoneChange(event) {
        this.acc.Phone = event.target.value;
        console.log("Phone", this.acc.Phone);
    }
    
    saveRecord(){        
        saveAccounts(this.acc.accountList)
            .then(result => {
                this.message = result;
                this.error = undefined;
                if(this.message !== undefined) {
                    this.acc.Name = '';
                    this.acc.AccountNumber = '';
                    this.acc.Phone = '';
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Success',
                            message: 'Account created successfully',
                            variant: 'success',
                        }),
                    );
                }
                
                console.log(JSON.stringify(result));
                console.log("result", this.message);
                /*console.log(' After adding Record List ', result);
                this.accountList = result;
                console.log(' After adding Record List ', this.accountList);*/
            })
            .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));
            });
    }
      
}
 
AccountController.apex  

public with sharing class AccountController { 
 
    @AuraEnabled( cacheable = true ) 
    public static List< Account > getAccounts() { 
      
        return [ SELECT Id, Name, Industry FROM Account LIMIT 10 ]; 
         
    } 
     
    @AuraEnabled( cacheable = true )
    public static void saveAccounts(List<Account> accList){
        Insert accList;
        /*if(accList.size()>0 && accList != null){
            insert accList;
        }*/
    } 
}
Thanks 
Siva
 
Hi,

I have tried to add two list via trigger but i got an error like System.ListException: Before Insert or Upsert list must not have two identically equal elements.  This is my code please suggest me whats is error. and how to fix that. I want to try to send sms for two contact numbers in employee object.
trigger SMSAttendance on Emp_Attendance__c (after insert) {
    List<smagicinteract__smsmagic__c> scpList = new List<smagicinteract__smsmagic__c>();
    String tplText = null;
    for (Emp_Attendance__c empatten : Trigger.New){
        if(!empatten. Employee_Present__c){                      
           Emp_Attendance__c emp= [SELECT Contact_Emp__r.Phone,sitinstra__Contact_Emp__r.OtherPhone from Emp_Attendance__c where Id = :empatten.Id limit 1];
             
            tpltext = 'Dear Emp, this is to inform you that you are ABSENT for the office today. Regards, Department of HR, ABC Pvt Ltd.';
            system.debug(tpltext);
            smagicinteract__smsMagic__c smsObj = new smagicinteract__smsMagic__c();
            smsObj.smagicinteract__PhoneNumber__c = emp.Contact_Emp__r.Phone;
            smsObj.smagicinteract__SMSText__c = tplText;             
            smsObj.smagicinteract__senderId__c = 'ABCPL';
            smsObj.smagicinteract__external_field__c = empatten.Id + 'testmessage';
            smsObj.smagicinteract__Name__c = empatten.Employee_Name__c;
            scpList.add(smsObj);
          /   Here i have a doubt - how to send a SMS for two mobile numbers in same employee. Below code i have tried but got an error that means second time add list value  /
            smsObj.smagicinteract__PhoneNumber__c = emp.Contact_Emp__r.OtherPhone;
            smsObj.smagicinteract__SMSText__c = tplText;             
            smsObj.smagicinteract__senderId__c = 'ABCPL';
            smsObj.smagicinteract__external_field__c = empatten.Id + 'testmessage1';
            smsObj.smagicinteract__Name__c = empatten.Employee_Name__c;
            scpList.add(smsObj);
            
        }
    }
    insert scpList;
}
Thanks
Siva
Hi,
            How to display the sub query value in apex trigger. Please find the code and correct me where i made mistake. How to aolve this issue.
I have try to conver Lead to Account and that time i want to send a text message. Your Lead has successfully converted with Account Name as well as Contact Name. I can get Account Name but not able to get the contact name to display.Please suggest me.  
trigger ConvertLeadtoAccount on Account (after insert) {
    List<smsbox__c> sms = new List<smsbox__c>();
    String Txttemp = null;
    for (Account acct : Trigger.New){
                          
            Account acc = [SELECT Phone, Name, (SELECT Name, MobilePhone, Phone FROM Contacts) FROM Account WHERE Id =:acct.Id limit 1];
           
             
            Txttemp = 'The Lead  '+ acc.Name +' has been successfully converted into '+ acc.Name +' Account';
            
            system.debug(Txttemp);
            smsbox__c obj = new smsbox__c();
            obj.PhoneNumber__c = acc.Phone;
            obj.SMSText__c = Txttemp;  
            obj.external_field__c = acct.Id + 'instratestmessage';
            obj.Name__c = acc.Name;
            sms.add(obj);
        }
    insert sms;
}

I have tried acc.contacts[0].Name also but not yet fixed.

Thanks
Sivasakthi
Hi,

The record some times gets saved and some times its shows error as 'Error: Error ID: 852563905-238205 (1478300867) ' for Community Users . 
This issue occurs only in Managed Packaged Installed (Test/Demo) Orgs. No error id we are getting in Development/ Packaging Org. Kindly guide me to solve this issue ASAP.
Note: I have already raised the case to the salesforce support team.We are the internal app developers. 

Thanks
Sivasakthi
 
I have a code to attach files greater than 25MB. but the problem is i can't able to save/view the Attached document by using of chatter:feed tag in VF page. The error I got is, chatter:feed should not be used under form tag. Is there any other solution to use Chatter:feed in VF page? kindly Suggest any option is available.
Hi
       I have created the trigger for automatically inserted the records form source to destination org with connection.Its not automatically inserted in the main object except we have to accept manually.Its stored in the Connection Section after click the go button in this section its show all records from the source org. we can accept manually one by one and give required relationship field. I have checked that in Subscribed objection section to enable the 'auto accept' option but its unable to choose. It will show the below message
Msg: Auto-accept isn't available for child objects, like opportunity products and tasks, because child records are automatically accepted with their parent record. 
We have checked the OWD also all are provided as Public Read/Write option.

I have created the trigger for before insert the relationship field mapping like fromula to text field mentioned inthe connection process. But its not working. Could you please anyone help me to provide solution for auto accept of records.Please find the screen shot & coding. Help me how to solve this issue. Where i made mistake.

Thanks
Siva
Marks record from connection 
 
Example Trigger Code :
==================
trigger MarksTrigger on Marks__c (before insert, before update) {
   
    List<String> StuMark = new List<String>(); 
    for (Marks__c sm : Trigger.new) {
           StuMark.add(sm.Stu_Course_Plan__c); 
    }  

    List <Course_Plan__c> SCPList=[Select Id, Name from Course_Plan__c Where Name IN:StuMark];
    Map <String,Id> smMap= new Map<String,Id>();
    for(Course_Plan__c scp:SCPList) {
        smMap.put(scp.Name,scp.Id);
    } 
             
    for (Marks__c smadd : Trigger.new)  {

        if (!smMap.isEmpty() && smadd.Course__c == null) {
                smadd.Course__c = smMap.get(smadd.Stu_Course_Plan__c);               
        }   
    }

    /* Another way i tried to map the relationship field */
   
   /* for(Marks__c sm : trigger.new) {                
        Course_Plan__c scp = [select Id, Name from Course_Plan__c where Name = :sm.Stu_Course_Plan__c limit 1 ];
        system.debug('Trigeer SCP Id ====== :: '+ sm.Stu_Course_Plan__c );
        system.debug('Trigger MarkId ====== :: '+ scp.Name);
        sm.Course__c = scp.Name;
    }  */    
    
}

 
Hi,

We have created one trial org using the trail template.Org created successfully. Login in to newly created org, while access to the community login we got Error Id 1166351650-561010 (-208404695). In the TSO org all communities login & landing page working perfectly . After creating the template to access the community login & landing page means getting this error Id. Please let me know how to solve this issue.

Advance Thanks
Sivasakthi 
Hi ,
We have tried to give the CRUD permission for Attachment in Apex Class for Security scan perpose but not covered.
I have tried in two ways below. Please help me out to fix this issue ASAP. 
Is salesforce changed the attachment Name as CombinedAttachment ? Thats why i gave like this.
1. if (CombinedAttachment.sObjectType.getDescribe().isDeletable()) {
       delete at;  
    }  
2. if(!(Schema.sObjectType.Attachment.isDeletable()){
         delete at;   
    }
Advance Thanks
Siva
Hi,
       I have 3(forms) in different vf components with different controllers  show in a single VF page. The 1 st form (component) fill the details and click save means it should show the 2nd form(component ), then 2nd one completed means have to show the 3rd form(component) in same page . How to do this any idea. Pls guide me to solve this .

Eg:       Like 1 st form have Basic Info, 2nd form have qualification , 3rd form have Acheivement Details. If 1st Basic Info form(component) completed the details and click save means show the 2nd Qualification form (component)  in the same page.

<apex:page showHeader="false" sidebar="false"  >     
   
    <apex:outputpanel rendered="false" >
        <c:BasicInfo />
    </apex:outputpanel>
          
    <apex:outputpanel rendered="true" >
       <c:Qualification />
    </apex:outputpanel>
    
    <apex:outputpanel rendered="false" >
        <c:Achievement/>
    </apex:outputpanel>
      
</apex:page>

Advance Thanks
Siva

 
Hi,

   How to use the connection.js for file upload more than 5MB in lightning component? I tried to split chunks the files size can upload with in 5 MB. I want to upload more than 5MB means how to acheive this via connection.js.  Can any one help on this.

 
Hi,

       How to create the lightning component with google map instead of leaflet map. I saw the leaflet example in this link
'https://developer.salesforce.com/blogs/developer-relations/2015/04/creating-salesforce-lightning-map-component.html'  .   But I want to show the google map in lightning component. Please guide me how to get this.

Advance Thanks
Siva
 
Hi,
                  I am creating the lightning component with a leaflet map and access via Visualforce page. In that page created the drop down with contact list. Based on list value i select what are records set the Location ( Latitude and Longitude ) the map will refresh.

I have doubt how to pass the parameter of the list values into the lightning component. Guide me how to achieve this

This Error I got Using the 'Firing Lightning Events from Non-Lightning Code ' Method:

Uncaught SecurityError: Blocked a frame with origin "https://lightnapp-dev-ed--c.ap2.visual.force.com" from accessing a frame with origin "https://lightnapp-dev-ed.my.salesforce.com". Protocols, domains, and ports must match.

My Code:
==========

<apex:page showHeader="false" controller="ContactLocatorController">
<apex:includeLightning />
<div id="lightning" >
<script>
var myExternalEvent;
if(window.opener.$A && (myExternalEvent = window.opener.$A.get("e.c:ContactsSelected"))) {
       myExternalEvent.setParams({});
       myExternalEvent.fire();
}

var visualForceFunction = function(event) {
      var EventData = event.getParam("contact");
      console.log('::::::::::',EventData);
};
$Lightning.use("c:ContactLocatorApp", function()  {
       $Lightning.createComponent("c:ContactLocator",
        { },
         "lightning",
          function(cmp) {
               $A.eventService.addHandler({ "event": "c:ContactsSelected", "handler" : visualForceFunction});
               //alert('handler test');
         });
});
</script>
<apex:form >
<apex:outputText label="You Have Selected : " value="{!selectedContact}"/>
<apex:selectList size="1" value="{!selectedContact}">
<apex:selectOptions value="{!ContactsList}" />
<!-- <apex:actionSupport event="onchange" oncomplete="function(this)"/>-->
</apex:selectList><br/>
</apex:form> </div>
</apex:page>

Advance Thanks
Hi,

I have try to sum the iteration text box values from child component into parent component. I can able to get the child values from child component via application & component events. Pls guide me how to push those child values in new array and sum it.

Parent Component:
----------------------------
<aura:component >     
    <aura:attribute name="arrvals" type="integer[]" default="1,2,3,4,5"/>    
    <aura:registerEvent name="sum" type="c:SumAppEvent"/>     
    <aura:handler name="sumres" event="c:SumCompEvent" action="{!c.sumVal}"/>
    <aura:attribute name="myResults" type="integer[]" />
    <aura:iteration var="num" items="{!v.arrvals}" aura:id="ipv" indexVar="index">
        <c:myListComponent />         
    </aura:iteration>
     
    <ui:button aura:id="addbtn" label="Calculate" press="{!c.calculate}" /><br/>
    Sum of the Value : <ui:outputNumber aura:id="totalValue" value="{!v.totalValue}" />    
</aura:component>

Parent Controller:
------------------------
sumVal : function(component, event, helper) {
            
            var txtval = event.getParam("resval");            
            console.log('got value from child',txtval);                              
            var val = component.getEvent("sum");
            val.setParams({"myResults" : txtval});
            console.log('val******',val);
            for (var total = 0, i = 0; i <txtval; i++) {
                  val.push({ value: txtval });                 
                 //total += parseInt(txtval);
            } 
            console.log('sum +++++++',val);   
        
           },                     
    
        calculate : function(component, event, helper)  {              
                $A.get("e.c:SumAppEvent").fire();                
        } , 
})

Advance Thanks
Siva
 
Hi,

           I have tried to calculate sum of custom array values in lightning component. But unable to get the index values. If we get the index values means using for loop to calculate the sum. Please guide me where i made mistake and how  to solve this. 

Component:
-----------------------
<aura:component >
    <aura:attribute name="arrvals" type="integer[]" default="1,2,3,4,5"/>
    <aura:attribute name="numbers" type="integer"/>
    
    <aura:iteration var="num" items="{!v.arrvals}" aura:id="ipv" indexVar="index" >
        {!index}<ui:inputNumber label="Input value : " aura:id="{!index+'ip'}" placeholder="Enter the Vlaue"/>  
    </aura:iteration>
    
    <ui:button aura:id="addbtn" label="Calculate" press="{!c.calculate}" /><br/>     
    Sum of the Value : <ui:outputNumber aura:id="totalValue" value="{!v.totalValue}" />  
</aura:component>

Controller.js
------------------
({       
    calculate : function(component) {
       
       try {     
            debugger;
            var numbers=component.find("index+ip").get("v.value");
            console.log(numbers); 
            var arrlist =component.get("v.arrvals");
            console.log(arrvals);            
            var totalval=0;            
            for(var i=0; i<arrlist.length; i++) { 
                //var sum = parseInt(numbers)
                totalval += parseInt(numbers) ;
                console.log(totalval);                
            }          
                component.set('v.totalValue',totalval);            
        }                           
        catch (e) {
            alert('Exception : '  + e);
        }     
    } ,
})

Advance Thanks
Sivasakthi
Hi,

       I have two components parent and child with rollup summary value. when i update child records the parent rollup value is updated. Able to check that update using pull to refresh. Is any other way to refresh the parent component/record(Rollup value) with out pull to refresh?. I have show that record details in record view passing recordid edit that record and click save have to refresh the parent component/record.

Please guide me to achive this.  

Example Code:
--------------------------
<aura:component>
        <aura:attribute name="emp" type="Employee__c"/>      
        <div class="{!v.value == 'All Employee'? 'row primary' : 'row '}" >    
            <div onclick="{!c.gotoRecord}">    
                <force:recordView recordId="{!v.emp.Id}" type="MINI"/>    
            </div>            
        </div> 
</aura:component>

Advance Thanks
Sivasakthi
Hi, I am new to LWC ​​​​​​, trying dynamically add/remove rows for a table scenario. I can able to add the row by click on the + button. After added that rows I want to enter some values in text boxes and save into account object by click on save buttton. Also do the delete action as well to delete the specific row by click on delete button. 

I am facing issue with save & delete records. How I can solve this? Can anyone give me some guidence to solve.

AddDeleteRow
dynamicAddRow.html

<template>
                  
    <div class="slds-m-around--xx-large">
        <div class="slds-float_right slds-p-bottom_small">
            <h1 class="slds-page-header__title">Add Row
                <lightning-button-icon icon-name="utility:add"  size="large" variant="bare" alternative-text="Add" onclick={addRow}> </lightning-button-icon>
            </h1>
        </div>
        <div class="container-fluid">        
            <table class="slds-table slds-table_bordered slds-table_cell-buffer"> 
                <thead>
                    <tr class="slds-text-title_caps">
                        <th scope="col">
                            <div class="slds-truncate">#</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Account Name">Account Name</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Account Number">Account Number</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Phone">Phone</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Action">Action</div>
                        </th>
                    </tr>
                </thead>   
                <tbody>      
                    
                    <template for:each={accountList} for:item="acc" for:index="index">
                        <tr key={acc.Id}> 
                            <td>{index}</td>                                                  
                            <td>
                                <lightning-input label="Name" value={acc.Name} onchange={handleNameChange}></lightning-input>                               
                            </td>
                            <td>
                                <lightning-input label="Account Number" value={acc.AccountNumber} onchange={handleAccountNumberChange}></lightning-input>                        
                            </td>
                            <td>
                                <lightning-input label="Phone" value={acc.Phone} onchange={handlePhoneChange}></lightning-input>
                            </td>
                            <td>
                                <a onclick={removeRow}> 
                                    <lightning-icon icon-name="utility:delete" size="small" style="margin-top: -4px; margin-right: 0px;" ></lightning-icon>
                                    <span class="slds-assistive-text">Delete</span>
                                </a>
                            </td> 
                        </tr>
                    </template>
                     
                </tbody>
            </table>
            <div class="slds-align_absolute-center slds-p-top_small">                
                <lightning-button name="Save" label="Save" onclick={saveRecord} ></lightning-button>
            </div>
        </div>
    </div>

</template>
 
dynamicAddRow.js

import { LightningElement, track,api } from 'lwc';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import ACCOUNTNUMBER_FIELD from '@salesforce/schema/Account.AccountNumber';
import PHONE_FIELD from '@salesforce/schema/Account.Phone';
import saveAccounts from '@salesforce/apex/AccountController.saveAccounts';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class CreateDynamicRecord extends LightningElement {
    @track accountList = []; 
    @track index = 0;
    @api recordId;
    @track name = NAME_FIELD;
    @track industry = ACCOUNTNUMBER_FIELD;
    @track phone = PHONE_FIELD;

    @api record = {
        firstName : '',
        lastName : '',
        Email : '',
        Phone : '',
        Title : ''
    }

    addRow(){

        this.index++;
   
        this.accountList.push ({
            sobjectType: 'Account',
            Name: '',
            AccountNumber : '',
            Phone: ''
        });

        console.log('Enter ',this.accountList);
        
       // this.accountList.push(this.record);
        //console.log(' After adding Record List ', this.accountList);
    }
    
    removeRow(){

        var index = this.index;
      
        if(this.accountList.length>1)
           this.accountList.splice(index, 1);

        //this.dispatchEvent(new CustomEvent('deleterow', {detail: this.index}));
        //console.log(' After adding Record List ', this.dispatchEvent);
    } 

    acc = {
        Name : this.name,
        AccountNumber : this.accNumber,
        Phone : this.phone
    }

    handleNameChange(event) {
        this.acc.Name = event.target.value;
        console.log("name", this.acc.Name);
    }
    
    handleAccountNumberChange(event) {
        this.acc.AccountNumber = event.target.value;
        console.log("AccountNumber", this.acc.AccountNumber);
    }
    
    handlePhoneChange(event) {
        this.acc.Phone = event.target.value;
        console.log("Phone", this.acc.Phone);
    }
    
    saveRecord(){        
        saveAccounts(this.acc.accountList)
            .then(result => {
                this.message = result;
                this.error = undefined;
                if(this.message !== undefined) {
                    this.acc.Name = '';
                    this.acc.AccountNumber = '';
                    this.acc.Phone = '';
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Success',
                            message: 'Account created successfully',
                            variant: 'success',
                        }),
                    );
                }
                
                console.log(JSON.stringify(result));
                console.log("result", this.message);
                /*console.log(' After adding Record List ', result);
                this.accountList = result;
                console.log(' After adding Record List ', this.accountList);*/
            })
            .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));
            });
    }
      
}
 
AccountController.apex  

public with sharing class AccountController { 
 
    @AuraEnabled( cacheable = true ) 
    public static List< Account > getAccounts() { 
      
        return [ SELECT Id, Name, Industry FROM Account LIMIT 10 ]; 
         
    } 
     
    @AuraEnabled( cacheable = true )
    public static void saveAccounts(List<Account> accList){
        Insert accList;
        /*if(accList.size()>0 && accList != null){
            insert accList;
        }*/
    } 
}
Thanks 
Siva
 
Hi,

We just released a managed package of an app which uses a third party tool ( Vertical Responce ) for sending mails. The credentials of the tool are kept in the custom settings of the app.

Is there a possibility to change the custom settings values (Vertical Responce Credentials)  when the app is installed in another Org.This is requires as the app buyer may want to purchase an account from vertical responce with a different credential; not as the one we tested.

Kindly advice.

Thanks in Advance,

Regards,
Maheshwar
Hi,

I have 50 user in same profile  example sales, i want to assign the permission set for 10 users at a time, How can i assign this at a time. one by one means its possible to assign. i want to assign for 10 users at the same time. help me how i can assign.
Hi All,
     This below test class covers 36% only how to increase the coverage more than 75%. Please guide me to get more coverage. Thanks in advance.
Apex Class:
=========
public with sharing class MultiSelectLookupController {

    @AuraEnabled
    public static List<RecordsData> fetchRecords(String objectName, String filterField, String searchString, String values) {
        try {
            List<RecordsData> recordsDataList = new List<RecordsData>();
            List<String> selectedvalues = (List<String>) JSON.deserialize(values, List<String>.class);
            String query = 'SELECT Id, ' + filterField + ' FROM '+objectName;
            if(selectedvalues != null && selectedvalues.size() > 0) {
                query += ' WHERE Id IN: selectedvalues LIMIT 49999';
            } else {
                query += ' WHERE '+filterField+
                		' LIKE ' + '\'' + String.escapeSingleQuotes(searchString.trim()) + '%\' LIMIT 49999';
            }
	        for(SObject s : Database.query(query)) {
	            recordsDataList.add( new RecordsData((String)s.get(filterField), (String)s.get('id')) );
	        }
            return recordsDataList;
	    } catch (Exception err) {
	    	if ( String.isNotBlank( err.getMessage() ) && err.getMessage().contains( 'error:' ) ) {
                throw new AuraHandledException(err.getMessage().split('error:')[1].split(':')[0] + '.');
            } else {
                throw new AuraHandledException(err.getMessage());
            }
	    }
    }

    public class RecordsData {
        @AuraEnabled public String label;
        @AuraEnabled public String value;
        public RecordsData(String label, String value) {
            this.label = label;
            this.value = value;
        }
    }
}


Test Class:
========

@isTest
public class MultiSelectLookupControllerTest {

    @istest
    static void QLIeditMethod_Test(){
        List<Quote> quoteList= [select id from quote];
        string recType = 'Commercial products';
        Product2 prod = new Product2();
        prod.Name = 'Test Bulk';
        
        String objectName = 'Product2';
        String filterField = 'Name';
        String searchString = 'unit Bulk';
        String values = 'Name';
        //String myJSON = JSON.stringify(prod);
        
        Test.startTest();
        try {
        MultiSelectLookupController.fetchRecords(objectName,filterField,searchString,values);
        }Catch(exception e){}
        Test.stopTest(); 
    }    
    
    public static testMethod void testGetProductValues() {        
        MultiSelectLookupController controller = new MultiSelectLookupController();            
    }
}
User-added image
 
Hi All, 
    How to give the cusotm validation in LWC. I have added the JS function for each Lightning-Input field Validation. How to check fiels Value != Null or Not Empty.I am getting this below error. Please guide me where I made mistake and how to solve this.
Validation
HTML:
---------

<div class="container-fluid">        
            <table class="slds-table slds-table_bordered slds-table_cell-buffer"> 
                <thead>
                    <tr class="slds-text-title_caps">
                        <th scope="col">
                            <div class="slds-truncate">#</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Contact FirstName">Contact FirstName</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Contact LastName">Contact LastName</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Email">Email</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Phone">Phone</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Maximum">Maximum</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Minimum">Minimum</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Action">Action</div>
                        </th>
                    </tr>
                </thead>   
                <tbody>      
                    
                    <template for:each={contactList} for:item="con" for:index="indx">
                        <tr key={con.key} id={con.key}> 
                            <td>{indx}</td>                                                  
                            <td>
                                <lightning-input name="firstName" data-id={indx} value={con.FirstName} onchange={handleFirstNameChange} onblur={handleCustomValidationFirstName}></lightning-input>                               
                            </td>
                            <td>
                                <lightning-input name="lastName" data-id={indx} value={con.LastName} onchange={handleLastNameChange} onblur={handleCustomValidationLastName}></lightning-input>                               
                            </td>
                            <td>
                                <lightning-input data-id={indx} value={con.Email} onchange={handleEmailChange}></lightning-input>                        
                            </td>
                            <td>
                                <lightning-input data-id={indx} value={con.Phone} onchange={handlePhoneChange}></lightning-input>
                            </td>
                            <td>
                                <lightning-input data-id={indx} value={con.Maximum__c} onchange={handleMaximumChange}></lightning-input>                        
                            </td>
                            <td>
                                <lightning-input data-id={indx} value={con.Minimum__c} onchange={handleMinimumChange}></lightning-input>
                            </td>
                            <td>
                                <lightning-button-icon icon-name="utility:delete"
																		  data-id={indx}       
																		  alternative-text="Delete"     
																		  class="slds-m-left_xx-small"
																		  onclick={removeRow} 
																		  title="Delete"></lightning-button-icon>
                            </td>
                        </tr>
                    </template>
                     
                </tbody>
            </table>
            <div class="slds-align_absolute-center slds-p-top_small">                
                <lightning-button name="Save" label="Save" onclick={saveRecord} if:true={addSaveNewRow}></lightning-button>
            </div>
        </div>  

JS:
------

handleCustomValidationFirstName(event) {
    let element = this.template.querySelector("[data-id='firstName']");
    let value = element.value;

    if (value == '' || value ==  null ) {
    element.setCustomValidity("Error!");
    } else {
    element.setCustomValidity("");
    }

    element.reportValidity();
}
handleCustomValidationLastName(event) {
    let element = this.template.querySelector("[data-id='lastName']");
    let value = element.value;

    if (value == '' || value ==  null) {
    element.setCustomValidity("Error!");
    } else {
    element.setCustomValidity("");
    }

    element.reportValidity();
}

handleSave(event) {

    let element = this.template.querySelector("lightning-input");
    let value = element.value;

    if (value == '' || value == null)  {
        element.setCustomValidity("Error!");
    } else {
        element.setCustomValidity("");
    }

    element.reportValidity();

    const recordInputs = event.detail.draftValues.slice().map(draft => {
        const fields = Object.assign({}, draft);
        return {fields};
    });

    //const recordInput = {fields};
    const promises = recordInputs.map(recordInput => updateRecord(recordInput));
        Promise.all(promises).then(() => {
            // Clear all draft values
            this.draftValues = [];
            // Display fresh data in the datatable
            return refreshApex(this.wiredDataResult);
        }).catch(error => {
            // Handle error
        });
}

Thanks
Siva

   
Hello everyone,

Here is my issue: Modal
Basically I have a Modal in a Modal and i am trying to overwrite the title in the Header and the Footer so my buttons appear insted of the Cancel button.

Here is a partial of my component code :
<aura:component controller="************" implements="force:hasRecordId,force:appHostable,force:lightningQuickAction">
	<aura:attribute name="recordId" type="String" default="{!recordId}"/>
   	<aura:handler name="init" value="{!this}" action="{!c.getrecord}" />
    <div class="slds-modal__container slds-fade-in-open">
        <header class="slds-modal__header">
          <h2 id="modal-heading-01" class="slds-text-heading--medium">Share History Call Reports</h2>
        </header>
        
        <div class="slds-modal__content slds-p-around_medium slds-align_absolute-center" id="modal-content-id-1">
            <p>Would you like to share the history call report to the cluster owner?</p>
        </div>
        
        <footer class="slds-modal__footer">
            <lightning:button class="slds-button slds-button_neutral" onclick="{!c.yesResponse}" label="Yes" />
            <lightning:button class="slds-button slds-button_brand" onclick="{!c.noResponse}" label="No"/>
        </footer>
    </div>
</aura:component>

Thanks for your help :)
I want to insert all the input field values of a template into custom fields of an object in LWC. Could anyone please give me a solution. Below is the code which I have written so far. But I come up with this error(insert failed. First exception on row 0; first error: INVALID_TYPE_ON_FIELD_IN_RECORD, First_Name: value not of required type: {fieldApiName=First_Name__c, objectApiName=Registration__c}: [First_Name__c])
 
    HTML:
    <lightning-input type="text" name="txtFname" label="Enter First Name" onchange={handleChange} value={regRecord.fName}></lightning-input>
      <lightning-button variant="success" label="Submit" title="Submit" onclick={saveRecord} class="slds-m-left_x-small"></lightning-button>
    
    Javascript:
    
    import FirstName_FIELD from '@salesforce/schema/Registration__c.First_Name__c';
    import saveRegRecord from '@salesforce/apex/regClass.createRecord';
    
    @track regRecord = {
            fName : FirstName_FIELD
        };
    
        handleChange(event) {
            const field = event.target.name;
            if (field === 'txtFname') {
                console.log(event.target.value);
                this.regRecord.fName = event.target.value;            
            } 
        }
    
        saveRecord(event)
        {   
            saveRegRecord({reg : this.regRecord})
            .then(result => {
                // Clear the user enter values
                console.log(this.regRecord)
                this.conrec = {};            
                window.console.log('result ===> '+result);
                alert('record inserted');
            })
            .catch(error => {
                this.error = error.message;
                console.log('error==>'+this.error);
                alert('record not inserted');
            });
        }

    Apex:
    @AuraEnabled
        public static void createRecord (Registration__c reg){  
                if(reg != null){
                    insert reg;
            } 
        }

 
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, I am new to LWC ​​​​​​, trying dynamically add/remove rows for a table scenario. I can able to add the row by click on the + button. After added that rows I want to enter some values in text boxes and save into account object by click on save buttton. Also do the delete action as well to delete the specific row by click on delete button. 

I am facing issue with save & delete records. How I can solve this? Can anyone give me some guidence to solve.

AddDeleteRow
dynamicAddRow.html

<template>
                  
    <div class="slds-m-around--xx-large">
        <div class="slds-float_right slds-p-bottom_small">
            <h1 class="slds-page-header__title">Add Row
                <lightning-button-icon icon-name="utility:add"  size="large" variant="bare" alternative-text="Add" onclick={addRow}> </lightning-button-icon>
            </h1>
        </div>
        <div class="container-fluid">        
            <table class="slds-table slds-table_bordered slds-table_cell-buffer"> 
                <thead>
                    <tr class="slds-text-title_caps">
                        <th scope="col">
                            <div class="slds-truncate">#</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Account Name">Account Name</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Account Number">Account Number</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Phone">Phone</div>
                        </th>
                        <th scope="col">
                            <div class="slds-truncate" title="Action">Action</div>
                        </th>
                    </tr>
                </thead>   
                <tbody>      
                    
                    <template for:each={accountList} for:item="acc" for:index="index">
                        <tr key={acc.Id}> 
                            <td>{index}</td>                                                  
                            <td>
                                <lightning-input label="Name" value={acc.Name} onchange={handleNameChange}></lightning-input>                               
                            </td>
                            <td>
                                <lightning-input label="Account Number" value={acc.AccountNumber} onchange={handleAccountNumberChange}></lightning-input>                        
                            </td>
                            <td>
                                <lightning-input label="Phone" value={acc.Phone} onchange={handlePhoneChange}></lightning-input>
                            </td>
                            <td>
                                <a onclick={removeRow}> 
                                    <lightning-icon icon-name="utility:delete" size="small" style="margin-top: -4px; margin-right: 0px;" ></lightning-icon>
                                    <span class="slds-assistive-text">Delete</span>
                                </a>
                            </td> 
                        </tr>
                    </template>
                     
                </tbody>
            </table>
            <div class="slds-align_absolute-center slds-p-top_small">                
                <lightning-button name="Save" label="Save" onclick={saveRecord} ></lightning-button>
            </div>
        </div>
    </div>

</template>
 
dynamicAddRow.js

import { LightningElement, track,api } from 'lwc';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import ACCOUNTNUMBER_FIELD from '@salesforce/schema/Account.AccountNumber';
import PHONE_FIELD from '@salesforce/schema/Account.Phone';
import saveAccounts from '@salesforce/apex/AccountController.saveAccounts';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class CreateDynamicRecord extends LightningElement {
    @track accountList = []; 
    @track index = 0;
    @api recordId;
    @track name = NAME_FIELD;
    @track industry = ACCOUNTNUMBER_FIELD;
    @track phone = PHONE_FIELD;

    @api record = {
        firstName : '',
        lastName : '',
        Email : '',
        Phone : '',
        Title : ''
    }

    addRow(){

        this.index++;
   
        this.accountList.push ({
            sobjectType: 'Account',
            Name: '',
            AccountNumber : '',
            Phone: ''
        });

        console.log('Enter ',this.accountList);
        
       // this.accountList.push(this.record);
        //console.log(' After adding Record List ', this.accountList);
    }
    
    removeRow(){

        var index = this.index;
      
        if(this.accountList.length>1)
           this.accountList.splice(index, 1);

        //this.dispatchEvent(new CustomEvent('deleterow', {detail: this.index}));
        //console.log(' After adding Record List ', this.dispatchEvent);
    } 

    acc = {
        Name : this.name,
        AccountNumber : this.accNumber,
        Phone : this.phone
    }

    handleNameChange(event) {
        this.acc.Name = event.target.value;
        console.log("name", this.acc.Name);
    }
    
    handleAccountNumberChange(event) {
        this.acc.AccountNumber = event.target.value;
        console.log("AccountNumber", this.acc.AccountNumber);
    }
    
    handlePhoneChange(event) {
        this.acc.Phone = event.target.value;
        console.log("Phone", this.acc.Phone);
    }
    
    saveRecord(){        
        saveAccounts(this.acc.accountList)
            .then(result => {
                this.message = result;
                this.error = undefined;
                if(this.message !== undefined) {
                    this.acc.Name = '';
                    this.acc.AccountNumber = '';
                    this.acc.Phone = '';
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Success',
                            message: 'Account created successfully',
                            variant: 'success',
                        }),
                    );
                }
                
                console.log(JSON.stringify(result));
                console.log("result", this.message);
                /*console.log(' After adding Record List ', result);
                this.accountList = result;
                console.log(' After adding Record List ', this.accountList);*/
            })
            .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));
            });
    }
      
}
 
AccountController.apex  

public with sharing class AccountController { 
 
    @AuraEnabled( cacheable = true ) 
    public static List< Account > getAccounts() { 
      
        return [ SELECT Id, Name, Industry FROM Account LIMIT 10 ]; 
         
    } 
     
    @AuraEnabled( cacheable = true )
    public static void saveAccounts(List<Account> accList){
        Insert accList;
        /*if(accList.size()>0 && accList != null){
            insert accList;
        }*/
    } 
}
Thanks 
Siva
 
Hi,

I have tried to add two list via trigger but i got an error like System.ListException: Before Insert or Upsert list must not have two identically equal elements.  This is my code please suggest me whats is error. and how to fix that. I want to try to send sms for two contact numbers in employee object.
trigger SMSAttendance on Emp_Attendance__c (after insert) {
    List<smagicinteract__smsmagic__c> scpList = new List<smagicinteract__smsmagic__c>();
    String tplText = null;
    for (Emp_Attendance__c empatten : Trigger.New){
        if(!empatten. Employee_Present__c){                      
           Emp_Attendance__c emp= [SELECT Contact_Emp__r.Phone,sitinstra__Contact_Emp__r.OtherPhone from Emp_Attendance__c where Id = :empatten.Id limit 1];
             
            tpltext = 'Dear Emp, this is to inform you that you are ABSENT for the office today. Regards, Department of HR, ABC Pvt Ltd.';
            system.debug(tpltext);
            smagicinteract__smsMagic__c smsObj = new smagicinteract__smsMagic__c();
            smsObj.smagicinteract__PhoneNumber__c = emp.Contact_Emp__r.Phone;
            smsObj.smagicinteract__SMSText__c = tplText;             
            smsObj.smagicinteract__senderId__c = 'ABCPL';
            smsObj.smagicinteract__external_field__c = empatten.Id + 'testmessage';
            smsObj.smagicinteract__Name__c = empatten.Employee_Name__c;
            scpList.add(smsObj);
          /   Here i have a doubt - how to send a SMS for two mobile numbers in same employee. Below code i have tried but got an error that means second time add list value  /
            smsObj.smagicinteract__PhoneNumber__c = emp.Contact_Emp__r.OtherPhone;
            smsObj.smagicinteract__SMSText__c = tplText;             
            smsObj.smagicinteract__senderId__c = 'ABCPL';
            smsObj.smagicinteract__external_field__c = empatten.Id + 'testmessage1';
            smsObj.smagicinteract__Name__c = empatten.Employee_Name__c;
            scpList.add(smsObj);
            
        }
    }
    insert scpList;
}
Thanks
Siva
Hi,
            How to display the sub query value in apex trigger. Please find the code and correct me where i made mistake. How to aolve this issue.
I have try to conver Lead to Account and that time i want to send a text message. Your Lead has successfully converted with Account Name as well as Contact Name. I can get Account Name but not able to get the contact name to display.Please suggest me.  
trigger ConvertLeadtoAccount on Account (after insert) {
    List<smsbox__c> sms = new List<smsbox__c>();
    String Txttemp = null;
    for (Account acct : Trigger.New){
                          
            Account acc = [SELECT Phone, Name, (SELECT Name, MobilePhone, Phone FROM Contacts) FROM Account WHERE Id =:acct.Id limit 1];
           
             
            Txttemp = 'The Lead  '+ acc.Name +' has been successfully converted into '+ acc.Name +' Account';
            
            system.debug(Txttemp);
            smsbox__c obj = new smsbox__c();
            obj.PhoneNumber__c = acc.Phone;
            obj.SMSText__c = Txttemp;  
            obj.external_field__c = acct.Id + 'instratestmessage';
            obj.Name__c = acc.Name;
            sms.add(obj);
        }
    insert sms;
}

I have tried acc.contacts[0].Name also but not yet fixed.

Thanks
Sivasakthi
Hi all trailhead,

I am now stucking in one of the challenges of modules in Trailhead: Advanced Formula > Level up with advanced formula.
https://trailhead.salesforce.com/modules/advanced_formulas/units/implementing_advanced_formulas

The challenge is trying to ask us to calculate the 'percent completed' of the opportunity by using Today (), createdate and closedate.....However this does not make sense or even cause contradiction to me because when we already have a closedate of an opportunity, why do we need to calculate the progress? If we do not have the closedate, how to calculate the percentage of the opportunity completed?

Please help.
Hi All

I have created a custom object which is having image for every record.so how to create a vf page for displaying all image .

User-added image
I get the following message when trying to save my VF page. I can not proceed with unit.

User-added image
Hi,

We have created one trial org using the trail template.Org created successfully. Login in to newly created org, while access to the community login we got Error Id 1166351650-561010 (-208404695). In the TSO org all communities login & landing page working perfectly . After creating the template to access the community login & landing page means getting this error Id. Please let me know how to solve this issue.

Advance Thanks
Sivasakthi 
Hi ,
We have tried to give the CRUD permission for Attachment in Apex Class for Security scan perpose but not covered.
I have tried in two ways below. Please help me out to fix this issue ASAP. 
Is salesforce changed the attachment Name as CombinedAttachment ? Thats why i gave like this.
1. if (CombinedAttachment.sObjectType.getDescribe().isDeletable()) {
       delete at;  
    }  
2. if(!(Schema.sObjectType.Attachment.isDeletable()){
         delete at;   
    }
Advance Thanks
Siva
Hi,

I am not able to select the customer community user from account by lookup, hear i have created the user lookup in account,for my requirement i need to select the customer community user in account, but i am not able to select the customer community users.Please help on this requirement.

Thanks,
Surya
Hi All,

I want to display Dashboards tab for community user. The community is created using Napil teplate. Iam not finding ways to display dasboards using napili template. please help.

thanks in advance.

Vedashri