• Nishchal Vashisht 1
  • 10 Points
  • Member since 2022

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
  • 2
This is my query.
SOBject acc = [Select Id, Name, (Select Id, Account.Parent.Parent.Name, Name from Contacts__r) from Sales_Location__c where Id ='a005j000009xxxBAxU']; 
Contact abc =(Contact)(acc.getSobjects('Contacts__r')).get(0); System.debug(abc.get('Account.Parent.Parent.Name'));

But instead of using get() if I  directly use abc.Account.Parent.Parent.Name , I am getting result. But I don't know why  my code fails in case of get().  In Actual scenario abc is of SObject type that's why I need to use get() here.

import { LightningElement, api, track, wire } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import contactDetails from '@salesforce/apex/GetContact.getContacts';
import addContactRow from '@salesforce/apex/GetContact.addContactRow';
import deleteContactRow from '@salesforce/apex/GetContact.deleteContactRow';
const columns = [
        label: 'Delete',
        type: 'button-icon',
            iconName: 'utility:delete',
            name: 'Delete',
            variant: 'brand',
        label: 'FirstName',
        fieldName: 'FirstName',
        editable: true,
        label: 'LastName',
        fieldName: 'LastName',
        editable: true,
        label: 'Email',
        fieldName: 'Email',
        type: 'email',
        editable: true,
        label: 'Phone',
        fieldName: 'Phone',
        type: 'Phone',
        editable: true,

export default class EOperation extends LightningElement {
    data = [];
    columns = columns;
    step = '1';
    @api recordId;
    boolvalue = true;
    emaildata = '';
    subject = '';
    body = '';
    hasError = false;
    fldsItemValues = [];
    temp = [];
    @wire(contactDetails, {
        accId: '$recordId'
    }) wiredContacts({ error, data }) {
        if (data) {
            console.log('Temp Data is  ' + data)
            console.log('Stringify data ' + JSON.stringify(data))
            this.contactObj = data;
            this.secondContact = data;
            this.error = undefined;
        } else if (error) {
            console.log('error is ' + error)
            this.error = error;
            this.contactObj = undefined;
handleSave(event) {
        console.log('draft valus ID  ' + JSON.stringify(event.detail.draftValues));
        console.log('  type are ' + typeof (event.detail.draftValues) + '   IS Array ' + Array.isArray(event.detail.draftValues));
        console.log('Temp 0 ' + JSON.stringify(this.temp['id']))
        let row = JSON.stringify(event.detail.draftValues).split(',')[1];
        row = row.substring(row.indexOf('-') + 1, row.indexOf('}') - 1)
        console.log('row is  ' + row)
        let field = JSON.stringify(event.detail.draftValues).split(',')[0] + '}';
        console.log('ffffis  ' + field)
        let fieldValue = field.substring(field.indexOf(':') + 2, field.indexOf('}') - 1);
        console.log('fieldvalue is ' + fieldValue)
        let queryString = '' + field.substring(field.indexOf('{') + 1, field.indexOf('}')) + '';
        console.log('queryString  ' + typeof (queryString))
        field = field.substring(field.indexOf('"') + 1, field.indexOf(':') - 1);
        console.log('field is sss ' + field)
        let val = this.contactObj[row][field]
        let rs = `"${field}":"${val}"`
        console.log('rs is ' + typeof (rs))
        console.log('   IS Array ' + Array.isArray(this.contactObj))
        //let ts1 = this.contactObj.splice(row,1)
        console.log(JSON.stringify(this.contactObj[row]).replace(rs, queryString))
        console.log('tss is  ')
        let finall = JSON.parse(JSON.stringify(this.secondContact[row]).replace(rs, queryString));
        //  this.contactObj[row] =JSON.parse(JSON.stringify(this.contactObj[row]).replace(rs,queryString))
        console.log(typeof (finall) + '  >>colomn are ' + typeof (this.secondContact[row]))
        //this.secondContact[row]= '[{"Id":"0035j00000MM49HAAT","FirstName":"Alok","LastName":"Thirdss","Phone":"44564754654","Email":"bcd@gmail.com"}]'
        // console.log(ts.replace(rs,queryString))
        // let temp2 =
        // this.contactObj[row][field] = fieldValue;

handelsave is called on oncellchange event in datatable. My Question is why i am getting error on this line 'this.contactObj[row]=finall;'
Actually I have created a datatable with inline edit & I am updating the childobject each time user update any cell.
Here's my datatable. I didn't add full code in JS I have mentioned my Line where I am getting my error. 
    <div style="height: 300px;">
        <lightning-card title="Contact Details">
            <lightning-button-icon icon-name="utility:adduser" variant="brand" alternative-text="Add user"
                class="slds-m-left_xx-small " slot="actions" title="AddUser" onclick={addUser}>
            <lightning-datatable key-field="id" data={contactObj} suppress-bottom-bar hide-checkbox-column="true"
                onrowaction={handleRowActions} oncellchange={handleSave} draft-values={fldsItemValues}  columns={columns}>
            <p slot="footer">
                <lightning-button-icon icon-name="utility:save" variant="brand" alternative-text="Save"
                    class="slds-m-left_xx-small slds-float_right" title="Save" onclick={saveRecord}>



This is my VF page.
<apex:page Controller="SaleController" >
    <apex:form >
        <apex:pageBlock title="country list">
            <apex:pageBlockSection columns="3">
                <apex:outputLabel > Countries : </apex:outputLabel>
                <apex:selectList size="1" value="{!selectedCountry}" >
                    <apex:selectOptions value="{!country }"/>
                    <apex:actionSupport event="onchange" action="{!check}" reRender="reg"/>
                </apex:selectList> <br/>
                <apex:outputLabel value="Region"/>
                <apex:selectList id="reg" size="1" value="{!selectedRegion}"  >
                    <apex:selectOptions value="{!region }"/>
                    <apex:actionSupport event="onchange" action="{!check}" reRender="stat"/>
                </apex:selectList> <br/>
                <apex:outputLabel value="State"/>
                <apex:selectList id="stat" size="1" value="{!selectedState}"  >
                    <apex:selectOptions value="{!state }"/>
                    <apex:actionSupport event="onchange" action="{!check}" reRender="aaa"/>
            <apex:pageBlockButtons id="aaa" location="bottom" >
                <apex:commandButton value="Find" action="{!findRecord}" reRender="tab"></apex:commandButton>
    <apex:pageBlock title="Account Record">
        <apex:pageBlockTable id="tab" value="{!listOfAc.contacts}" var="contact" >
            <apex:column value="{!listOfAc.Name}"/>
            <apex:column value="{!contact.FirstName}"/>
            <apex:column value="{!contact.LastName}"/>
            <apex:column value="{!contact.Email}"/>
            <apex:column value="{!contact.Phone}"/>
And this is my Controller.
public class SaleController {
    public List<SelectOption> country {get;set;}
    public List<SelectOption> region {get;set;}
    public List<SelectOption> state {get;set;}    
    public String selectedCountry;
    public String selectedRegion;
    public String selectedState;
    public String tempCountry;
    public String tempRegion;
    public String tempState;
    public Account listOfAc {get;set;}  
    public List<Contact> listOfContact {get;set;} 
    Map<String,List<String>> countryWithState; 
    public SaleController(){
        country=new List<SelectOption>();
        region = new List<SelectOption>();
        state =new List<SelectOption>();
        state.add(new SelectOption('','--None--'));
        country.add(new SelectOption('','--None--'));    
        country.add(new SelectOption('India','India'));
        country.add(new SelectOption('China','China'));
        country.add(new SelectOption('US','US'));
        countryWithState = new  Map<String,List<String>>();
        countryWithState.put('IndiaNorth',new List<String>{'Delhi','Jammu','Himachal'});
        countryWithState.put('IndiaSouth',new List<String>{'Kerala','Karnataka'});
        countryWithState.put('IndiaWest',new List<String>{'Sikkim','Manipur','Meghalya'});
        countryWithState.put('ChinaNorth',new List<String>{'Hohot','jilin'});
        countryWithState.put('ChinaSouth',new List<String>{'yunan','hainan'});
        countryWithState.put('ChinaWest',new List<String>{'Zehenjang','shanghai'});
        countryWithState.put('USNorth',new List<String>{'New York','Washington'});
        countryWithState.put('USSouth',new List<String>{'Texas','Arizona'});
        countryWithState.put('USWest',new List<String>{'Virginia','ohio'});
    public String getSelectedCountry(){
        return selectedCountry;
    public void setSelectedCountry(String s){
        tempCountry = s;
        region.add(new SelectOption('','--None--'));
        region.add(new SelectOption('North','North'));
        region.add(new SelectOption('South','South'));
        region.add(new SelectOption('West','West'));
    public String getSelectedRegion(){
        return selectedRegion;
    public void setSelectedRegion(String s){
        if(s!=null && this.tempCountry!=null){
            for(String loopString:this.countryWithState.get(this.tempCountry+s)){
                state.add(new SelectOption(loopString,loopString));
    public String getSelectedState(){
        return selectedState;
    public void setSelectedState(String s){
    public String check(){
        return selectedCountry;
    public pageReference findRecord(){
        List<Id> listOfId =new List<Id>();
        if(tempCountry!=null && tempRegion!=null &&tempState!=null){
            for(Sales_Location__c tempSale:[select Account__c from Sales_Location__c where Country__c=:tempCountry and  State__c=:tempState and Region__c=:tempRegion])
            listOfAc = [Select Name,(Select FirstName,LastName,Phone,Email from Contacts)  from Account where Id In :listOfId limit 1];
            System.debug('All thing is Null');
        return null;

Is it possible to make interaction between two triggers ? Suppose I have two different triggers A and B. In A I want to save a List of id who Trigger.new and in other trigger B I want to access that list. Both Trigger are on different object. Is it possible
Is it possible to make interaction between two triggers ? Suppose I have two different triggers A and B. In A I want to save a List of id who Trigger.new and in other trigger B I want to access that list. Both Trigger are on different object. Is it possible
I'm not sure if I am just completely missing something or no one asks this question but I can't find a solution to this. I have a requirement to be able to upload images into the body of a rich text field which is being used to facilitate back and fourth communication in a SFDC community <> console.

User-added image

I've built a lightning app which works well except I can't figure out how I'm supposed to upload images into the field. Is lightning:inputRichText even capable of doing so? There is no documentation that says it doesn't and it's supposed to replace the legacy ui:richText field (which does not allow for local import anyways). I've also tried the CKEditor approach and that also does not support local import, not to mention with lockerservice enabled it does not render.

Whats weird is the editor we use here allpows for this functionality!!! I'm totally stumped, any help is appreciated.

Here is my component in case it helps:
<aura:component controller="caseCommentsController" implements="force:appHostable,forceCommunity:availableForAllPageTypes,force:hasRecordId" access="global">

  <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
  <aura:attribute name="comments" type="Case_Comments__c[]"/>
  <aura:attribute name="newComment" type="Case_Comments__c"
         default="{ 'sobjectType': 'Case_Comments__c'
  	<!-- display case comments -->
    <div class="container slds-p-top--medium">
    	<div id="list" class="row">
        	<aura:iteration items="{!v.comments}" var="comment">
            	<c:caseCommentsList comment="{!comment}"/>

  	<!-- input form using components -->
  	<div class="container slds-p-top--large">
    	<form class="slds-form--stacked">
        	<div class="slds-form-element">
           		<div class="slds-form-element__control">
             		<!-- ui:inputText aura:id="caseid" disabled="true"
                               value="{!v.newComment.Case__c}"/ -->               
         <div class="slds-form-element">
           <div class="slds-form-element__control">
             <lightning:inputRichText aura:id="addComment" 
                                      placeholder="Add a comment..."
               <!-- ui:inputRichText aura:id="addComment" required="true" placeholder="Add a comment..."
                               value="{!v.newComment.Comment__c}"/ -->                                
          <div class="slds-form-element">
          	<ui:button label="Add Comment" 
                       class="slds-button slds-button--neutral"
  </div><!-- ./container-->