You need to sign in to do that
Don't have an account?

Account list is not coming on using lightning-datatable!
Hi Everyone!
I want a list of account using Lightning-datatable. But it is not displaying the list of accounts.
HTML:
<template>
<lightning-card title="t">
<template if:true={accList}>
<lightning-datatable
key-field="Id"
data={data}
columns={columns}>
</lightning-datatable>
</template>
<template if:true={error}>
{error}
</template>
</lightning-card>
</template>
JS:
import { LightningElement ,api, wire, track} from 'lwc';
import getAccountList from '@salesforce/apex/AccountHelper.getAccountList';
export default class Test extends LightningElement {
@track columns = [{
label: 'Account name',
fieldName: 'Name',
type: 'text',
sortable: true
},
{
label: 'Type',
fieldName: 'Type',
type: 'text',
sortable: true
},
];
@track error;
@track accList ;
@wire(getAccountList)
wiredAccounts({
error,
data
}) {
if (data) {
this.accList = data;
alert(JSON.stringify(accList));
alert(JSON.stringify(data));
} else if (error) {
this.error = error;
}
}
}
Apex Class:
public with sharing class AccountHelper {
@AuraEnabled(cacheable=true)
public static List<Account> getAccountList() {
return [SELECT Id, Name, Type, Rating,
Phone, Website, AnnualRevenue
FROM Account LIMIT 10];
}
}
xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>50.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
Output:
I want the list of accounts.
Thank you in Advance!

How a pop up will appear after clicking of a drop down menu.
Hi,
I have created a drop down menu in lightning web component. But, I want a pop up will appear on click of a menu item.
I tried this for pop up, But it is not working. On click of a "Rename " Menu item . A pop up will be shown.
button.html
<template>
<div class="slds-p-around_medium lgc-bg">
{selectedItemValue}
{ready}
<lightning-card title="Drop Down">
<lightning-button-menu alternative-text="Show menu" variant="border-filled" onselect={handleOnselect}>
{selectedItemValue}
<lightning-menu-item value="openinsharepoint" label="Open in SharePoint" prefix-icon-name="utility:new_window"
href="#"
target="_blank">
</lightning-menu-item>
<lightning-menu-item value="rename" label="Rename" prefix-icon-name="utility:edit">
<template if:true={ready}>
<section role="dialog" tabindex="-1" class="slds-modal slds-fade-in-open slds-modal_small"
aria-labelledby="modal-heading-01" aria-modal="true" aria-hidden="true"
aria-describedby="modal-content-id-1">
<div class="slds-modal__container">
<!-- Modal/Popup Box LWC header here -->
<header class="slds-modal__header">
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeModal}>
<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">Rename LWC Setup.docx</h2>
</header>
<!-- Modal/Popup Box LWC body starts here -->
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<lightning-input type="text" name="folder_name" label="Rename" placeholder="Enter new item name">
</lightning-input>
</div>
<!-- Modal/Popup Box LWC footer starts here -->
<footer class="slds-modal__footer">
<button class="slds-button slds-button_neutral" onclick={closeModal} title="Cancel">Cancel</button>
<button class="slds-button slds-button_brand" onclick={submitDetails} title="Create">Create</button>
</footer>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</template>
</lightning-menu-item>
<lightning-menu-item value="download" label="Download" prefix-icon-name="utility:download">
</lightning-menu-item>
<div class="slds-has-divider_top-space" role="separator">
<lightning-menu-item value="delete" label="Delet" prefix-icon-name="utility:close"></lightning-menu-item>
</div>
</lightning-button-menu>
</lightning-card>
</div>
</template>
button.js
import { LightningElement, track } from 'lwc';
export default class ButtonMenuOnselect extends LightningElement {
@track selectedItemValue;
@track ready;
handleOnselect(event) {
this.selectedItemValue = event.detail.value;
if(this.selectedItemValue == "rename")
{
alert("ready");
this.ready = true;
alert("false");
}
}
}


Just Copy Paste The following code
<template> <div class="slds-p-around_medium lgc-bg"> {selectedItemValue} {ready} <lightning-card title="Drop Down"> <lightning-button-menu alternative-text="Show menu" variant="border-filled" onselect={handleOnselect} > {selectedItemValue} <lightning-menu-item value="openinsharepoint" label="Open in SharePoint" prefix-icon-name="utility:new_window" href="#" target="_blank" > </lightning-menu-item> <lightning-menu-item value="rename" label="Rename" prefix-icon-name="utility:edit" > </lightning-menu-item> <lightning-menu-item value="download" label="Download" prefix-icon-name="utility:download" > </lightning-menu-item> <div class="slds-has-divider_top-space" role="separator"> <lightning-menu-item value="delete" label="Delet" prefix-icon-name="utility:close" ></lightning-menu-item> </div> </lightning-button-menu> <template if:true={ready}> <div class="slds-box slds-theme_shade"> <div class="slds-modal slds-fade-in-open slds-backdrop"> <div class="slds-modal__container"> <!--HEADER Section--> <div class="slds-modal__header"> <lightning-button-icon icon-name="utility:close" alternative-text="Close this window" size="large" variant="bare-inverse" onclick={closeModal} class="slds-modal__close" > </lightning-button-icon> <h2>Rename LWC Setup.docx</h2> </div> <!---Body Section--> <div class="slds-modal__content slds-p-around_medium"> <lightning-input type="text" name="folder_name" label="Rename" placeholder="Enter new item name" > </lightning-input> </div> <!--Footer Section--> <div class="slds-modal__footer"> <button class="slds-button slds-button_neutral" onclick={closeModal} title="Cancel" > Cancel </button> <button class="slds-button slds-button_brand" onclick={submitDetails} title="Create" > Create </button> </div> </div> </div> </div> </template> </lightning-card> </div> </template> --------------------------------------------------------------------------------------------------- js @track selectedItemValue; ready = true; handleOnselect(event) { this.selectedItemValue = event.detail.value; alert(this.selectedItemValue); if(this.selectedItemValue == 'rename') { this.ready = true; } } closeModal(){ this.ready = false; }
Please Mark It As Best Answer If it Helps Thank you

How can I get the name of the current app in the Apex Controller?
public static String getAppName() { UserAppInfo userAppInfo = [SELECT Id, AppDefinitionId FROM UserAppInfo WHERE UserId = :UserInfo.getUserId() LIMIT 1]; AppDefinition appDefinition = [SELECT DurableId, Label FROM AppDefinition Where DurableId = :userAppInfo.AppDefinitionId LIMIT 1]; return appDefinition.Label; }But Im getting 3 errors:
Line 1: No such column 'AppDefinitionId' on entity 'UserAppInfo'
Line 2: Invalid type: AppDefinition
Line 3: Variable does not exist: appDefinition
Can anyone provide some insight as to what I may be doing wrong? Thanks!



Greetings to you!
Your code looks good to me. Make sure you are using API version 43.0 or later. As per the Salesforce doc, AppDefinitionId field on UserAppInfo object and AppDefinition object are available in API version 43.0 and later.
Please refer to the below links which might help you further.
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_userappinfo.htm
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_appdefinition.htm
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas

Add visualforce page on record Edit page?
So is it possible to add visualforce page on record Edit page now?

No, VF page cannot be added to Record Edit Page. If you really need dynamic functionality, you can always create a VF page for editing the records and add the fields you want to edit. THough this would be less flexible as page layout changes would mean updating the VF Page everytime.
Assert Fails on Trigger Test Class
Here is the Test Class
@isTest private class AtualizaStatusDoChamadoTest { private static testmethod void testaTrigger(){ Case novoCaso = new Case(); novoCaso.Nome__c = 'Teste'; novoCaso.Status = 'Em aberto'; novoCaso.Email__c = 'teste@teste.com'; insert novoCaso; Comentario_caso__c novoComentario = new Comentario_caso__c(); novoComentario.Caso__c = novoCaso.Id; novoComentario.Tipo_de_Comentario__c = 'Encerramento'; insert novoComentario; Case caso = [SELECT Id, Status FROM Case WHERE Id =: novoComentario.Caso__c]; Test.startTest(); System.assertEquals('Encerrado', caso.Status); Test.stopTest(); } }
Here is the Trigger
trigger AtualizaStatusDoChamado on Comentario_Caso__c (before insert, before update) { if(Trigger.isBefore){ if(Trigger.isInsert || Trigger.isUpdate){ List<Comentario_Caso__c> listaDeComentarios = trigger.new; Comentario_Caso__c novoComentario = listaDeComentarios[0]; Case casoDoComentario = [SELECT Id, Status FROM Case WHERE Id =: novoComentario.Caso__c]; if(novoComentario.Tipo_de_Comentario__c == 'Encerramento'){ casoDoComentario.Status = 'Encerrado'; } System.debug('caso: ' + casoDoComentario); } } }
Log
11:52:42:863 EXCEPTION_THROWN [19]|System.AssertException: Assertion Failed: Expected: Encerrado, Actual: Em aberto
On the Trigger, the debug is showing the correct Status, maybe I'm doing something wrong when trying to get the updated Case on Test Class.

As I am seeing your trigger here you are not updating the case record after updating the status of the case. In the test, you are querying the case after inserting the Comentario_Caso__c Record. So you need to update the case record after changing the status. After this, your assert will not fail.
I hope you find the above solution helpful. If it does, please mark it as Best Answer to help others too.
Thanks and Regards,
Sachin Arora
www.sachinsf.com

Error: Unknown property 'core.email.template.EmailTemplateComponentController.Opportunity'
This is my first attempt at tweaking an APEX. It is a e-mail template for Invoice which is generated from "Send E-mail" within Opportunity. I am getting: " Error: Unknown property 'core.email.template.EmailTemplateComponentController.Opportunity' " when I am trying to save. What am I missing here?
<messaging:emailTemplate subject="Your invoice" recipientType="Contact" relatedToType="Opportunity"> <messaging:htmlEmailBody > <table border="0" cellspacing="0" cellpadding="10" width="700" id="table1" align="center"> <tr> <td width="230"> <img src='{!URLFOR($Resource.PixLogo70pix)}' title=" Logo" /> </td> <td align="right"><font face="Arial" size="2" color="#666666"> One Broadway<br /> </font> </td> </tr> </table> <center> <p style="font-family:Arial;font-size:22px;font-weight:bold;color:#666666;">INVOICE</p> </center> <br/> <table border="0" cellspacing="0" cellpadding="5" width="800" id="table1" align="center"> <tr> <td valign="top"> <font face="Arial" size="2" color="#666666"> Bill To:</font><br /> <font face="Arial" size="2"> {!Opportunity.Account.Name}<br/> {!Opportunity.Account.BillingStreet}<br/> {!Opportunity.Account.BillingCity}, {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}<br/> {!Opportunity.Account.BillingCountry}<br/> </font> </td> <td> </td> <td valign="top"> <font face="Arial" size="2"> <font color="#666666">Account Name:</font> <br/> {!Opportunity.Account.Name}<br/> <font color="#666666">Invoice Number:</font> <br/> {!Opportunity.Project_number__c}<br/> <font color="#666666">Invoice Date:</font> <br/> {!Opportunity.CloseDate}<br /> <font color="#666666">Payment Terms:</font> <br/> <font color="#FF3300">Due Upon Receipt</font></font></td> </tr> </table> <br/> <table width="800" border="0" align="center" cellpadding="3" cellspacing="1" id="table4"> <tr bgcolor="#E5E5E5"><font face="Arial" size="2" color="#666666"> <td>Product</td> <td>Description</td> <td>Quantity</td> <td>Unit Price</td> <td>Total Price</td> </font> </tr> <tr><font face="Arial" size="2" color="#000000"> <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line"> <tr> <td>{!line.PricebookEntry.Name}</td> <td>{!line.Description}</td> <td>{!line.Quantity}</td> <td><apex:OutputField value="{!line.UnitPrice}"/></td> <td><apex:OutputField value="{!line.TotalPrice}"/></td> </tr> </apex:repeat> </font> </tr> <tr> <td bgcolor="#FFFFFF" align="right" colspan="5"> <font face="Arial" size="2">Sub-total: <apex:OutputField value="{!Opportunity.Sub_Total__c}"/></font></td> </tr> <tr> <td bgcolor="#FFFFFF" align="right" colspan="5"> <font face="Arial" size="2">Discounts: <apex:OutputField value="{!Opportunity.Discount_amount__c}"/></font></td> </tr> <tr> <td bgcolor="#FFFFFF" align="right" colspan="5"> <font face="Arial">Tax: <apex:OutputField value="{!Opportunity.Sales_Tax__c}"/></font></td> </tr> <tr> <td bgcolor="#E5E5E5" align="right" colspan="5"> <font face="Arial"><b>Total:</b> <apex:OutputField value="{!Opportunity.Amount}"/></font></td> </tr> </table> <br/> <p align="center"><font face="Arial">Thank you very much for you business!<br /> {!Opportunity.CreatedBy.FirstName} {!Opportunity.CreatedBy.LastName} </font></p> </messaging:htmlEmailBody> <messaging:attachment renderAs="pdf" filename="{!relatedTo.name}"> <table border="0" cellspacing="0" cellpadding="10" width="700" id="table1" align="center"> <tr> <td width="230"> <img src='{!URLFOR($Resource.PixLogo70pix)}' title="Pixability Logo" /> </td> <td align="right"><font face="Arial" size="2" color="#666666"> One Broadway<br /> </font> </td> </tr> </table> <center> <p style="font-family:Arial;font-size:22px;font-weight:bold;color:#666666;">INVOICE</p> </center> <br/> <table border="0" cellspacing="0" cellpadding="5" width="800" id="table1" align="center"> <tr> <td valign="top"> <font face="Arial" size="2" color="#666666"> Bill To:</font><br /> <font face="Arial" size="2"> {!Opportunity.Account.Name}<br/> {!Opportunity.Account.BillingStreet}<br/> {!Opportunity.Account.BillingCity}, {!Opportunity.Account.BillingState} {!Opportunity.Account.BillingPostalCode}<br/> {!Opportunity.Account.BillingCountry}<br/> </font> </td> <td> </td> <td valign="top"> <font face="Arial" size="2"> <font color="#666666">Account Name:</font> <br/> {!Opportunity.Account.Name}<br/> <font color="#666666">Invoice Number:</font> <br/> {!Opportunity.Project_number__c}<br/> <font color="#666666">Invoice Date:</font> <br/> {!Opportunity.CloseDate}<br /> <font color="#666666">Payment Terms:</font> <br/> <font color="#FF3300">Due Upon Receipt</font></font></td> </tr> </table> <br/> <table width="800" border="0" align="center" cellpadding="3" cellspacing="1" id="table4"> <tr bgcolor="#E5E5E5"><font face="Arial" size="2" color="#666666"> <td>Product</td> <td>Description</td> <td>Quantity</td> <td>Unit Price</td> <td>Total Price</td> </font> </tr> <tr><font face="Arial" size="2" color="#000000"> <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line"> <tr> <td>{!line.PricebookEntry.Name}</td> <td>{!line.Description}</td> <td>{!line.Quantity}</td> <td><apex:OutputField value="{!line.UnitPrice}"/></td> <td><apex:OutputField value="{!line.TotalPrice}"/></td> </tr> </apex:repeat> </font> </tr> <tr> <td bgcolor="#FFFFFF" align="right" colspan="5"> <font face="Arial" size="2">Sub-total: <apex:OutputField value="{!Opportunity.Sub_Total__c}"/></font></td> </tr> <tr> <td bgcolor="#FFFFFF" align="right" colspan="5"> <font face="Arial" size="2">Discounts: <apex:OutputField value="{!Opportunity.Discount_amount__c}"/></font></td> </tr> <tr> <td bgcolor="#FFFFFF" align="right" colspan="5"> <font face="Arial">Tax: <apex:OutputField value="{!Opportunity.Sales_Tax__c}"/></font></td> </tr> <tr> <td bgcolor="#E5E5E5" align="right" colspan="5"> <font face="Arial"><b>Total:</b> <apex:OutputField value="{!Opportunity.Amount}"/></font></td> </tr> </table> <br/> <p align="center"><font face="Arial">Thank you very much for you business!<br /> {!Opportunity.CreatedBy.FirstName} {!Opportunity.CreatedBy.LastName} </font></p> </messaging:attachment> </messaging:emailTemplate>



You correctly bound the 'relatedtotype' at the top of your template....but inside the template try replacing "Opportunity" in the email body with {!relatedTo}. Templates use this generic placeholder for whatever Sobject type you choose to associate with them
{!Opportunity.Account.Name} -> {!relatedTo.Account.Name}
{!Opportunity.OpportunityLineItems} -> {!relatedTo.OpportunityLineItems}
etc...
check out the example from the docs, at the bottom it shows how to use 'relatedTo' (and also how child objects are referenced)

Need Help writing a validation rule

You have to write the validation rule like below:
AND( ISPICKVAL(Project_Status__c, "Active"), ISBLANK(TEXT(Foundation_Type__c)), OR( ISPICKVAL(ProjDept__c, "Custom"), ISPICKVAL(ProjDept__c, "Commercial"), ISPICKVAL(ProjDept__c, "Addition") ) )
Thanks,
Maharajan.C

Does queueing a future method count as DML?
Hi all,
We need to implement the following pattern at my org:
- callout to external data source
- if that callout takes too long (according to some configurable threshold), log an error (ie do some DML)
- if that callout timed out on the remote server, try it again
public static void foo() { Http http = new Http(); HttpRequest req = new Httprequest(); req.setEndpoint('https://test.salesforce.com'); //whatever endpoint req.setMethod('GET'); http.send(req); //works fine bar(); http.send(req); //throws calloutexception } @future public static void bar() { }Am I correct to assume that calling a future method counts as a DML operation? Is there any documentation I'm missing somewhere?



How to add Custom Objects to an App after creation of the objects?
Hi,
I am following the book "Developement with the Force.com platform" by JasonOuelette.
When creating the Custom Objects, I did not check the box to be visible in a tab, and so I could not add this object to the Custom App I was creating. Now I have a created fields and relationships in the custom object. How do I add this Object to the Custom App?
thanks
Svidya



It looks you havent create custom Tabs while defining custom objects first you need to create custom Tab for new objects Creating Tab Setup -->App Set up---> Create---> Tabs Click on new Tab [drop down shows all untabed objects ] select your object, set Tab style , click Next select profiles Save Adding To App Setup -->App Set up---> Create---> Apps Click on edit, edit available tab section Save Done Thanks, Bala
"Remove View Report Link" option on Dashboard Component
In Salesforce Lightning, do we have any option to remove/disable the Drilldown/View report hyper link on Dashboard?.
Thanks,
Naren



Sorry for this issue you are facing.
Unfortunately, this is not possible as of now. There is an idea which is active on the success community for which you can upvote so that it can be available in the mere future.
You can find the idea at the below link. Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra
Just Copy Paste The Following Code Please Mark It As Best Answer If it Helps
Thank you