-
ChatterFeed
-
110Best Answers
-
0Likes Received
-
4Likes Given
-
1Questions
-
497Replies
How to Get Records From Flow + Lwc
is there any way for fetching data/records from lightning flow and show in custom table in lwc?
I tried but didn't succeed.can you please give me any example or guide that how can we achieve this?
I believe you guys help me.
Thanks in advance
- Mohit Sharma 397
- January 23, 2023
- Like
- 0
- Continue reading or reply
custom datatable with Inline Editing In Lwc
I have one requirment I want a custom datatable with inline editing in lwc.
can you please provide me any reference.
Thanks in advance
- test vijay
- January 23, 2023
- Like
- 0
- Continue reading or reply
Change Lightning-Button Color & Size- LWC
I'm new to LWC.
How do I change the button color and size of a lightning-button? It's taking the default from "Variant".
Alternatively, can I use anything else (like icon)?
Any help in this regard is really appreciated.
- SambitNayak
- September 17, 2022
- Like
- 0
- Continue reading or reply
System.QueryException: List has no rows for assignment to SObject, someone help me
ServiceContract scQuery = [SELECT BankId__c, Agencia__c, Conta__c, CNPJ__c, Digito_Conta__c,Type_de_Conta_Bancaria__c, Conta_Savings__c from ServiceContract limit 1 ];
how do i fix it?
- jOseMC
- July 14, 2022
- Like
- 0
- Continue reading or reply
unable to fetch records from case
my query is -
Select id, Status, Account.Name from Case where Contact IN ('Forbes, Sean', 'Pavlova, Stella')
can anyone plz suggest if any mistake
- Abhishek Sharma 527
- July 13, 2022
- Like
- 0
- Continue reading or reply
batch process with try-catch block
//this is my code
global class BatchDemo_Lead implements Database.Batchable<sObject>{
try{
global Database.QueryLocator start(Database.BatchableContext bc){
return Database.getQueryLocator([Select id from Lead]);
}
}
global void execute(Database.BatchableContext bc, List<Lead> scope){
for(Lead l : scope)
{
if(l.State == 'VA'){
l.State = 'NJ';
}
}
update scope;
}
global void finish(Database.BatchableContext bc){
system.debug('Batch process finished.');
}
catch(Exception e){
return Database.getQueryLocator(Select id, State from Lead);
System.debug('DML operation executed from catch block');
}
}
- Abhishek Sharma 527
- July 13, 2022
- Like
- 0
- Continue reading or reply
how to achieve100%test coverage for this batch class.
global Integer recordsProcessed = 0;
global Database.QueryLocator start(Database.BatchableContext bc) {
string query='select Rating,(select StageName from Opportunities where StageName=\''+String.escapeSingleQuotes('Inprogress,Delivered,closedwon')+ '\') From account where Rating <> \''+String.escapeSingleQuotes('client') + '\'';
return Database.getQueryLocator(query);
}
global Void execute(Database.BatchableContext bc, List<Account> Scope){
for(Account a :Scope){
a.Rating='client';
recordsProcessed = recordsProcessed + 1;
}
update Scope; }
global void finish(Database.BatchableContext bc){
System.debug(recordsProcessed + 'records processed. Shazam!');
}
}
test class
@isTest public class UpdateAccountRatingTest {
@testSetup static void setup() {
Account ac =new Account();
ac.Name = 'test';
ac.rating='prospect';
insert ac;
ac.Name = 'test';
ac.rating='client';
update ac; }
@isTest static void test() {
Test.startTest();
UpdateAccountRating uar = new UpdateAccountRating();
Id batchId = Database.executeBatch(uar);
Test.stopTest(); } }
Thanks in advance
- suji srinivasan
- June 13, 2022
- Like
- 0
- Continue reading or reply
Display Case Type as button in LWC in Contact Record Page
Something like this:
- Yukinon
- June 13, 2022
- Like
- 0
- Continue reading or reply
Getting 15% of Code Coverage
Apex Class
Test Class
- B_k
- June 12, 2022
- Like
- 0
- Continue reading or reply
Inline Editing In Lwc
Greeting, Guys I have a requirement regarding inline editing in lwc.
Problem is there are lots of example about inline editing in aura but I haven't found any example about lwc. if someone can help me, will be good for me.
Thanks in advance
- Govind Bangalore
- June 02, 2022
- Like
- 0
- Continue reading or reply
How to increase quickAction Button Width/Height In LWC
I am working on a project and I am facing a challenge. I have a lwc component that is added in lwc quickAction Button. now the challenge is how to increase the quickAction Button Width/Height in Lwc.
There is an option in aura quickAction button but I have to work in lwc.
Please show me some way.
Thanks in advance
- Govind Bangalore
- May 28, 2022
- Like
- 0
- Continue reading or reply
Get leads in input fields, not in columns
I have leadtable as in the image.
I need get leads in input fields to save them automatically, not in columns. Please tell me how can I do that.
My code:
Html
<template>
<lightning-card title="Leads">
<lightning-layout multiple-rows="true" vertical-align="end">
<lightning-layout-item size="12" padding="around-small">
<lightning-datatable key-field="id" data={leads} columns={columns}>
</lightning-datatable>
<lightning-input class="slds-p-around_medium" label="Name" name="leadName"
onchange={nameChangedHandler}></lightning-input>
<lightning-input class="slds-p-around_medium" label="Title" name="leadTitle"
onchange={titleChangedHandler}></lightning-input>
<lightning-input class="slds-p-around_medium" label="Phone" type="phone" name="leadPhone"
onchange={phoneChangedHandler}></lightning-input>
<br/>
</lightning-layout-item>
</lightning-layout>
</lightning-card>
</template>
Js
import { LightningElement, wire } from 'lwc';
import getLeads from '@salesforce/apex/ProjectThree.getLeads';
import LEAD_OBJECT from '@salesforce/schema/Lead';
import NAME_FIELD from '@salesforce/schema/Lead.Title';
import TITLE_FIELD from '@salesforce/schema/Lead.Title';
import PHONE_FIELD from '@salesforce/schema/Lead.Phone';
const columns = [
{ label: 'Name', fieldName: 'recordLink', type: 'url',
typeAttributes: {label: {fieldName: "LeadName"}, tooltip: "Name", linkify: true} },
{ label: 'Title', fieldName: 'Title', type: 'text', editable: true },
{ label: 'Phone', fieldName: 'Phone', type: 'text', editable: true }
];
export default class LdsCreateRecord extends LightningElement {
columns = columns;
leads;
lead = LEAD_OBJECT;
myFields = [NAME_FIELD, TITLE_FIELD, PHONE_FIELD];
strName;
strTitle;
strPhone;
// Change Handlers.
nameChangedHandler(event){
this.strName = event.target.value;
}
titleChangedHandler(event){
this.strAccountNumber = event.target.value;
}
phoneChangedHandler(event){
this.strPhone = event.target.value;
}
@wire(getLeads)
wiredLeads(value) {
const {error, data} = value;
if (data) {
let leadData = JSON.parse(JSON.stringify(data));
leadData.forEach(record => {
record.recordLink = "/" + record.Id;
record.LeadName = record.Name;
});
this.leads = leadData;
} else if (error) {
this.error = error;
}
}
}
public with sharing class ProjectThree {
@AuraEnabled(cacheable=true)
public static List<Lead> getLeads() {
List<Lead> leads = [
SELECT Id, Name, Title, Phone
FROM Lead
//WHERE Name Like 'Lisa%'
Limit 3
];
System.debug('leads = ' + leads);
return leads;
}
}
- Mike Tol 1
- April 25, 2022
- Like
- 0
- Continue reading or reply
A simple concatenation question
I have contact table and need to get Id + Name as concatenation of Id '0032v000034aSJyAAM' and string 'Name' like on the image.
Please tell me how can I do that.
Here is code:
Html:
<template>
<lightning-card title="Contacts">
<lightning-layout multiple-rows="true" vertical-align="end">
<lightning-layout-item size="12" padding="around-small">
<lightning-datatable key-field="id" data={contacts} columns={columns}></lightning-datatable>
</lightning-layout-item>
</lightning-layout>
</lightning-card>
</template>
Js:
import { LightningElement , wire} from 'lwc';
import getContacts from '@salesforce/apex/Qqq.getContacts';
let N = 'Name';
const columns = [
{ label: 'idName', fieldName: 'Id' + N, type: 'text' },
{ label: 'Name', fieldName: 'recordLink', type: 'url',
typeAttributes: {label: {fieldName: "ContactName"}, tooltip: "Name", linkify: true} }
];
export default class ContactTable extends LightningElement {
columns = columns;
contacts;
@wire(getContacts)
wiredContacts(value) {
const {error, data} = value;
if (data) {
let contactData = JSON.parse(JSON.stringify(data));
contactData.forEach(record => {
record.recordLink = "/" + record.Id;
record.ContactName = record.Name;
});
this.contacts = contactData;
} else if (error) {
this.error = error;
}
}
}
Apex:
public with sharing class Qqq {
@AuraEnabled(cacheable=true)
public static List<Lead> getLeads() {
List<Lead> leads = [
SELECT Id, Name, Title, Phone
FROM Lead
WHERE Name Like 'Lisa%'
Limit 3
];
System.debug('leads = ' + leads);
return leads;
}
@AuraEnabled(cacheable=true)
public static List<Contact> getContacts() {
List<Contact> contacts = [
SELECT Id, Name
FROM Contact
//WHERE LastName Like 'Apex%'
Limit 3
];
System.debug('contacts = ' + contacts);
return contacts;
}
}
- Mike Tol 1
- April 22, 2022
- Like
- 0
- Continue reading or reply
Data of Lead doesn’t redirect to the detail page current Lead
I have lead table.
I need that when I click on the name of the lead, it opens the detail page current Lead.
The link seems to work, but the detail page current Lead does not open. Please tell me how to fix it.
My code:
Html:
<template>
<lightning-card title="Leads">
<lightning-layout multiple-rows="true" vertical-align="end">
<lightning-layout-item size="12" padding="around-small">
<lightning-datatable key-field="id" data={leads} columns={columns}></lightning-datatable>
</lightning-layout-item>
</lightning-layout>
</lightning-card>
</template>
Js:
import { LightningElement , wire} from 'lwc';
import getLeads from '@salesforce/apex/Qqq.getLeads';
const columns = [
{ label: 'Name', fieldName: 'Name', type: 'url',
typeAttributes: {label: {fieldName: "Name"}, tooltip: "Name", linkify: true} },
{ label: 'Title', fieldName: 'Title', type: 'text' },
{ label: 'Phone', fieldName: 'Phone', type: 'text' }
];
export default class LightningDatatableLWCExample extends LightningElement {
columns = columns;
leads;
@wire(getLeads)
wiredLeads(value) {
const {error, data} = value;
if (data) {
let leadData = JSON.parse(JSON.stringify(data));
leadData.forEach(record => {
if (record.LeadId) {
record.recordLink = "/" + record.LeadId;
record.LeadName = record.Lead.Name;
}
});
this.leads = leadData;
} else if (error) {
this.error = error;
}
}
}
- Mike Tol 1
- April 21, 2022
- Like
- 0
- Continue reading or reply
How create contact using lightning-input-field?
I created a contact using lightning-input.
But I need to create a contact (and lookup search Account) using lightning-input-field. I сan't link html with js and Apex. Please tell me how can I do that. (I must use Apex).
My code with lightning-input that works:
Html:
<template>
<lightning-card if:true={showModal}>
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<lightning-button-icon class="slds-modal__close" title="Close" icon-name="utility:close" icon-class="slds-button_icon-inverse" onclick={handleDialogClose}></lightning-button-icon>
<div class="slds-modal__header">
<h1 id="modal-heading-01" class="slds-modal__title slds-hyphenate">Create contact with custom lookup</h1>
</div>
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<lightning-card title="New contact" icon-name="standard:contact">
<div class="slds-p-around_x-small">
<lightning-input type="text" label="Last name" value={rec.LNAME} onchange={handlelnameChange}></lightning-input>
<br/>
<lightning-button label="Save" onclick={handleClick}></lightning-button>
</div>
</lightning-card>
</div>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open" role="presentation"></div>
</lightning-card>
</template>
Js:
import { LightningElement, api, wire, track } from 'lwc';
import LNAME_FIELD from '@salesforce/schema/Contact.LastName';
import insertContact from '@salesforce/apex/ContactTableProjectSecond.addContact';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import getContacts from '@salesforce/apex/ContactTableProjectSecond.getContacts';
import {refreshApex} from "@salesforce/apex";
export default class LwcNewContactUsingApexImperativecalling extends LightningElement {
showModal = false;
@track lname =LNAME_FIELD;
rec={
LNAME:this.lname,
}
@wire(getContacts)
wiredCallback(result) {
this._wiredResult = result;
}
handlelnameChange(event) {
this.rec.LNAME = event.target.value;
window.console.log("LNAME", this.rec.LNAME);
}
handleClick() {
const contact = {
LastName: this.rec.LNAME,
}
insertContact ({ con : contact })
.then(() => {
// this.rec={}; // Don't. You aren't clearing the value of rec properties, you're removing them. So everywhere you're using them you'll get an error because they will be now undefined properties.
this.rec.LNAME = null;
this.dispatchEvent(
new ShowToastEvent({
title: 'Success',
message: 'Contact created',
variant: 'success',
}),
);
})
.catch((error) => {
this.dispatchEvent(
new ShowToastEvent({
title: 'Error creating record',
message: error.body.message,
variant: 'error',
}),
);
console.log('error', JSON.stringify(error));
});
}
@api show() {
this.showModal = true;
}
handleDialogClose() {
this.showModal = false;
}
// @track selectedAccountId;
// handleSelected(event){
// console.log(event.detail);
// this.selectedAccountId = event.detail;
// }
}
Apex:
public with sharing class ContactTableProjectSecond {
@AuraEnabled(cacheable=true)
public static List<Contact> getContacts() {
return [
SELECT Id, FirstName, LastName, Phone, Email, Account.Name, AccountId, CreatedDate
FROM Contact
];
}
@AuraEnabled(cacheable=true)
public static List<Contact> searchContacts(String searchKey) {
String searchKeyword = '%' + searchKey + '%';
List<Contact> contacts = [
SELECT Id, FirstName, LastName, Phone, Email, Account.Name, AccountId, CreatedDate
FROM Contact
WHERE Name LIKE :searchKeyword
];
return contacts;
}
@AuraEnabled
public static void deleteContact(Id recordId) {
List<Contact> contact = [SELECT Id FROM Contact WHERE Id = :recordId];
delete contact;
}
@AuraEnabled
public static Contact addContact(Contact con) {
//Contact contact = new Contact();
system.debug('con'+con);
insert con;
return con;
}
@AuraEnabled(cacheable=true)
public static List<account> getCustomLookupAccount(String actName) {
List<account> accountLookupList = new List<account>();
System.debug('accountLookupList' + accountLookupList);
if (actName != '') {
String accountName = '%' + actName + '%';
accountLookupList = [SELECT Id, Name FROM Account WHERE Name like:accountName];
return accountLookupList;
}
return accountLookupList;
}
}
My code with lightning-input-field that doesn’t work:
Html:
<template>
<lightning-card if:true={showModal} title={cardTitle}>
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<lightning-button-icon class="slds-modal__close" title="Close" icon-name="utility:close" icon-class="slds-button_icon-inverse" onclick={handleDialogClose}></lightning-button-icon>
<div class="slds-modal__header">
<h1 id="modal-heading-01" class="slds-modal__title slds-hyphenate">Create contact with custom lookup</h1>
</div>
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<lightning-card title={cardTitle}>
<div class="slds-m-around_medium">
<lightning-record-edit-form object-api-name="Contact">
<lightning-input-field field-name="LastName">
</lightning-input-field>
<lightning-input-field field-name="AccountId" value={recordId}>
</lightning-input-field>
<lightning-button
label="Save" onclick={handleClick}>
</lightning-button>
</lightning-record-edit-form>
</div>
</lightning-card>
</div>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open" role="presentation"></div>
</lightning-card>
</template>
Js:
import { LightningElement, api, wire, track } from 'lwc';
import LNAME_FIELD from '@salesforce/schema/Contact.Name';
//import LNAME_FIELD from '@salesforce/schema/Contact.LastName';
import insertContact from '@salesforce/apex/ContactTableProjectSecond.addContact';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import getContacts from '@salesforce/apex/ContactTableProjectSecond.getContacts';
import {refreshApex} from "@salesforce/apex";
export default class LwcNewContactUsingApexImperativecalling extends LightningElement {
showModal = false;
LastName = LNAME_FIELD;
field={
LNAME:this.LastName,
}
@api recordId;
@wire(getContacts)
wiredCallback(result) {
this._wiredResult = result;
}
handlelnameChange(event) {
this.field.LNAME = event.target.value;
window.console.log("LNAME", this.field.LNAME);
}
handleClick(event) {
console.log("handleClick", event);
const contact = {
LastName: this.field.LNAME,
}
insertContact ({ con : contact })
.then(() => {
// this.rec={}; // Don't. You aren't clearing the value of rec properties, you're removing them. So everywhere you're using them you'll get an error because they will be now undefined properties.
this.field.LNAME = null;
this.dispatchEvent(
new ShowToastEvent({
title: 'Success',
message: 'Contact created',
variant: 'success',
}),
);
})
.catch((error) => {
this.dispatchEvent(
new ShowToastEvent({
title: 'Error creating record',
message: error.body.message,
variant: 'error',
}),
);
console.log('error', JSON.stringify(error));
});
}
@api show() {
this.showModal = true;
}
handleDialogClose() {
this.showModal = false;
}
// @track selectedAccountId;
// handleSelected(event){
// console.log(event.detail);
// this.selectedAccountId = event.detail;
// }
}
Apex:
public with sharing class ContactTableProjectSecond {
@AuraEnabled(cacheable=true)
public static List<Contact> getContacts() {
return [
SELECT Id, FirstName, LastName, Phone, Email, Account.Name, AccountId, CreatedDate
FROM Contact
];
}
@AuraEnabled(cacheable=true)
public static List<Contact> searchContacts(String searchKey) {
String searchKeyword = '%' + searchKey + '%';
List<Contact> contacts = [
SELECT Id, FirstName, LastName, Phone, Email, Account.Name, AccountId, CreatedDate
FROM Contact
WHERE Name LIKE :searchKeyword
];
return contacts;
}
@AuraEnabled
public static void deleteContact(Id recordId) {
List<Contact> contact = [SELECT Id FROM Contact WHERE Id = :recordId];
delete contact;
}
@AuraEnabled
public static Contact addContact(Contact con) {
//Contact contact = new Contact();
system.debug('con'+con);
insert con;
return con;
}
@AuraEnabled(cacheable=true)
public static List<account> getCustomLookupAccount(String actName) {
List<account> accountLookupList = new List<account>();
System.debug('accountLookupList' + accountLookupList);
if (actName != '') {
String accountName = '%' + actName + '%';
accountLookupList = [SELECT Id, Name FROM Account WHERE Name like:accountName];
return accountLookupList;
}
return accountLookupList;
}
}
- Mike Tol 1
- April 18, 2022
- Like
- 0
- Continue reading or reply
Edit And Delete Button is not showing on Public Group Page
Today, I stuck in an issue. Actually I have a user xyz on that user's public group Edit or Delete button is not showing. I want to add some more user in that group but edit button is not showing.
Could anyone help me that which permission I am missing.
Thanks In Advance
- Govind Bangalore
- December 10, 2021
- Like
- 0
- Continue reading or reply
visualforce page error Unknown property 'mensajeController.mensajeContenido'
Unknown property 'mensajeController.mensajeContenido'
this the vf page
<apex:page controller="mensajeController" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="test"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!contacts}" var="c" >
<apex:column >
<apex:inputCheckbox value="{!c.selected}"/>
</apex:column>
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.Email}" />
<apex:column value="{!c.con.Phone}" />
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock>
<p>Current description: {!mensajeContenido}</p>
<p>Change description to:</p>
<apex:inputTextarea id="newDesc" value="{!mensajeContenido}"/><p/>
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlock>
<apex:pageBlock id="test">
Total No of Selected Records :<apex:outputText value="{!value }"/>
<apex:pageBlockTable value="{!SelectedContacts}" var="c" >
<apex:column value="{!c.Name}" />
<apex:column value="{!c.Email}" />
<apex:column value="{!c.Phone}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
this is the controller
public class mensajeController {
public List<cContact> contactList {get; set;}
public List<Contact> selectedContacts{get;set;}
public Integer value {get;set;}
public List<cContact> getContacts() {
if(contactList == null) {
contactList = new List<cContact>();
for(Contact c : [select Id, Name, Email, Phone from Contact]) {
contactList.add(new cContact(c));
}
}
return contactList;
}
public PageReference processSelected() {
selectedContacts = new List<Contact>();
for(cContact cCon : getContacts()) {
if(cCon.selected == true) {
selectedContacts.add(cCon.con);
}
}
value = selectedContacts.size();
System.debug('printingtcontc'+selectedContacts.size());
return null;
}
public List<Contact> getSelectedContacts(){
System.debug('printingtcontc inside get'+selectedContacts.size());
if(selectedContacts.size()>0)
return selectedContacts;
else return null;
}
public class cContact {
public Contact con {get; set;}
public Boolean selected {get; set;}
public cContact(Contact c) {
con = c;
selected = false;
}
}
public class messageDescription {
public string mensajeContenido {get; set;}
}
}
- Rafael Franco Moreno 24
- December 06, 2021
- Like
- 0
- Continue reading or reply
How to get records from lightning flow to Lwc
I have a requirement. I want to fetch records from flow to lwc. we can do it by using apex but my manager was saying we can't use apex. we have to achieve it by flow.
Is there any way which we can achieve it?
You can refer any link or example.
Thanks In Advance
- Govind Bangalore
- November 21, 2021
- Like
- 0
- Continue reading or reply
Need Salesforce Certificate Voucher/Coupon
I am planning for platform developer(PD) 1 certificate exam and I need Voucher/Coupon. I have a request if any body have a voucher then can you please provide me.
Thanks in advance
Ravi Soni
- ravi soni
- August 30, 2023
- Like
- 0
- Continue reading or reply
INSUFFICIENT_ACCESS: use of the Metadata API requires a user with the ModifyAllData or ModifyMetadata permissions
Hi Connections,
I am getting below error while retrieve data from vs code. can somebody please help me out to resolve this issue. I got this error first time.
here is error
INSUFFICIENT_ACCESS: use of the Metadata API requires a user with the ModifyAllData or ModifyMetadata permissions.
Thanks in advance
- Mohit Sharma 397
- January 31, 2023
- Like
- 0
- Continue reading or reply
How to Get Records From Flow + Lwc
is there any way for fetching data/records from lightning flow and show in custom table in lwc?
I tried but didn't succeed.can you please give me any example or guide that how can we achieve this?
I believe you guys help me.
Thanks in advance
- Mohit Sharma 397
- January 23, 2023
- Like
- 0
- Continue reading or reply
custom datatable with Inline Editing In Lwc
I have one requirment I want a custom datatable with inline editing in lwc.
can you please provide me any reference.
Thanks in advance
- test vijay
- January 23, 2023
- Like
- 0
- Continue reading or reply
Refresh LWC when related list is updated
In LWC, there is a way to automatically update the content in it when the record is updated without having to refresh the page. This is possible if we use getRecordNotifyChange.
My question is how do we detect a change in the related list in a custom LWC? For example, when I delete a file from the Files related list, I see the spinner appear on each of the standard related lists meaning that they are getting automatically refreshed when I delete the related file. So, how do I get a custom LWC also to refresh itself when a related record or atleast a related file is deleted?
- Nikhil Shah 14
- October 07, 2022
- Like
- 0
- Continue reading or reply
Trying to test PageRedirect
public PageReference redirect(){
String somekey = [SELECT Key__c FROM Some_metadata__mdt WHERE Organization_Id__c = :runningOrg.Id].Destination_Key__c;
String URL='https://myurl.com/' + someKey + '?accId='+Account_Id__c.Id+'&sourceId='Source_Record_Id__c.Source+'&svcType='+Service_Type__c.Service+'&rsrcId='+Event_Id__c;
PageReference getFeedback=new PageReference(URL);
getFeedback.setRedirect(true);
return getFeedback;
I have written the test code as such:
@istest
static void TestPageRedirect(){
String somekey = 'UsFZNSFf';
String URL='https://myurl.com/' + surveyKey + '?accId=123456789&sourceId=123456789&svcType=My Service Type&rsrcId=My Event ID';
PageReference getFeedback=new PageReference(URL);
Test.setCurrentPage(getFeedback);
The test executes without problems but none of the code in the Apex class is shown as covered.
What am I doing wrong?
- Jonathan Crow 10
- October 06, 2022
- Like
- 0
- Continue reading or reply
Apex Test Class - When I don't use @istest(SeeAllData=true) I don't get any results back
Is there a way around this?
- Jonathan Crow 10
- October 06, 2022
- Like
- 0
- Continue reading or reply
Line: 22, Column: 1 System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [First_Name__c, Last_Name__c]: [First_Name__c, Last_Name__c]
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [First_Name__c, Last_Name__c]: [First_Name__c, Last_Name__c]
- Pronati Debnath
- September 19, 2022
- Like
- 0
- Continue reading or reply
Create dynamic multipicklist dropdown through LWC. So that You do not hard code the values.
Hi All
I have tried to create multiselect picklist dropdown through LWC but here values are hardcoded. You can see my Code Below:
Demo.html
<template>
<!-- picklistlabel sets the label to multi select combobox -->
<c-mutli-select-picklist picklistlabel="Industry" values={values} ></c-mutli-select-picklist>
</template>
demo.js
import { LightningElement, track, api } from 'lwc';
export default class Demo extends LightningElement {
//This array can be anything as per values
values = [{label : 'Agriculture', value : 'Agriculture', selected : false},
{label : 'Banking', value : 'Banking', selected : false},
{label : 'Chemicals', value : 'Chemicals'},
{label : 'Education', value : 'Education'},
{label : 'Finance', value : 'Finance'}];
//To get the picklist values in container component
fetchSelectedValues(){
let selections = this.template.querySelector('c-mutli-select-picklist');
console.log(selections.values);
}
}
Demo.js meta
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>52.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
Requirement:
Object: Account and Field: Industry
I want that through apex class all the picklist value of industry would be visible in dropdown instead of hardcoded value.
Can anybody help me to make it dynamic.
Thanks in Advance
- Cooper 13
- September 19, 2022
- Like
- 0
- Continue reading or reply
Change Lightning-Button Color & Size- LWC
I'm new to LWC.
How do I change the button color and size of a lightning-button? It's taking the default from "Variant".
Alternatively, can I use anything else (like icon)?
Any help in this regard is really appreciated.
- SambitNayak
- September 17, 2022
- Like
- 0
- Continue reading or reply
My requirement is to hide & show text field based on picklist values selected on lead object can anyone suggest the best way
- Babar Hussain 4
- July 15, 2022
- Like
- 0
- Continue reading or reply
Code coverage on Event controller test class
Here is my custom controller:
public class ContactTasks{ public Event event; public ContactTasks() { event = [SELECT FIELDS(STANDARD) FROM Event WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; } public Event getEvent(){ return event; } List <Task> relatedTasks; public List<Task> getrelatedTasks(){ relatedTasks = [SELECT FIELDS(STANDARD) FROM Task WHERE WhoId= :this.event.WhoId ORDER BY ActivityDate DESC]; return relatedTasks; } }Here is my test class:
@isTest private class ContactTasks_Test{ @testSetup static void setupTestData(){ test.startTest(); Contact contact_Obj = new Contact(LastName='Test'); Insert contact_Obj; Event eventobj = new Event(WhoId = contact_Obj.id, DurationInMinutes = 10, ActivityDateTime = Datetime.now()); Insert eventobj; Task task_Obj = new Task(WhoId = contact_Obj.id, ActivityDate = Date.today(), Status = 'Not Started', Priority = 'High', Description = '12', IsReminderSet = false, IsRecurrence = false, Placeholder_for_next_call_set__c = false, BD_Meeting_scheduled_by_InMail__c = false, Duplicate_Meeting__c = false, Automatic_Reply__c = false, Candidate_InMail__c = false, Bounced__c = false); Insert task_Obj; test.stopTest(); } static testMethod void test_getEvent_UseCase1(){ List<Task> task_Obj = [SELECT Id,WhoId,WhatId,WhoCount,WhatCount,Subject,ActivityDate,Status,Priority,Description,IsRecurrence,Placeholder_for_next_call_set__c from Task]; System.assertEquals(true,task_Obj.size()>0); PageReference pageRef = Page.ContactsTasks; pageRef.getParameters().put('id','test'); Test.setCurrentPage(pageRef); Contact contact_Obj = new Contact(LastName='Test'); Insert contact_Obj; Event eventobj = new Event(WhoId = contact_Obj.id, DurationInMinutes = 10, ActivityDateTime = Datetime.now()); Insert eventobj; } static testMethod void test_getEvent_UseCase3(){ List<Task> task_Obj = [SELECT Id,WhoId,WhatId,WhoCount,WhatCount,Subject,ActivityDate,Status,Priority,Description,IsRecurrence,Placeholder_for_next_call_set__c from Task]; System.assertEquals(true,task_Obj.size()>0); PageReference pageRef = Page.ContactsTasks; pageRef.getParameters().put('id','test'); Test.setCurrentPage(pageRef); task_Obj[0].ActivityDate = date.parse('7/13/2022'); task_Obj[0].Status='Not Started'; task_Obj[0].Priority='High'; task_Obj[0].Description = '0'; } static testMethod void test_getrelatedTasks_UseCase1(){ List<Task> task_Obj = [SELECT Id,WhoId,WhatId,WhoCount,WhatCount,Subject,ActivityDate,Status,Priority,Description,IsRecurrence,Placeholder_for_next_call_set__c from Task]; System.assertEquals(true,task_Obj.size()>0); PageReference pageRef = Page.ContactsTasks; pageRef.getParameters().put('id','test'); Test.setCurrentPage(pageRef); } static testMethod void test_getrelatedTasks_UseCase2(){ List<Task> task_Obj = [SELECT Id,WhoId,WhatId,WhoCount,WhatCount,Subject,ActivityDate,Status,Priority,Description,IsRecurrence,Placeholder_for_next_call_set__c from Task]; System.assertEquals(true,task_Obj.size()>0); PageReference pageRef = Page.ContactsTasks; pageRef.getParameters().put('id','test'); Test.setCurrentPage(pageRef); task_Obj[0].ActivityDate = date.parse('7/13/2022'); task_Obj[0].Status='Not Started'; task_Obj[0].Priority='High'; task_Obj[0].Description = '0'; } }
- RichardR1
- July 14, 2022
- Like
- 0
- Continue reading or reply
After update ,delete,inserting contact record update account email field(custom) with contacts email with comma seperated values
- Abhishek AS 3
- July 14, 2022
- Like
- 0
- Continue reading or reply
unable to fetch records from case
my query is -
Select id, Status, Account.Name from Case where Contact IN ('Forbes, Sean', 'Pavlova, Stella')
can anyone plz suggest if any mistake
- Abhishek Sharma 527
- July 13, 2022
- Like
- 0
- Continue reading or reply
batch process with try-catch block
//this is my code
global class BatchDemo_Lead implements Database.Batchable<sObject>{
try{
global Database.QueryLocator start(Database.BatchableContext bc){
return Database.getQueryLocator([Select id from Lead]);
}
}
global void execute(Database.BatchableContext bc, List<Lead> scope){
for(Lead l : scope)
{
if(l.State == 'VA'){
l.State = 'NJ';
}
}
update scope;
}
global void finish(Database.BatchableContext bc){
system.debug('Batch process finished.');
}
catch(Exception e){
return Database.getQueryLocator(Select id, State from Lead);
System.debug('DML operation executed from catch block');
}
}
- Abhishek Sharma 527
- July 13, 2022
- Like
- 0
- Continue reading or reply
We hit a snag: I can't find the validation that is being trigger
I am getting 'Review the errors on this page.
You must select a sales campaign to perform a status change.' error that seems like a validation rule but when I make a QUERY in Validation Rule I don't find any with this error message.
Can this be created in any other way? Is there any way to debug it or find where this is coming through?
I made a Debug Log with Finest and Info in Validation but I don't see anything there either.
Thank you!
- Sabrina Viscardi
- July 13, 2022
- Like
- 0
- Continue reading or reply
Custom Path for dependent picklist
I have created Field dependencies, Status picklist field is controlling and sub status picklist field is dependent. I have a requirement of showing path of both Status and Sub status picklist fields on the record page. I did that by Aura component but dependent picklist(sub status) is showing all the values on the path.
On path dependent picklist(sub status) should only show the values related to what user selects in controlling field (Status) means dependent picklist path should change and only show values on behalf of what we select in the controlling field.
Here is what I implemented: -
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" > <aura:attribute name="variant" type="String" default="non-linear"/> <aura:attribute name="hideUpdateButton" type="Boolean" default="true"/> <lightning:picklistPath aura:id="picklistPath" recordId="{!v.recordId}" variant="non-linear" picklistFieldApiName="Sub_Finance__c" onselect="{!c.handleSelect}"> </lightning:picklistPath> </aura:component>
({ handleSelect : function (component, event, helper) { var stepName = event.getParam("detail").value; var toastEvent = $A.get("e.force:showToast"); toastEvent.setParams({ "title": "Success!", "message": "Toast from " + stepName }); toastEvent.fire(); } })
Does anyone knows solution for this requirement?
- Priya Sharma 57
- February 12, 2021
- Like
- 1
- Continue reading or reply
Event being handled even when tab is not open
I am trying to listen for a save success on the e.force:editRecord and after much searching I found no solution as apparently there is no standard callback for the editRecord
https://trailblazer.salesforce.com/ideaView?id=0873A000000CQQiQAO
As per a few other suggestions I have added an handler for the force:showToast
This is working, albeit a hack, but the problem is as this is an application event it is constantly being listened for even if the custom tab isn't open.
Does anyone have any ideas how I can remedy this
<aura:handler event="force:showToast" action="{!c.handleToastEvent}"/> handleToastEvent: function(component, event, helper){ var toastMessageParams = event.getParams(); var message = toastMessageParams.message; if(message.includes('Resource Placeholder') && message.includes('was saved')){ var calendar = component.get('v._Calendar'); var calendarEvent = event.getParam("calendarEvent") helper.fetchCalendarEvents(component, calendar, calendarEvent); } }
Many thanks,
- louisa barrett 7
- August 10, 2020
- Like
- 1
- Continue reading or reply
how to get file preview on Lightning Component?
I have lightning components that displays images from ContentVersion as thumbnails and also links, when I click on the image its directly downloading the image but I would like it to open as preivew or open the image in a new tab/window. please advice.
below is the current line that displays image thumbnails with link to open big
<aura:iteration items="{!v.items}" var="content"> <a href="/sfc/servlet.shepherd/version/download/'+{!content.id}" target="_blank"> <img src="/sfc/servlet.shepherd/version/download/'+{!content.id}" width="100" height="100"/> </a> </aura:iteration>
- Sumant Kuchipudi
- December 05, 2018
- Like
- 1
- Continue reading or reply
Data binding of lightning:input and aura:attribute with type sObject(field) is not working
<aura:attribute name="student" type="JN_Student__c" access="global" default="{'sobjectType' : 'JN_Student__c'}" /> <lightning:input aura:id="requiredVal" name="lastName" label="Legal Last Name"value="{!v.student.JN_Last_Name__c}" maxlength="20" required="true"/>
above works perfectly and the data persists as I show/hide this section. WHEREAS for,
<aura:attribute name="insuranceInstance" type="JN_Insurance__c" access="global" default="{'sobjectType' : 'JN_Insurance__c'}" /> <lightning:input aura:id="requiredVal" name="lastName" label="Legal Last Name" value="{!v.insuranceInstance.Name}" maxlength="20" required="true"/>
the 'v.insuranceInstance.Name' doesn't persists its value.
Please reply if anyone knows/encounted the same.
- Himanshu Joshi 34
- April 15, 2018
- Like
- 1
- Continue reading or reply