@track data;   @track columns = [{                 label: 'Name',                 fieldName: 'Name',                 type: 'text',                 sortable: true             }]      @wire(getAccountlist)     accountList({data,error}){     if(data){    this.data= data;    for(var i=0;i&lt;data.length;i++){        this.columns.push({label : 'Info',                           ...this.data[i].Info__c&amp;&amp; {fieldName:'Info__c'},type: 'text',sortable: true})     }     } }   The column that I'm dynamically adding is not being added to the data table.
19484
Am not doing anything fancy, just trying to update a field on Contact in JS of LWC but getting this exception.  Uncaught TypeError: 'set' on proxy: trap returned falsish for property 'Name' throws at mydomain/auraFW/javascript/mhontaYdOya4Y_lBu7v9yg/aura_prod.js:2:27687  HTML Code:   &lt;template&gt;      &lt;template if:true={wiredContact}&gt;          {wiredContact.Name}          &lt;lightning-input value={wiredContact.Name} onchange={updateName}&gt;&lt;/lightning-input&gt;     &lt;/template&gt;  &lt;/template&gt;   JS:   import { LightningElement ,wire,track,api } from 'lwc'; import myContact from "@salesforce/apex/ContactController.fetchContact";  export default class Myrefreshapextest extends LightningElement {    @track wiredContact;   @wire (myContact)         fetchedContact({error, data}){             if(data){                 console.log(JSON.stringify(data));                 this.wiredContact = data;             }else if (error){                 console.log(error);             }     }      updateName (event){         console.log(JSON.stringify(event.detail.value));         console.log(JSON.stringify(this.wiredContact));         this.wiredContact.Name = event.detail.value;     }  }   Apex:  public class ContactController {      @AuraEnabled(cacheable=true)     public static Contact fetchContact(){         return [SELECT Id,Name FROM COntact LIMIT  1];     } }   On top of my head, am not doing anything wrong, anyone has idea what's wrong with my code?  When I print console.log(JSON.stringify(this.wiredContact)); I get old values so am pretty sure it exists.  I tried with @track and @api, but same response. Can anyone shed some light?
104755
I have a gridview and I need to sort its elements when the user clicks on the header. Its datasource is a List object.  The aspx is defined this way :  &lt;asp:GridView ID="grdHeader" AllowSorting="true" AllowPaging="false"      AutoGenerateColumns="false" Width="780" runat="server"  OnSorting="grdHeader_OnSorting" EnableViewState="true"&gt;     &lt;Columns&gt;         &lt;asp:BoundField DataField="Entitycode" HeaderText="Entity" SortExpression="Entitycode" /&gt;         &lt;asp:BoundField DataField="Statusname" HeaderText="Status" SortExpression="Statusname" /&gt;         &lt;asp:BoundField DataField="Username" HeaderText="User" SortExpression="Username" /&gt;     &lt;/Columns&gt; &lt;/asp:GridView&gt;   The code behind is defined this way : First load :  protected void btnSearch_Click(object sender, EventArgs e) {     List&lt;V_ReportPeriodStatusEntity&gt; items = GetPeriodStatusesForScreenSelection();     this.grdHeader.DataSource = items;     this.grdHeader.DataBind(); }   when the user clicks on headers :  protected void grdHeader_OnSorting(object sender, GridViewSortEventArgs e) {     List&lt;V_ReportPeriodStatusEntity&gt; items = GetPeriodStatusesForScreenSelection();     items.Sort(new Helpers.GenericComparer&lt;V_ReportPeriodStatusEntity&gt;(e.SortExpression, e.SortDirection));     grdHeader.DataSource = items;     grdHeader.DataBind(); }   My problem is that e.SortDirection is always set to Ascending. I have webpage with a similar code and it works well, e.SortDirection alternates between Ascending and Descending.  What did I do wrong ?
67234
Below is the code tried,  @wire(getObjectDetails)     wiredResult(data,error) {          if(data){             console.log('DateOfRun--&gt;',data);             this.lstRecs=data;             console.log('values len--&gt;',this.lstRecs);             console.log('values --&gt;',this.lstRecs.values);         } else if(error){             console.log('error --&gt;'+error);            }     }    I am getting data as [object Object],But would like to fetch the values of a record.  i tried below:   @wire(getObjectDetails)     wiredResult(data,error) {          if(data){             console.log('DateOfRun--&gt;',data);//[object object]             this.lstRecs=data;             console.log('values len--&gt;',JSON.stringify(data));//Getting json value             this.strtest=JSON.stringify(data);             console.log('data=='+this.strtest.data);//undefined          } else if(error){             console.log('error --&gt;'+error);            }     }
85206
I have this below code where i am trying to first search an account name and on hit button it displays the result set.  On the button click i am also loading an child component which is displaying the id of the record.  I need the child component should get displayed once i click on the record.  How can i achieve this -   Parent Component -   &lt;aura:component controller="SimpleAccountController"&gt;     &lt;aura:attribute name="account" type="account[]"/&gt;     &lt;ui:outputText aura:id="outName" value="" class="text"/&gt;     &lt;ui:inputText aura:id="name" label="Enter Name:" placeholder="Your Name" /&gt;     &lt;ui:button aura:id="button" buttonTitle="Click to see what you put into the field" class="button" label="Click me" press="{!c.getInput}"/&gt;     &lt;aura:iteration var="acc" items="{!v.account}"&gt;             &lt;a onclick="{!c.accountselected}" data-recId="{!acc.Id}"&gt;         &lt;p&gt;{!acc.Name} : {!acc.Type} : {!acc.Industry} : {!acc.Rating}&lt;/p&gt;             &lt;/a&gt;         &lt;c:HelloWorkdChildCmp selectedaccount="{!acc.Id}" /&gt;     &lt;/aura:iteration&gt; &lt;/aura:component&gt;   COntroller -   ({     getInput : function(cmp, evt) {         var myName = cmp.find("name").get("v.value");         var myText = cmp.find("outName");         var greet = "Hi, " + myName;         myText.set("v.value", greet);         var action = cmp.get("c.seaAcc");         action.setParams({ "s" : myName });         action.setCallback(this, function(response) {             var state = response.getState();             if (state === "SUCCESS") {                 cmp.set("v.account", response.getReturnValue());                 //alert("From server: " + response.getReturnValue());             }         });         $A.enqueueAction(action);     },      accountselected : function(cmp, evt) {        console.log(evt.currentTarget.getAttribute("data-recId")) ;     }  })   Child component -   &lt;aura:component &gt;     &lt;aura:attribute name="selectedaccount" type="String"/&gt;     &lt;div&gt;Id: {!v.selectedaccount}&lt;/div&gt; &lt;/aura:component&gt;
2705
The upsert() DML operation requires a specific List based on a specific sObject type, for instance:List&lt;Account&gt; lstAccount = new List&lt;Account&gt;();   However, we are trying to generate a generic method which allows us to pass by an sObject list containing all data records to be upserted for a specific sObject. An insert() operation allows us to use a List&lt;sObject&gt; to be inserted but the upsert() function is rejecting it:  List&lt;sObject&gt; listWRecords = new List&lt;sObject&gt;(); listWRecords.add(new Foo__c(Name="Record1")); listWRecords.add(new Foo__c(Name="Record2"));  upsert(listWRecords, 'ExternalIdFieldFrom_Foo__c', false);   Which will result in an error saying that the upsert must be performed on a concrete entity type.   Dynamically casting an sObject list is also not possible; I've seen solutions to 'hard code' or create Wrapper classes for each sObject on your org. But we would like to create a generic option here.  Another possibility would be to create some logic mimicking an upsert by splitting it into an update() and an insert() operation. Keeping in mind Salesforce limits, I do not see an option to go this way.
22754
I have some code that relies on field history tracking by querying the History for a custom object. This works fine, but it appears that the history records aren't created during the test so none of my tests will pass.
81320
I am trying to add key value pair in the below JSON object, but it is getting added in the wrong way, is there any way i can add to each object a new  key value pair, that will help me to complete the req. JSON as follow : var object =[       {          &quot;asdf&quot;:&quot;&quot;,          &quot;fdrtf&quot;:&quot;869966&quot;,          &quot;hdhfhfh&quot;:&quot;utytut&quot;,          &quot;Cat&quot;:&quot;A&quot;                 },       {          &quot;hjhj&quot;:&quot;&quot;,          &quot;hfhfhf&quot;:&quot;h&quot;,          &quot;hhfh&quot;:&quot;hfjfhdj&quot;,          &quot;cat&quot;:&quot;B&quot;                 },       {          &quot;hjhj&quot;:&quot;&quot;,          &quot;hfhfhf&quot;:&quot;h&quot;,          &quot;hhfh&quot;:&quot;hfjfhdj&quot;,          &quot;cat&quot;:&quot;B&quot;       } ]  code i am using to add the new key value pair : for (let i = 0; i &lt; object.length; i++) {             object[i]['ABC'] = [i];         }  Actually expected should be: var object =[       {          &quot;asdf&quot;:&quot;&quot;,          &quot;fdrtf&quot;:&quot;869966&quot;,          &quot;hdhfhfh&quot;:&quot;utytut&quot;,          &quot;Cat&quot;:&quot;A&quot;,          &quot;ABC&quot;: &quot;0&quot;                 },       {          &quot;hjhj&quot;:&quot;&quot;,          &quot;hfhfhf&quot;:&quot;h&quot;,          &quot;hhfh&quot;:&quot;hfjfhdj&quot;,          &quot;cat&quot;:&quot;B&quot;,          &quot;ABC&quot;: &quot;1&quot;                 },       {          &quot;hjhj&quot;:&quot;&quot;,          &quot;hfhfhf&quot;:&quot;h&quot;,          &quot;hhfh&quot;:&quot;hfjfhdj&quot;,          &quot;cat&quot;:&quot;B&quot;          &quot;ABC&quot;: &quot;2&quot;       } ]  the final value i am getting as below: [&quot;0&quot;:{          &quot;hjhj&quot;:&quot;&quot;,          &quot;hfhfhf&quot;:&quot;h&quot;,          &quot;hhfh&quot;:&quot;hfjfhdj&quot;,          &quot;cat&quot;:&quot;B&quot;,           },    &quot;1&quot;:{          &quot;asdf&quot;:&quot;&quot;,          &quot;fdrtf&quot;:&quot;869966&quot;,          &quot;hdhfhfh&quot;:&quot;utytut&quot;,          &quot;Cat&quot;:&quot;A&quot;              },    &quot;2&quot;:{        &quot;hjhj&quot;:&quot;&quot;,          &quot;hfhfhf&quot;:&quot;h&quot;,          &quot;hhfh&quot;:&quot;hfjfhdj&quot;,          &quot;cat&quot;:&quot;B&quot;    }   ]  kindly someone help me out to achieve this
49049
Error Message:  Oops! Your question couldn't be submitted because: Please add some context to explain the code sections (or check that you have not incorrectly formatted all of your question as code).  How do I fix this issue? It says that I need to explain my code more when I try to post this as google-apps-script. I have explained almost every part of the code. Also, this code was posted previously and I just added a few extra lines with explanations. What do they mean by &quot;context&quot; function doGet() {   var app = UiApp.createApplication();   //Create listBox   var listBox = app.createListBox();   //Add items to listBox   listBox.addItem(&quot;item 1&quot;).addItem(&quot;item 2&quot;).addItem(&quot;item 3&quot;).setName(&quot;myListBox&quot;);   //Create hidden app   var hidden = app.createHidden().setName('hidden').setId('hidden')   //Create button handler   var handler = app.createServerHandler(&quot;buttonHandler&quot;);   // pass the listbox into the handler function as a parameter and the hidden widget as well   handler.addCallbackElement(listBox).addCallbackElement(hidden);    //Create flextable   var table = app.createFlexTable().setId(&quot;myTable&quot;);    //Create flex table style attributes     table.setStyleAttribute(&quot;border-style&quot;, &quot;solid&quot;)     table.setStyleAttribute(&quot;border-width&quot;, &quot;1px&quot;)     table.setCellPadding(1);      //Create flex table headers   table.setWidget(0, 0, app.createLabel(&quot;Product Type&quot;)).setStyleAttribute(&quot;color&quot;, &quot;blue&quot;);   table.setWidget(0, 5, app.createLabel(&quot;Size&quot;));    var button = app.createButton(&quot;+&quot;, handler);    // add all widgets to the app   app.add(table).add(hidden);   app.add(listBox).add(button)   return app; }  function buttonHandler(e) {   var app = UiApp.getActiveApplication();   // get the position (is a string)   var pos = e.parameter.hidden;   // initial condition, hidden widget is empty    if(pos==null){pos='0'};   // convert to number    pos=Number(pos);   var table = app.getElementById(&quot;myTable&quot;);   // add the new item at the right place   table.insertRow(pos).insertCell( pos, 0).setText(pos, 0, e.parameter.myListBox);   // increment position   ++pos;   // save value   app.getElementById('hidden').setValue(pos);   // update app   return app; }
39725
I am trying to build a datatable in lwc and one of the column's datatype is url. When I provide URL it shows as  , what I want is just label "Google.com".  I can see from the docs of the  , i can use typeAttributes for url and provide "label", "target" and it should be good to go.  But when I try that I get cell as http://[object Object] which is a bit weird.    Template.html :  &lt;template&gt;     &lt;div class="slds-m-top_medium slds-m-bottom_x-large"&gt;         &lt;h2 class="slds-text-heading_medium slds-m-bottom_medium"&gt;             A data table that fetches content during initialization.         &lt;/h2&gt;          &lt;!-- Simple --&gt;         &lt;div class="slds-p-around_medium lgc-bg" style="height: 300px;"&gt;             &lt;lightning-datatable                 key-field="id"                 data={data}                 columns={columns}                 is-loading={tableLoadingState}&gt;             &lt;/lightning-datatable&gt;         &lt;/div&gt;     &lt;/div&gt; &lt;/template&gt;   JS :  import { LightningElement, track } from 'lwc';  const columns = [     { label: 'Date', fieldName: 'createdDate' , type: 'date-local',typeAttributes :{ month: "2-digit",day: "2-digit"}},     { label: 'Duplicate Website', fieldName: 'duplicateWebsite', type: 'url'  },     { label: 'Person Detail Match', fieldName: 'personDetailMatch', type: 'boolean' }  ];  export default class DatatableBasic extends LightningElement {     @track data = [];     @track columns = columns;     @track tableLoadingState = true;       connectedCallback() {         const data =  [{createdDate : "1479944705000" , duplicateWebsite : { label : 'Google' , target : 'www.google.com'}   , personDetailMatch : true }];         this.data = data;         this.tableLoadingState = false;     } }   Playground Link :   Update: I managed to update label by providing label fieldName in column definition   const columns = [         { label: 'Date', fieldName: 'createdDate' , type: 'date-local',typeAttributes :{ month: "2-digit",day: "2-digit"}},         { label: 'Duplicate Website', fieldName: 'duplicateWebsite', type: 'url',typeAttributes: { label: {fieldName:'duplicateWebsite'}, value: {fieldName:'urlTarget'}  }  },         { label: 'Person Detail Match', fieldName: 'personDetailMatch', type: 'boolean' }    ];   And rowData as  const data =  [{personName:"url name", createdDate : "1479944705000" , duplicateWebsite : "Google"  ,urlTarget : "www.google.com",  personDetailMatch : true }];   Now the issue is it takes label value as href value, thus making links dead.  Updated Playground Link:
82116
Since I started coding in Apex, I've gotten used to working with lists of IDs of objects not the objects themselves.  This time around, instead of creating a List&lt;ID&gt; of account ids, I created a List&lt;Account&gt;.  Now, I'm trying to add account records to this list, via a lookup field on a related custom object. However, when I do this, I get an error back telling me I'm trying to add an ID to an sObject list.   So what I'm wondering is, how would I best indicate that it's the sObject record as a whole I want to add, not just the ID indicated by the lookup field? And if it involves a SOQL query, wouldn't that be problematic in terms of hitting governors limits?
72615
I have to calculate the sum of related child object(contact) on field (Score1__c and Score2__c) to parent object Account object field(AccountScore1__c and AccountScore2__c)  my code is working on insert update undelete but not working with ****delete**** event  trigger ContactScoreRollup on Contact (after insert,after update,after undelete,Before Delete) {     Set&lt;Id&gt; accountIds = new Set&lt;Id&gt;();     List&lt;Account&gt; accountsToUpdate = new List&lt;Account&gt;();     List&lt;Account&gt; accountsToUpdate1 = new List&lt;Account&gt;();     if(trigger.isinsert || trigger.isundelete || trigger.isupdate){         for(Contact con :Trigger.new){             accountIds.add(con.AccountId);         }     }     if(Trigger.isdelete || Trigger.isupdate){         for(contact con : Trigger.old){             accountids.add(con.Accountid);         }         accountIds.remove(null);     }      for(AggregateResult ar :[SELECT AccountId,SUM(Score1__c) sumammount1 FROM Contact  where AccountId in: accountIds  GROUP BY AccountId]){          accountsToUpdate.add(new Account(Id = (Id)ar.get('AccountId'),AccountScore1__c= (Decimal)ar.get('sumammount1') ));     }      for(AggregateResult arr :[SELECT AccountId,SUM(Score2__c) sumammount2 FROM Contact  where AccountId in: accountIds  GROUP BY AccountId]){          accountsToUpdate1.add(new Account(Id = (Id)arr.get('AccountId'),Account_Score2__c= (Decimal)arr.get('sumammount2') ));     }     update accountsToUpdate;     update accountsToUpdate1; }
77477
I am trying to dynamically create a data table with two arrays (SObject array and a String array which has field API name).  The two arrays are Contact[] and String[], where String[] consists of ["Id", "Name"].  What I've tried dot notation and square bracket notation but neither worked.  &lt;!-- row --&gt; &lt;aura:iteration item="{!v.contacts} var="contact"&gt;     &lt;!-- column --&gt;     &lt;aura:iteration item="{!v.fieldNames} var="fieldName"&gt;         {!contact.fieldName}          {!contact[fieldName]}     &lt;/aura:iteration&gt; &lt;/aura:iteration&gt;   Not quite sure what is the correct approach to do this.
40374
I'm trying to create a dynamic sender profile where the from name and from email change if a value is present in a specific field of the data extension. I want the Lead First Name value and Lead Last Name values to appear. I'm trying to keep all the logic in the sender profile. %%=IIF(EMPTY(AttributeValue(&quot;X&quot;)), &quot;Bill&quot;, AttributeValue(&quot;LeadFirstName&quot;) AttributeValue(&quot;LeadLastName&quot;))=%%  Not sure why, but doing the test, the script shows up as the sender and isn't resolving.
5960
I have two tables, movies and categories, and I get an ordered list by categoryID first and then by Name.  The movie table has three columns ID, Name and CategoryID. The category table has two columns ID and Name.  I tried something like the following, but it didn't work.  var movies = _db.Movies.OrderBy( m =&gt; { m.CategoryID, m.Name })
25086
I have queries pulling all of the information correctly but what I can't seem to find was a way to add new options to a picklist using APEX.  I currently have   Package__c.Products__c.add(new Schema.PicklistEntry(products[j].Name));   Package__c is my custom object, and Products__c is the picklist. products[j] is pulling a list of products pulled from our products page.  And I've tried adding it as a select option, or even casting the variable type.  And this information has to go to the actual picklist within a custom object, and not within a visual force page or anything like that.
68741
I'm having troubles with rendering my datatable correctly. There are actions added but it seems the datatable is not high enough to view it correctly. Is it something I'm doing wrong? Or is it a bug?    This is the code for the datatable  &lt;div class="slds-text-heading_medium"&gt;Search results&lt;/div&gt; &lt;lightning:datatable data="{! v.persondata }"                      columns="{! v.personcolumns }"                      keyField="id"                     onrowselection="{! c.getSelectedPerson }"                     hideCheckboxColumn="true"  /&gt;   Here is the code for initializing the columns  //init datatable component.set('v.personcolumns', [             {label: 'Last Name', fieldName: 'LastName', type: 'text'},             {label: 'First Name', fieldName: 'FirstName', type: 'text'},             {label: 'Mailing Zip/ Postal Code', fieldName: 'PersonMailingPostalCode', type: 'text'},             {label: 'Mailing City', fieldName: 'PersonMailingCity', type: 'text'},             {label: 'Billing Street', fieldName: 'PersonMailingStreet', type: 'text'},             {label: 'Email', fieldName: 'PersonEmail', type: 'text'},             {label: 'Primary Phone', fieldName: 'PersonHomePhone', type: 'text'},             {label: 'Secondary Phone', fieldName: 'PersonOtherPhone', type: 'text'},             {type: 'action', typeAttributes: { rowActions: actions}}         ]);   And the code for adding data (the response is a list of Accounts)  component.set('v.persondata',response.getReturnValue());
106917
This formula works fine when adding a new list item:  =[Class Date]>=TODAY()+3  Basically ensuring the user selects a date greater than two days away from current date.  I don't want the formula to be in effect if the record is an UPDATE to an existing record.  So if someone comes back to this record after completing it correctly and saving it, but now wants to update a different field I don't want this field to be editable nor do I want the validation formula to be applied to the updating of the record.  Is this possible?