• kallam salesforce1
  • NEWBIE
  • 30 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 6
    Replies
HTML >>>
<template>
   
    <div class="slds-m-top_medium slds-m-bottom_x-large">
        <h2 class="slds-text-heading_medium slds-m-bottom_medium">
            Button-icons with the <code>variant</code> attribute omitted or set to the default value of <code>border</code>.
        </h2>
        <!-- with border / by default -->
        <div class="slds-p-around_medium lgc-bg">
            <lightning-button-icon icon-name="utility:add"  alternative-text="New Request" title="New request" onclick={showModalpopUp}></lightning-button-icon>
            <template if:true={isModalpopupTrue}>
                <!-- //<c-modal-popup-component></c-modal-popup-component> -->
                <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                    <div class="slds-modal__container">
                     <!-- modal header start -->
                       <header class="slds-modal__header">
                          <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={hideModalBox}>
                             <lightning-icon icon-name="utility:close"
                                alternative-text="close"
                                variant="inverse"
                                size="small" ></lightning-icon>
                             <span class="slds-assistive-text">Close</span>
                          </button>
                          <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Leave Request</h2>
                       </header>
                   
                       <!-- modal body start -->
                       <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                        <lightning-record-edit-form object-api-name={objectApiName}
                        record-id={recordId} onsuccess={handleSuccess}>
                        <lightning-messages></lightning-messages>
                        <lightning-input-field field-name={user}> </lightning-input-field>
                        <lightning-input-field field-name={FromDate}> </lightning-input-field>
                        <lightning-input-field field-name={Todate}> </lightning-input-field>
                        <lightning-input-field field-name={Reason}> </lightning-input-field>
                        <lightning-button  variant="brand"  type="submit" name="save" label="Save">
                        </lightning-button>
                        <lightning-button   type="submit" name="Cancel" label="Cancel" onclick={hideModalBox}>
                        </lightning-button>
                        </lightning-record-edit-form>
                             
                       </div>
             
                       <!-- modal footer start
                       <footer class="slds-modal__footer">
                        <lightning-button  variant="brand"  type="submit" name="save" label="Save">
                        </lightning-button>
                          <button class="slds-button slds-button_neutral" onclick={hideModalBox}>Cancel</button>
                       </footer> -->
                   
                    </div>
                 </section>
                 <div class="slds-backdrop slds-backdrop_open"></div>
           
            </template>
        </div>
        <div style="height: 300px;">
            <lightning-datatable
                    key-field="id"
                    data={tabledata}
                    columns={columns}
                    hide-checkbox-column
                    onrowaction={handleRowAction}>
            </lightning-datatable>
        </div>
    </div>        
</template>

Js file >>>>>>>>> 

 showModalpopUp(){
       this.isModalpopupTrue = true;
       console.log('Get the details of Lig input tag >>>>>>'+this.template.querySelectorAll("lightning-input-field"));
       
       this.template.querySelectorAll('lightning-input').forEach(element => {            
        element.value = null;
      });  
    }

Getting error as  >>
Get the details of Lig input tag >>>>>>SecureNodeList: [object NodeList]{ key: {"namespace":"c"} }
HTML.File
<template>
       <lightning-card>
        <lightning-combobox>
            label="Folders"
            value={value}            
            options={folders}
            onchange={handleChange}
        </lightning-combobox>
        
        </lightning-card>
       
</template>


Js.File

import { LightningElement,wire,track } from 'lwc';
import getFolder from '@salesforce/apex/EmailTemplates.getFolder'
export default class AddTempalte extends LightningElement {
    
    value = '';
    @track folders = [];
    

   
    @wire (getFolder) wiredgetfolder({data, error}){
        //console.log('Get the Folder deatails@@@'+JSON.stringify(data))
        if(data){
            console.log('Get the Folder deatails@@@'+JSON.stringify(data))
            this.folders = data.map(a=>({
                 label : a.Name,
                 value : a.Name
            }));
            console.log('Get the folder values &&&'+this.folders);
        }
        else if(error){
            console.log('Get the error details are @@@'+error)
        }
    }
   
    handleChange(event){
        console.log('Get the folder values'+this.folders);
        this.value  = event.detail.value;
    }
        
}

I am getting data in Wire method as
**Get the Folder deatails@@@[{"Id":"00l5g000003cQw4AAE","Name":"EX","Type":"EmailTemplate"}] Get the folder values[object Object] **
 

import updateParentCase from '@salesforce/apex/UpdateMotherCase.updateParentCase';
export default class InitiateMotherCase extends LightningElement {
    @api recordId;
    handleClick(event){
       console.log('Get the record Id is'+this.recordId);
       
       updateParentCase({rid:'$recordId'}).then(result =>{
              console.log('Get details'+result);
           }).catch( error => {});
       
    }

 

Apex method>>>>>

@AuraEnabled(cacheable=true)
    public static void updateParentCase(String rid){
        try{
        System.debug('Get the case record Id details'+rid);
        list<Case> c = [SELECT id,CaseNumber,ParentId,Recently_Updated__c from case  where id =: rid AND ParentId != null];
        System.debug('Get the case details'+c);

}

}

 

Send email action in case feed. In classic mode we can see Discard Draft and Save link ?

User-added image

But In lightning Discard Draft and save links are disppared?

User-added image

 

User-added imageI created send email quick action in chatter feed. But I can able to see only send Button. How can i able to get save and Submit for approval in chat feed mentioned in the above image?

User-added image

list<GroupMember> grpNameList = [SELECT UserOrGroupId, Group.DeveloperName FROM GroupMember WHERE Group.DeveloperName = 'Sales_Reports_Group'  AND Group.Type = 'Regular'];

Map<String,list<Id>> UserIdsWithGroupNames = new Map<String,List<Id>>();
 
for(GroupMember grp :grpNameList){
    if(!UserIdsWithGroupNames.containsKey(grp.Group.DeveloperName)){
         UserIdsWithGroupNames.put(grp.Group.DeveloperName, new List<Id>());
        
    }
    else{
        UserIdsWithGroupNames.get(grp.Group.DeveloperName).add(grp.UserOrGroupId);
    }
}
Map<Id, String> userEmailsById = new Map<Id, String>();
        // Get Emails from active users from group
        for(User u :[SELECT Id, Email FROM User WHERE Id IN :UserIdsWithGroupNames.values() AND IsActive = true]) {
            userEmailsById.put(u.Id, u.Email);
        }    

Help me how to resolve this issuse?
>>> TableSorting.Html
<template>
    <lightning-card title="Data Sorting in Lightning Datatable in LWC" icon-name="standard:contact" >
        <br/>
        <div style="width: auto;">
            <template if:true={data}>
                <lightning-datatable data={data}
                                     columns={columns}
                                     key-field="id"
                                     sorted-by={sortBy}
                                     sorted-direction={sortDirection}
                                     onsort={doSorting}
                                     hide-checkbox-column="true"></lightning-datatable>
            </template>
        </div>
    </lightning-card>
</template>


>>>>>>>>> TableSorting.js

import { LightningElement,track,wire } from 'lwc';
import getContactsInfo from '@salesforce/apex/GetContacts.getContactsInfo';
const columns = [ { label: 'FirstName', fieldName: 'FirstName', sortable: "true"},
                  { label: 'LastName', fieldName: 'LastName', sortable: "true"},
                  { label: 'Phone', fieldName: 'Phone', type: 'phone', sortable: "true"},
                  { label: 'Email', fieldName: 'Email', type: 'email', sortable: "true" },];
export default class TableSorting extends LightningElement {
    @track data;
    @track columns = columns;
    @track sortBy;
    @track sortDirection;
 
    @wire(getContactsInfo)
    contacts(result) {
        if (result.data) {
            this.data = result.data;
            console.log(result.data)
            this.error = undefined;
        } else if (result.error) {
            this.error = result.error;
            this.data = undefined;
        }
    }
    doSorting(event) {
        this.sortBy = event.detail.fieldName;
        this.sortDirection = event.detail.sortDirection;
        this.sortData(this.sortBy, this.sortDirection);
    }
    sortData(fieldname, direction) {
        let parseData = JSON.parse(JSON.stringify(this.data));
        // Return the value stored in the field
        let keyValue = (a) => {
            return a[fieldname];
        };
        // cheking reverse direction
        let isReverse = direction === 'asc' ? 1: -1;
        // sorting data
        parseData.sort((x, y) => {
            x = keyValue(x) ? keyValue(x) : ''; // handling null values
            y = keyValue(y) ? keyValue(y) : '';
            // sorting values based on direction
            return isReverse * ((x > y) - (y > x));
        });
        this.data = parseData;
        console.log(this.data);
    }    
}

>>>>>>>>  Apex class
public with sharing class GetContacts {
   
    @AuraEnabled(Cacheable = true)
    public static list<Contact> getContactsInfo(){
       return  [SELECT Id,FirstName,LastName,Phone,Email from Contact];
    }
}

User-added imageIn Table you can find in 1st cloumn unable to sort particulsr NAme?
APEX  Class>>>>>>>>>
public with sharing class AccountManager {
   
    @AuraEnabled(cacheable=true)
    public static list<Account> getAccounts(){
           
       list<Account> listAcc = [SELECT Id,Name,Rating,AnnualRevenue from Account LIMIT 8];
       return listAcc;
    }
    @AuraEnabled
    public static void deleteselectedRecords(list<Id> listOfIds){
        list<Account>  listOfAcc = [SELECT Id,Name,Rating,AnnualRevenue from Account where ID IN : listOfIds];
        if(!listOfAcc.isEmpty()){
            delete listOfAcc;
        }
    }
}
html>>>>>>>>>>>>>>>>>>
<template>
    <lightning-card title="Delete selected Rows">
        <lightning-datatable
        key-field="id"
        data={getDetials}
        columns={columns} onrowselection={onselctedRowHandler}
        >
           
        </lightning-datatable>
        <div class="slds-m-around_medium">
            <lightning-button label="DeleteSelectedRecords" variant="brand" onclick={ClickDeleteRecords}></lightning-button>
        </div>
       
    </lightning-card>
</template>

import { LightningElement,wire } from 'lwc';
import getAccounts from '@salesforce/apex/AccountManager.getAccounts'
import deleteselectedRecords from '@salesforce/apex/AccountManager.deleteselectedRecords'
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';
export default class DeleteSelectedRows extends LightningElement {
getDetials
columns =[
    {label:'Id',fieldName:'Id'},
    {label:'AccName',fieldName:'Name'},
    {label:'Rating',fieldName:'Rating'},
    {label:'AnnualRevenue',fieldName:'AnnualRevenue'}
];
@wire (getAccounts) getAccdetails({data,error}){
if(data){
    this.getDetials = data;
     console.log(data)
     console.log(this.getDetials)
}
else{
     console.log(error)
}
}
seletedRowIdList =[]
onselctedRowHandler(event){
    const seletedRows = event.detail.selectedRows
   console.log(seletedRows)
   for(let i=0; i< seletedRows.length; i++){
    this.seletedRowIdList.push(seletedRows[i].Id)
    console.log(this.seletedRowIdList)
   }
}
ClickDeleteRecords(){
    deleteselectedRecords({listOfIds : this.seletedRowIdList}).then(()=>
    {
        const toastEvent = new ShowToastEvent({
            title:'Success!',
            message:'Record deleted successfully',
            variant:'success'
          });
          this.dispatchEvent(toastEvent);
          return refreshApex(this.getAccdetails);
    }
    ).catch((error)=>{
        console.log(error)
    }
    );
}
}

 
@RestResource(urlmapping='/v1/Accounts/*')
global with sharing class MultipleRecords {
   
    @HttpGet
    global static list<Account> getAccounts(){
         
        RestRequest accRequest = RestContext.request;
        map<String,String> accReqParams = accRequest.Params;
        string rating = accReqParams.get('Rating');
        list<Account> listAcc = [Select id,Name,Rating from Account where Rating =: rating];
        return listAcc;

    }
       
}
>>Query in POSTMAN
https://kallam12-dev-ed.my.salesforce.com/services/apexrest/v1/Accounts/?Rating=Hot 

How to get both where rating is Hot and Cold?

Can some one help me error in Code.

 @HttpPost
    global static String CreateContacts(){
        RestRequest request = RestContext.request;
        String requestBody = request.requestBody.toString();
       
       list<Contact> listcon = (List<Contact>) JSON.deserialize(requestBody, contact.class);
       if(!listcon.isEmpty()){
        insert  listcon;
        return 'SUCCESS';
       }
       else{
           return 'Failed';
       }
    }

REquest Body >>

[{
  "FirstName" : "Test2",
  "LastName"  : "Vasu"
},
{
  "FirstName" : "Test3",
  "LastName"  : "Vasu"
}
]

Getting error 

 APEX_ERROR
message: System.JSONException: Json Deserialization failed on token 'null' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row Class.System.JSON.deserialize: line 15, column 1 Class.AccountManager.CreateContacts: line 59, column 1 

 @HttpPost
    global static Contact CreateContacts(){
        RestRequest request = RestContext.request;
        String requestBody = request.requestBody.toString();
       
        list<Contact> con = (List<Contact>) JSON.deserialize(requestBody, list<Contact>.class);
        insert  con;
        return con;
    }

Passing Request Body>>

{"records" :[ { "FirstName": "test1", "LastName": "hello", }, { "FirstName": "test2", "LastName": "hello", }, { "FirstName": "test3", "LastName": "hello", }]

this code is not working.
Here i am using @wire as property and trying to iterate values. Could you please tell what is the error in below program?

public with sharing class lDS_GetContacts_Wire2 {
    @AuraEnabled(cacheable=true)
    public static list<Contact> findContacts(string searchtext){
          string key = '%'+searchtext+'%';
          return [Select id,Name,Phone,Email from Contact where FirstName LIKE:key];
    }
}

HTML FILE

<template>
    <lightning-card title="Search Contact WIRE">
        <lightning-input label="Enter the Search Text" type="search" value={searchkey} onchange={handleOnchange}>
            <template if:true={contact.data}>
                <template for:each={contact.data} for:item="con">
                    <p key={con.id}>{con.Name}</p>
                </template>
            </template>
            <template if:true={contact.error}>
                Sorry we can't display your record due to {contact.error}. Please Try Later.
            </template>
        </lightning-input>
    </lightning-card>
</template>

Js File >>>>>>>
import { LightningElement,track,wire} from 'lwc';
import findcontacts from '@salesforce/apex/lDS_GetContacts_Wire2.findContacts';
export default class LDS_SearchContact_Wire extends LightningElement {
    @track searchkey;
    @wire (findcontacts,{searchtext :'$searchkey'}) contact;
    handleOnchange(event){
        this.searchkey = event.target.value;
    }
}
 
public with sharing class lDS_GetContacts_Wire2 {
    @AuraEnabled(cacheable=true)
    public static list<Contact> findContacts(string searchtext){
          string key = '%'+searchtext+'%';
          return [Select id,Name,Phone,Email from Contact where FirstName LIKE:key];
    }
}

HTML FILE

<template>
    <lightning-card title="Search Contact WIRE">
        <lightning-input label="Enter the Search Text" type="search" value={searchkey} onchange={handleOnchange}>
            <template if:true={contact.data}>
                <template for:each={contact.data} for:item="con">
                    <p key={con.id}>{con.Name}</p>
                </template>
            </template>
            <template if:true={contact.error}>
                Sorry we can't display your record due to {contact.error}. Please Try Later.
            </template>
        </lightning-input>
    </lightning-card>
</template>

Js File >>>>>>>
import { LightningElement,track,wire} from 'lwc';
import findcontacts from '@salesforce/apex/lDS_GetContacts_Wire2.findContacts'
export default class LDS_SearchContact_Wire extends LightningElement {
    @track searchkey;
    @wire (findcontacts,{searchtext :'$searchkey'}) contact;
    handleOnchange(event){
        this.searchkey = event.target.value;
    }
}



 
HTML >>>
<template>
   
    <div class="slds-m-top_medium slds-m-bottom_x-large">
        <h2 class="slds-text-heading_medium slds-m-bottom_medium">
            Button-icons with the <code>variant</code> attribute omitted or set to the default value of <code>border</code>.
        </h2>
        <!-- with border / by default -->
        <div class="slds-p-around_medium lgc-bg">
            <lightning-button-icon icon-name="utility:add"  alternative-text="New Request" title="New request" onclick={showModalpopUp}></lightning-button-icon>
            <template if:true={isModalpopupTrue}>
                <!-- //<c-modal-popup-component></c-modal-popup-component> -->
                <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                    <div class="slds-modal__container">
                     <!-- modal header start -->
                       <header class="slds-modal__header">
                          <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={hideModalBox}>
                             <lightning-icon icon-name="utility:close"
                                alternative-text="close"
                                variant="inverse"
                                size="small" ></lightning-icon>
                             <span class="slds-assistive-text">Close</span>
                          </button>
                          <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Leave Request</h2>
                       </header>
                   
                       <!-- modal body start -->
                       <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                        <lightning-record-edit-form object-api-name={objectApiName}
                        record-id={recordId} onsuccess={handleSuccess}>
                        <lightning-messages></lightning-messages>
                        <lightning-input-field field-name={user}> </lightning-input-field>
                        <lightning-input-field field-name={FromDate}> </lightning-input-field>
                        <lightning-input-field field-name={Todate}> </lightning-input-field>
                        <lightning-input-field field-name={Reason}> </lightning-input-field>
                        <lightning-button  variant="brand"  type="submit" name="save" label="Save">
                        </lightning-button>
                        <lightning-button   type="submit" name="Cancel" label="Cancel" onclick={hideModalBox}>
                        </lightning-button>
                        </lightning-record-edit-form>
                             
                       </div>
             
                       <!-- modal footer start
                       <footer class="slds-modal__footer">
                        <lightning-button  variant="brand"  type="submit" name="save" label="Save">
                        </lightning-button>
                          <button class="slds-button slds-button_neutral" onclick={hideModalBox}>Cancel</button>
                       </footer> -->
                   
                    </div>
                 </section>
                 <div class="slds-backdrop slds-backdrop_open"></div>
           
            </template>
        </div>
        <div style="height: 300px;">
            <lightning-datatable
                    key-field="id"
                    data={tabledata}
                    columns={columns}
                    hide-checkbox-column
                    onrowaction={handleRowAction}>
            </lightning-datatable>
        </div>
    </div>        
</template>

Js file >>>>>>>>> 

 showModalpopUp(){
       this.isModalpopupTrue = true;
       console.log('Get the details of Lig input tag >>>>>>'+this.template.querySelectorAll("lightning-input-field"));
       
       this.template.querySelectorAll('lightning-input').forEach(element => {            
        element.value = null;
      });  
    }

Getting error as  >>
Get the details of Lig input tag >>>>>>SecureNodeList: [object NodeList]{ key: {"namespace":"c"} }

import updateParentCase from '@salesforce/apex/UpdateMotherCase.updateParentCase';
export default class InitiateMotherCase extends LightningElement {
    @api recordId;
    handleClick(event){
       console.log('Get the record Id is'+this.recordId);
       
       updateParentCase({rid:'$recordId'}).then(result =>{
              console.log('Get details'+result);
           }).catch( error => {});
       
    }

 

Apex method>>>>>

@AuraEnabled(cacheable=true)
    public static void updateParentCase(String rid){
        try{
        System.debug('Get the case record Id details'+rid);
        list<Case> c = [SELECT id,CaseNumber,ParentId,Recently_Updated__c from case  where id =: rid AND ParentId != null];
        System.debug('Get the case details'+c);

}

}

 

list<GroupMember> grpNameList = [SELECT UserOrGroupId, Group.DeveloperName FROM GroupMember WHERE Group.DeveloperName = 'Sales_Reports_Group'  AND Group.Type = 'Regular'];

Map<String,list<Id>> UserIdsWithGroupNames = new Map<String,List<Id>>();
 
for(GroupMember grp :grpNameList){
    if(!UserIdsWithGroupNames.containsKey(grp.Group.DeveloperName)){
         UserIdsWithGroupNames.put(grp.Group.DeveloperName, new List<Id>());
        
    }
    else{
        UserIdsWithGroupNames.get(grp.Group.DeveloperName).add(grp.UserOrGroupId);
    }
}
Map<Id, String> userEmailsById = new Map<Id, String>();
        // Get Emails from active users from group
        for(User u :[SELECT Id, Email FROM User WHERE Id IN :UserIdsWithGroupNames.values() AND IsActive = true]) {
            userEmailsById.put(u.Id, u.Email);
        }    

Help me how to resolve this issuse?
public with sharing class lDS_GetContacts_Wire2 {
    @AuraEnabled(cacheable=true)
    public static list<Contact> findContacts(string searchtext){
          string key = '%'+searchtext+'%';
          return [Select id,Name,Phone,Email from Contact where FirstName LIKE:key];
    }
}

HTML FILE

<template>
    <lightning-card title="Search Contact WIRE">
        <lightning-input label="Enter the Search Text" type="search" value={searchkey} onchange={handleOnchange}>
            <template if:true={contact.data}>
                <template for:each={contact.data} for:item="con">
                    <p key={con.id}>{con.Name}</p>
                </template>
            </template>
            <template if:true={contact.error}>
                Sorry we can't display your record due to {contact.error}. Please Try Later.
            </template>
        </lightning-input>
    </lightning-card>
</template>

Js File >>>>>>>
import { LightningElement,track,wire} from 'lwc';
import findcontacts from '@salesforce/apex/lDS_GetContacts_Wire2.findContacts'
export default class LDS_SearchContact_Wire extends LightningElement {
    @track searchkey;
    @wire (findcontacts,{searchtext :'$searchkey'}) contact;
    handleOnchange(event){
        this.searchkey = event.target.value;
    }
}