• Sowmya Yakkala
  • NEWBIE
  • 40 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 5
    Replies
Hi,
I am able to insert Record in Account Object in Lightning. But i am not able to insert Record in Community.And getting Error like
Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type

And For that i had written Apex Class Below
@AuraEnabled
    Public Static Account createAccountRecord(Account newAccountdata) {
        if(newAccountdata !=null){
            newAccountdata.ownerId = UserInfo.getUserId();
            insert newAccountdata;
            System.debug('newAccountdata--'+newAccountdata);
        }
        return newAccountdata;
    }
Can anyone help me....
 
Hi,
I had written code for 3 fileds (FirstName,LastName,PhysicalAttributes) for inserting record in Contact Object.It was successfully Saving Record.
But when i am trying to insert Record using FirstName and LastName i am getting error like

Error creating record
Upsert failed. First exception on row 0; first error: INVALID_TYPE_ON_FIELD_IN_RECORD, Physical Attributes: value not of required type: : [Physical_Attributes__c]
Close


Because while Inserting Records we can skip some Fields(i.e;Non-Mandatory)Fields.Can any one Plz suggest me.

Here is my code:

<template>
    <lightning-card title="Insert Contact" icon-name="standard:contact">
            <div class="slds-p-around_x-small">
                <lightning-input label="FirstName" value={rec.FirstName} onchange={handleFirstNameChange}></lightning-input>
                <lightning-input label="LastName" value={rec.LastName} onchange={handleLastNameChange}></lightning-input>
                <lightning-input type="text" label="PhysicalAttributes" value={rec.Physical_Attributes__c} onchange={handlePhysicalAttributesChange}></lightning-input><br/>
                <lightning-button label="Save" onclick={handleClick}></lightning-button>
            </div>
        </lightning-card>
</template>

import { LightningElement,track } from 'lwc';
import createContact from '@salesforce/apex/insertContactApexWeb.saveContactRecord';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
import FIRSTNAME_FIELD from '@salesforce/schema/Contact.FirstName__c';
import LASTNAME_FIELD from '@salesforce/schema/Contact.LastName__c';
import PHYSICALATTRIBUTES_FIELD from '@salesforce/schema/Contact.Physical_Attributes__c';
export default class InsertContact extends LightningElement {
    @track firstname = FIRSTNAME_FIELD;
    @track lastname = LASTNAME_FIELD;
    @track physicalattributes = PHYSICALATTRIBUTES_FIELD;
   @track  rec = {
        FirstName : this.firstname,
        LastName : this.lastname,
        Physical_Attributes__c: this.physicalattributes
    }
    handleFirstNameChange(event) {
        this.rec.FirstName = event.target.value;
    }
    
    handleLastNameChange(event) {
        this.rec.LastName = event.target.value;
    }
    
    handlePhysicalAttributesChange(event) {
        this.rec.Physical_Attributes__c= event.target.value;
    }
    handleClick() {
        createContact({ con : this.rec })
       .then(result => {
            // Clear the user enter values
            this.rec = {};
            window.console.log('result ===> '+result);
            // Show success messsage
            this.dispatchEvent(new ShowToastEvent({
                title: 'Success!!',
                message: 'Contact Created Successfully!!',
                variant: 'success'
            }),);
        })
        .catch(error => {            
            this.error = error.message;
            window.console.log('error body--'+error.body.message);
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Error creating record',
                    message: error.body.message,
                    variant: 'error',
                }),
            );
            window.console.log("error", JSON.stringify(this.error));
        });

    }
    
}


Apex Class:
public with sharing class insertContactApexWeb {
   
    @AuraEnabled
    public static void saveContactRecord(Contact con){
        System.debug('acc--'+con);
        try{
            insert con;
        }
        catch(Exception ex) {
            throw new AuraHandledException(ex.getMessage());
        }
    }
}
Hi When i am trying to edit a record  as a Community User i am getting [Object Object] error msg . But when i login as System Administrator i am able to edit and Update the Record also. And I checked Profile of Community User there is Create and Edit For Contact Object.
Can any one help me were the error is...
Here is mycode

 <lightning:recordEditForm aura:id="recordEditForm"
                           objectApiName="Contact" onerror="{!c.handleError}" recordId="{!v.getrecordId}"> 
                <lightning:messages />
                                        <lightning:inputField  fieldName="Name" value="{!v.editContact.Name}"/>
                                        <lightning:inputField  fieldName="Email" value="{!v.editContact.Email}"/>
</lightning:recordEditForm>




 
When i going to create a Record in Location (Standard Object) iam not getting values from Component to Js (Controller).Can any one plz Suggest me.

Cmp:
<aura:component>
<aura:attribute name="newLocation"  type="Location" default="{'sobjectType': 'Location'}"/> 
<lightning:input label="Location Name" required="true" value="{!v.newLocation.Name}"/>
                                            <lightning:select label="Location Type" value="{!v.newLocation.LocationType}">
                                                <option value="">--None--</option>
                                                <aura:iteration items="{!v.locationTypeValues}" var="item">
                                                   <option value="{!item}" selected="selected">{!item}</option>                   
                                                </aura:iteration>
                                            </lightning:select>
                                            <lightning:input label="Street Name" value="{!v.newLocation.Street_Name__c}"/>
                                            <lightning:input label="City" value="{!v.newLocation.City__c}"/>
                                            <lightning:input label="State"  value="{!v.newLocation.State__c}"/>
                                            <lightning:input label="Zip"   value="{!v.newLocation.Zip__c}"/>
  </aura:component>
Controller:
  var newLocation = component.get("v.newLocation");
       alert('newLocation--'+newLocation);
          var action = component.get("c.createRecord");  
            action.setParams({
                newLocation : newLocation
            });            
            action.setCallback(this,function(response){                  
                var state = response.getState();
              //  alert('state--'+state);
                if(state === "SUCCESS"){                     
                    var recId = response.getReturnValue();
                    var toastEvent = $A.get("e.force:showToast");
                    toastEvent.setParams({
                        "message": "Record created Successfully.",
                         "type": "success"                                                
                    });
                    toastEvent.fire();   
                  $A.get('e.force:refreshView').fire();         
                } else if(state == "ERROR"){
                    
                    //alert('Error in calling server side action');
                    var toastEvent = $A.get("e.force:showToast");
                    toastEvent.setParams({
                        "message": 'Error in calling server side action',
                        "type": "Error"
                    });
                    toastEvent.fire(); 
                }
            });
         $A.enqueueAction(action);            
    }
 Apex Class:
@AuraEnabled
    Public Static void createRecord(List<Schema.Location> newLocation)
    {
       System.debug('newLocation----'+newLocation);
        if(newLocation !=null){
            insert newLocation;
        }    

    }   
How can i find unused Apex class methods in Salesforce using Tooling Api For that i find some blogs and they were saying to install Git,Maven,Heroku for that i am using canvas Develpor guide and i was confused wheather i am going in right way or not. Can anyone tell me i am in right way or not and steps to find unused Apex methods.
I had written .html file and succesfully Deployed in to Org but when i am viewing the Output it shows error like:

User-added image
Hi i want to display the data in newline and i tried with <br/> and </n> but it was not working. And my code is

for( Opportunity oppLst : [Select Id,Name,Cart_Grand_Total__c, (Select Product_SKU__c,DeliveryDate__c from  Shopping_cart_line_items__r where DeliveryDate__c >Today )
                                 from Opportunity where AccountId =:accountId  and  StageName='Closed Won' ])
       {
             for(Shopping_cart_line_item__c scL : oppLst.Shopping_cart_line_items__r){
              DateTime DeliveryDate = scL.DeliveryDate__c;
              upcmngDeleviries += DeliveryDate.format('MM/dd/yyyy')+'\n';
          }
           upcmngDeleviries +='$'+oppLst.Cart_Grand_Total__c +'\n';
       }
       return upcmngDeleviries ;

Actual Output: 01/23/2020 $660.29 01/22/2020 01/22/2020 $1373.84

Expected Output : 01/23/2020 $660.29
                              01/22/2020 01/22/2020 $1373.84
Actually when i selected Template i am getting the Data from apex class in Json Format. But the Problem here is, i want only Subject from the response from Apex class.

The Code is :
 getTemplate : function(component, event) {
        
        var tempName= component.get("v.selTempl");
        var action = component.get("c.getTemplateDetails");
        action.setParams({"templteId":tempName});
        action.setCallback(this,function(response){
              var responseVal = JSON.stringify(response.getReturnValue());
               component.set("v.subjTxt",responseVal.Subject);
               console.log('Subject--',subjTxt);
               component.set("v.templDetail",responseVal);                    
         });
       $A.enqueueAction(action);
  },

Actual Output is:
Selected Template Name: Scheduled Letter 
Response in JSON  Format - [{"Id":"00X2v000001H8xjEAC","Name":"Scheduled Letter","Subject":"Interview Scheduled","TemplateType":"visualforce"}]

Subject -- undefined

But Expected Output--
Subject -- Interview Scheduled

Can anyone pls Suggest the Solution for this....
When ever i click a Send Email Button, i will get Popup/Model like ToAddress,FromAddress,Subject,MailBody,Template.

But my requirement is when ever i Select Template ,Template name should populate on Subject and Template Body in Mail body.

Can anyone help me...
When i am trying to delete ToAddress Field data From EmailMessage Object I am Getting Error like.
Delete failed.  INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []

I tried with Query 
List<EmailMessage> lst = [Select ToAddress From EmailMessage];
Delete lst;

can any one Plz respond to above  Problem .
Thanks in advance.
When i am Lightning, System performance was becoming low why can i know the reason 
When i am logging in to Salesforce Org, I am not able to identify weather it is Salesforce Org (Or) Force.com Org .Can any One help me how to find it.
Hi,
I had written code for 3 fileds (FirstName,LastName,PhysicalAttributes) for inserting record in Contact Object.It was successfully Saving Record.
But when i am trying to insert Record using FirstName and LastName i am getting error like

Error creating record
Upsert failed. First exception on row 0; first error: INVALID_TYPE_ON_FIELD_IN_RECORD, Physical Attributes: value not of required type: : [Physical_Attributes__c]
Close


Because while Inserting Records we can skip some Fields(i.e;Non-Mandatory)Fields.Can any one Plz suggest me.

Here is my code:

<template>
    <lightning-card title="Insert Contact" icon-name="standard:contact">
            <div class="slds-p-around_x-small">
                <lightning-input label="FirstName" value={rec.FirstName} onchange={handleFirstNameChange}></lightning-input>
                <lightning-input label="LastName" value={rec.LastName} onchange={handleLastNameChange}></lightning-input>
                <lightning-input type="text" label="PhysicalAttributes" value={rec.Physical_Attributes__c} onchange={handlePhysicalAttributesChange}></lightning-input><br/>
                <lightning-button label="Save" onclick={handleClick}></lightning-button>
            </div>
        </lightning-card>
</template>

import { LightningElement,track } from 'lwc';
import createContact from '@salesforce/apex/insertContactApexWeb.saveContactRecord';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
import FIRSTNAME_FIELD from '@salesforce/schema/Contact.FirstName__c';
import LASTNAME_FIELD from '@salesforce/schema/Contact.LastName__c';
import PHYSICALATTRIBUTES_FIELD from '@salesforce/schema/Contact.Physical_Attributes__c';
export default class InsertContact extends LightningElement {
    @track firstname = FIRSTNAME_FIELD;
    @track lastname = LASTNAME_FIELD;
    @track physicalattributes = PHYSICALATTRIBUTES_FIELD;
   @track  rec = {
        FirstName : this.firstname,
        LastName : this.lastname,
        Physical_Attributes__c: this.physicalattributes
    }
    handleFirstNameChange(event) {
        this.rec.FirstName = event.target.value;
    }
    
    handleLastNameChange(event) {
        this.rec.LastName = event.target.value;
    }
    
    handlePhysicalAttributesChange(event) {
        this.rec.Physical_Attributes__c= event.target.value;
    }
    handleClick() {
        createContact({ con : this.rec })
       .then(result => {
            // Clear the user enter values
            this.rec = {};
            window.console.log('result ===> '+result);
            // Show success messsage
            this.dispatchEvent(new ShowToastEvent({
                title: 'Success!!',
                message: 'Contact Created Successfully!!',
                variant: 'success'
            }),);
        })
        .catch(error => {            
            this.error = error.message;
            window.console.log('error body--'+error.body.message);
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Error creating record',
                    message: error.body.message,
                    variant: 'error',
                }),
            );
            window.console.log("error", JSON.stringify(this.error));
        });

    }
    
}


Apex Class:
public with sharing class insertContactApexWeb {
   
    @AuraEnabled
    public static void saveContactRecord(Contact con){
        System.debug('acc--'+con);
        try{
            insert con;
        }
        catch(Exception ex) {
            throw new AuraHandledException(ex.getMessage());
        }
    }
}
Hi When i am trying to edit a record  as a Community User i am getting [Object Object] error msg . But when i login as System Administrator i am able to edit and Update the Record also. And I checked Profile of Community User there is Create and Edit For Contact Object.
Can any one help me were the error is...
Here is mycode

 <lightning:recordEditForm aura:id="recordEditForm"
                           objectApiName="Contact" onerror="{!c.handleError}" recordId="{!v.getrecordId}"> 
                <lightning:messages />
                                        <lightning:inputField  fieldName="Name" value="{!v.editContact.Name}"/>
                                        <lightning:inputField  fieldName="Email" value="{!v.editContact.Email}"/>
</lightning:recordEditForm>




 
How can i find unused Apex class methods in Salesforce using Tooling Api For that i find some blogs and they were saying to install Git,Maven,Heroku for that i am using canvas Develpor guide and i was confused wheather i am going in right way or not. Can anyone tell me i am in right way or not and steps to find unused Apex methods.
Hi,
I am new to Web components and When ever i am trying to insert a record in Contact Object it was saving with only FirstName,Lastname,Physical Attributes but i am getting Input of all other fields  in Js but in debug Logs it was showing only data of FirstName,Lastname, not Physical Attributes in ApexClass why?? Can i Know the  reason Why??

.HTML:

<template>
    <lightning-card title="Insert Contact" icon-name="standard:contact">
            <div class="slds-p-around_x-small">
                <lightning-input label="FirstName" value={rec.FirstName} onchange={handleFirstNameChange}></lightning-input>
                <lightning-input label="LastName" value={rec.LastName} onchange={handleLastNameChange}></lightning-input>
                <lightning-input type="text" label="PhysicalAttributes" value={rec.PhysicalAttributes} onchange={handlePhysicalAttributesChange}></lightning-input><br/>
                <lightning-button label="Save" onclick={handleClick}></lightning-button>
            </div>
        </lightning-card>
</template>

Js File:

import { LightningElement,track } from 'lwc';
import createContact from '@salesforce/apex/insertContactApexWeb.saveContactRecord';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
import FIRSTNAME_FIELD from '@salesforce/schema/Contact.FirstName__c';
import LASTNAME_FIELD from '@salesforce/schema/Contact.LastName__c';
import PHYSICALATTRIBUTES_FIELD from '@salesforce/schema/Contact.Physical_Attributes__c';
export default class InsertContact extends LightningElement {
    @track firstname = FIRSTNAME_FIELD;
    @track lastname = LASTNAME_FIELD;
    @track physicalattributes = PHYSICALATTRIBUTES_FIELD;
    rec = {
        FirstName : this.firstname,
        LastName : this.lastname,
        PhysicalAttributes : this.physicalattributes
    }
    handleFirstNameChange(event) {
        this.rec.FirstName = event.target.value;
        window.console.log("FirstName", this.rec.FirstName);
    }
    
    handleLastNameChange(event) {
        this.rec.LastName = event.target.value;
        window.console.log("LastName", this.rec.LastName);
    }
    
    handlePhysicalAttributesChange(event) {
        this.rec.PhysicalAttributes = event.target.value;
        window.console.log("PhysicalAttributes", this.rec.PhysicalAttributes);
    }
    handleClick() {
        createContact({ con : this.rec })
            .then(result => {
                this.message = result;
                this.error = undefined;
                if(this.message !== undefined) {
                    this.rec.Name = '';
                    this.rec.Industry = '';
                    this.rec.Phone = '';
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Success',
                            message: 'Account created',
                            variant: 'success',
                        }),
                    );
                }
                
                window.console.log(JSON.stringify(result));
                window.console.log("result", this.message);
            })
            .catch(error => {
                this.message = undefined;
                this.error = error;
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error creating record',
                        message: error.body.message,
                        variant: 'error',
                    }),
                );
                window.console.log("error", JSON.stringify(this.error));
            });
    }
    
}

Apex Class:

public with sharing class insertContactApexWeb {
   
    @AuraEnabled
    public static void saveContactRecord(Contact con){
        System.debug('acc--'+con);
        try{
            insert con;
        }
        catch(Exception ex) {
            throw new AuraHandledException(ex.getMessage());
        }
    }
}

 
Actually when i selected Template i am getting the Data from apex class in Json Format. But the Problem here is, i want only Subject from the response from Apex class.

The Code is :
 getTemplate : function(component, event) {
        
        var tempName= component.get("v.selTempl");
        var action = component.get("c.getTemplateDetails");
        action.setParams({"templteId":tempName});
        action.setCallback(this,function(response){
              var responseVal = JSON.stringify(response.getReturnValue());
               component.set("v.subjTxt",responseVal.Subject);
               console.log('Subject--',subjTxt);
               component.set("v.templDetail",responseVal);                    
         });
       $A.enqueueAction(action);
  },

Actual Output is:
Selected Template Name: Scheduled Letter 
Response in JSON  Format - [{"Id":"00X2v000001H8xjEAC","Name":"Scheduled Letter","Subject":"Interview Scheduled","TemplateType":"visualforce"}]

Subject -- undefined

But Expected Output--
Subject -- Interview Scheduled

Can anyone pls Suggest the Solution for this....