• shalini sharma 24
  • NEWBIE
  • 45 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 13
    Replies
Hi,
I am getting null value in the parameter "contactField" which is being passed to the apex class. i am expecting the value in the lightning :input to be passed to the apex controller.
public class wrapperDisplayController {
   @AuraEnabled
    public static void saveRecords(String contactField){
        system.debug('contactField >> ' +contactField);
        if(!string.isBlank(contactField)){
            Contact c = new Contact();
             
                MainClass.wrapperClass oWrapField = (MainClass.wrapperClass)System.JSON.deserialize(contactField,MainClass.wrapperClass.class);
                c.Wrapper_Field__c = oWrapField.headerMsg;
                c.LastName = 'Test wrap';
        }
        
    }
Wrapper Class
public class MainClass {
     public class wrapperClass{
         @AuraEnabled public String headerMsg {get;set;}
    }
}
Lightning Component
<aura:component controller="wrapperDisplayController" implements="lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <!--aura init handler , call js "loadData" function on component load, and display contact data on table-->   
     <aura:attribute name="wrapperList" type="MainClass.wrapperClass"/>  
  <lightning:input name="contactedPerson" label="Person being Contacted" placeholder="type here..." value="{!v.wrapperList.headerMsg}"/>   
    <p>
    Contacted Person : {!v.wrapperList.headerMsg}
    </p>
    <div class="slds-size--1-of-3 slds-large-size--1-of-3 slds-align--absolute-center"> 
                                    <lightning:button class="slds-button slds-button--brand"  onclick="{!c.saveContactReport}">Save Contact Report</lightning:button> 
                                 </div>    
</aura:component>
 Js Controller:
({
    saveContactReport : function(component,event,helper) {
        alert('save method called');
        var field = component.get("v.wrapperList");
        var action = component.get('c.saveRecords');
        alert('field is >> '+field);
        var fieldVal = JSON.stringify(field);
        alert('fieldVal is >> '+fieldVal);
         action.setParams({
                "contactField" : fieldVal
            });
        action.setCallback(this, function(response) {
        var state = response.getState();
        if (state === "SUCCESS") {
            alert("SUCCESS");
        }
      });
      $A.enqueueAction(action);
    },
    
})
  
    
}
I have a requirement where on the click of button i am redirection to the new lightning component using e.force:navigateToComponent. But i want this new component to open in a new window.
Hi ,

i have logged in as System Admin in community and i do not see the option for create new report. I can just the existing reports. 

User-added image
Thanks
HI All,

I want to sort the column in lightning datatable. All other columns are getting sorted properly except Account Name

<aura:component controller="AccountListController"
                 implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    Component
    <aura:attribute type="Account[]" name="acctList"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="sortedBy" type="String" default="Name"/>
    <aura:attribute name="sortedDirection" type="String" default="asc"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>
    
    <lightning:datatable data="{!v.acctList}" 
                         columns="{!v.mycolumns}" 
                         keyField="id"
                         hideCheckboxColumn="true"
                         onsort="{!c.updateColumnSorting}"
                         sortedBy="{!v.sortedBy}"  
                         sortedDirection="{!v.sortedDirection}"/>
    
</aura:component>

CONTROLLER.JS

({
    fetchAccounts : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Account Name', fieldName: 'accUrl__c', type: 'url', sortable: true,typeAttributes: {label: { fieldName: 'Name' }, target: '_blank',sortable:'true'}},
            {label: 'Industry', fieldName: 'Industry', type: 'text'},
            {label: 'Type', fieldName: 'Type', type: 'Text'}
        ]);
        var action = component.get("c.fetchAccts");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.acctList", response.getReturnValue());
                helper.sortData(component, component.get("v.sortedBy"), component.get("v.sortedDirection"));
            }
        });
        $A.enqueueAction(action);
    },
    updateColumnSorting: function (cmp, event, helper) {
        var fieldName = event.getParam('fieldName');
        if (fieldName == 'accUrl__c'){fieldName = 'Name';}
        alert('fieldName >> '+fieldName);
        var sortDirection = event.getParam('sortDirection');
        alert('sortDirection >> '+sortDirection);
        cmp.set("v.sortedBy", fieldName);
        cmp.set("v.sortedDirection", sortDirection);
        helper.sortData(cmp, fieldName, sortDirection);
    }
})

Helper.Js

({
    sortData: function (cmp, fieldName, sortDirection) {
        var data = cmp.get("v.acctList");
        var reverse = sortDirection !== 'asc';
        data.sort(this.sortBy(fieldName, reverse))
        cmp.set("v.acctList", data);
    },
    
    sortBy: function (field, reverse, primer) {
        var key = primer ?
            function(x) {return primer(x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'aaa')} :
            function(x) {return x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'aaa'};
       alert('direction2 >> '+reverse);
        alert('direction3 >> '+reverse);
        reverse = !reverse ? 1 : -1;
       alert('direction4 >> '+reverse);
        return function (a, b) {            
           // return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
           return a = key(a)?key(a):'', b = key(b)?key(b):'', reverse * ((a > b) - (b > a));
        }
    }
})

Apex Class:
public class AccountListController {

    @AuraEnabled
    public static List < Account > fetchAccts() {
        return [ SELECT Id, Name, Industry, Type,accUrl__c FROM Account  ];
    }
    
}​

accUrl__c ​ is a formula field on Account with return type text : "https://toons-dev-ed.lightning.force.com/one/one.app#/sObject/" &Id& "/view" 
Hi ,
I want to create multiple tabs dynamically. I am iteraring through for loop and inside for loop i am creating tab dynamically.
Below is the code:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <aura:attribute name="moretabs" type="Aura.Component[]"/>
        <lightning:tabset variant="scoped">
            <lightning:tab label="Item One">
                 Some content here
            </lightning:tab>
            {!v.moretabs}
        </lightning:tabset>
        <lightning:button label="Add tab" onclick="{!c.addTab}"/>
</aura:component>

CONTROLLER:
({
    addTab: function(component, event) {
        for(var i=0; i <4; i++){
        $A.createComponent("lightning:tab", {
            "label": "New Tab"+i,
            "id": "new",
            "onactive": component.getReference("c.addContent")
        }, function (newTab, status, error) {
            if (status === "SUCCESS") {
                alert('success');
                var body = component.get("v.moretabs[i]");
                component.set("v.moretabs[i]", newTab);
            } else {
                throw new Error(error);
            }
        });
    }
    },
    addContent : function(component, event) {
        var tab = event.getSource();
        switch (tab.get('v.id')){
            case 'new':
                $A.createComponent("lightning:badge", {
                    "label": "NEW"
                }, function (newContent, status, error) {
                    if (status === "SUCCESS") {
                        tab.set('v.body', newContent);
                    } else {
                        throw new Error(error);
                    }
                });
                break;
        }
    }
})

For some reason, my tabs are not gettiing created.
Hi,

I am Getting the below error

User-added image
COMPONENT:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="componentController">
    <aura:attribute name="stage" type="String"  />
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="moretabs" type="Aura.Component[]"/>
    <!--aura:attribute name="moretabs" type="String"/-->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <ui:outputText value="{!v.stage}" />
     <lightning:tabset variant="scoped">
        {!v.moretabs}
    </lightning:tabset>
</aura:component>

CONTROLLER:

​({
    doInit: function(component, event, helper) 
    {
        var cmpId = component.get("v.recordId");
        var stage = component.get("v.stage");
        var actiondisplay = component.get("c.fetchStage"); 
        actiondisplay.setParams({
           "ComponentId": cmpId,
           });    
        actiondisplay.setCallback(this,function(response)
        {
            var state=response.getState();
            var result=response.getReturnValue();
            if(state === "SUCCESS"){
                component.set("v.stage",response.getReturnValue());
                var stage = component.get("v.stage");
             if(stage == "Concept"){
          $A.createComponent("lightning:tab", {
            "label": "Revision1" ,
            "id": "new",
            "onactive": component.getReference("c.addContent")
             }, function (newTab, status, error) {
            if (status === "SUCCESS") {
                var body = component.get("v.moretabs[0]");
                component.set("v.moretabs[0]", newTab);
                    var nT = component.get("v.moretabs[0]")
            } else {
                throw new Error(error);
            }
        });
                
      
        
},
    addContent : function(component, event) {
        var tab = event.getSource();
        var cmpId = component.get("v.recordId");
        switch (tab.get('v.id')){
            case 'new':
                 $A.createComponent("sharinpix:SharinPix", {
                     "aura:id" : "sharinpix-cmp", 
                     "AlbumId" : cmpId,
                     "height" : "500"
                 }, function (newContent, status, error) {
                    if (status === "SUCCESS") {
                        tab.set('v.body', newContent);
                    } else {
                        throw new Error(error);
                    }
                });
                break;
        }
    }
})
Hi,

I want to place the managed package component (we can find this component under custom - managed in lightning app builder) inside the dynamically created Tab. How can this be done?
 
Hi,

I am creating lightning tabs dynamically from inside the lightning client side controller.

How can i put my visualforce page inside these tabs?
 
Hi all.

I have a lightning component where i am using lightning:listview. Below is the code.

I want to fix the header of the listview. How can i achieve this?

 <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >     
    <lightning:listView aura:id="listViewAccounts"
    objectApiName="object__c"
    listName="Default"
    rows="20"
    showActionBar="true"
    enableInlineEdit="false"
    showRowLevelActions="true"
/>        
</aura:component>

Thanks
Hi ,

I am doing sorting at the client side in helper class in lightning datatable using the below code. However, I am receiving null values in few columns and that is impacting the sorting of my data. How can I handle the null values to show at the last in the sorted table?

 sortData: function (cmp, fieldName, sortDirection) {
        var data = cmp.get("v.mydata");
        var reverse = sortDirection !== 'asc';
        data.sort(this.sortBy(fieldName, reverse))
        cmp.set("v.mydata", data);
    },
    sortBy: function (field, reverse, primer) {
        var key = primer ?
            function(x) {return primer(x[field])} :
            function(x) {return x[field]};
        reverse = !reverse ? 1 : -1;
        return function (a, b) {
            return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
        }
    },
 
Hi,

I have a lightning datatable with search box(below):
COMPONENT:
<aura:component controller="lightningViewController">
    <aura:attribute name="object" type="string" default="Submission__c" />
    <aura:attribute name="cols" type="String" /> 
    <aura:attribute name="fields" type="String" default="Submission_Number__c,Name,subUrl__c,
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    <lightning:input type="text" label="" name="search" value="{!v.searchText}" />
    <lightning:button variant="brand" value="{!v.selectedCol}" label="Search" onclick="{! c.handleClick }" />
    <lightning:datatable data="{!v.mydata}" columns="{!v.mycolumn}" 
                             onsort="{!c.updateColumnSorting}" sortedBy="{!v.sortedBy}" 
                              sortedDirection="{!v.sortedDirection}" 
                             onrowselection="{!c.getSelectedName}" keyField="Id" />
    
    </div>
    </aura:component>
    
CONTROLLER    
    ({
    init : function(component, event, helper) {
      helper.getLightningTableData(component,event);
   
    },
    
   handleClick : function(component, event, helper) {
        component.set("v.displeyError",false);
        var srchKeyword = '';
        srchKeyword = component.get("v.searchText");
        if(srchKeyword == 'undefined' || srchKeyword == null || srchKeyword == ''){
         srchKeyword = '';
            helper.getLightningTableData(component,event);
        }else{
           
            helper.searchResult(component, event,srchKeyword); 
        }
    },
   
})

HELPER:

({
 getLightningTableData : function(component,event) {    
        var sColumn = component.get("v.fields");
        var sObject = component.get("v.object");
        var action = component.get("c.getsObjectRecords");
        action.setParams({
            ObjectName : sObject,
            fieldstoget : sColumn,
            
        });
        action.setCallback(this,function(response){
        var state = response.getState();
        if(state == 'SUCCESS'){
            var rtnValue = response.getReturnValue();
            component.set("v.mydata",rtnValue.tableRecord);
            component.set("v.mycolumn",[
                    {label: 'Submission Number', fieldName: 'subUrl__c', sortable:'true', type: 'url', typeAttributes: {label: { fieldName: 'Submission_Number__c' }}},
                    {label: 'Name', fieldName: 'Name', sortable:'true', type: 'text'},
                    {label: 'Licensee', fieldName: 'Account_Name__c', type: 'text', sortable:'true'},
                    
          ]);
                   
                component.set("v.TotalRecords", rtnValue.totalRecords);
                var count = component.get("v.TotalRecords");
                var data = component.get("v.mydata");
                alert('count'+JSON.stringify(count));
                alert('data'+JSON.stringify(data));
                  
        }
       });
         $A.enqueueAction(action);
    },
   
   searchResult: function(component, event,srchKeyword){
        var action = component.get("c.getSearchResSubmission");
        action.setParams({
           "srchKeyword" : srchKeyword,
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS"){
                var storeResponse = response.getReturnValue();
                if (storeResponse.length == 0) {
                    alert('No Records Found');
                } else {
                    component.set("v.mydata",storeResponse.tableRecordSubmission);
                   component.set("v.mycolumn",[
                    {label: 'Submission Number', fieldName: 'subUrl__c', sortable:'true', type: 'url', typeAttributes: {label: { fieldName: 'Submission_Number__c' }}},
                    {label: 'Name', fieldName: 'Name', sortable:'true', type: 'text'},
                    {label: 'Licensee', fieldName: 'Account_Name__c', type: 'text', sortable:'true'},
                    ]);
                    component.set("v.TotalRecords", storeResponse.totalRecords);
                    var count = component.get("v.TotalRecords");
                    alert('count'+JSON.stringify(count));
                    var data = component.get("v.mydata");
                       alert('data'+JSON.stringify(data)); 
           
        }
      } else{
                alert('Error:');
            }
        });
        $A.enqueueAction(action);
    }
    
})

APEX CLASS:
public with sharing class lightningViewController {
    @AuraEnabled public static lightningTableWraper getsObjectRecords(String ObjectName,String fieldstoget){ 
          system.debug('fieldstoget' +fieldstoget);
       String lastModifiedDate;  
       String statusValue = 'Canceled';  
       String queryString;  
       String queryString1;
       Integer totalRecords;
       LightningTableWraper ltngTableWrapper = new LightningTableWraper();
       String DaysDifference;  
       String componentStatus;  
       String createdDate; 
       system.debug('totalRecords' + totalRecords);
        List<String> lstfieldstoget = fieldstoget.split(',');
        DescribeSObjectResult objResult = Schema.getGlobalDescribe().get(ObjectName).getDescribe();
        string tAtrib='test';
        for(String field : lstfieldstoget){
           lightningTableColumnWrapper colWrapper = new lightningTableColumnWrapper();
            
           DescribeFieldResult fieldResult = objResult.fields.getMap().get(field).getDescribe();
           colWrapper.label = fieldResult.getlabel();               
          
            if (fieldResult.getName()=='LastModifiedDate')
           {
              lastModifiedDate = fieldResult.getName();
             
           } else if (fieldResult.getName()=='Days_Difference__c'){
               
               DaysDifference = fieldResult.getName();
           }else if (fieldResult.getName()=='Component_Status__c'){
               
               componentStatus = fieldResult.getName();
           }
            
         
        }
           //-------------------start To get the size---------------
             queryString1 = 'Select '+ String.escapeSingleQuotes(String.join(lstfieldstoget,','))+
                 ' from '+ String.escapeSingleQuotes(ObjectName) ;
             queryString += ' ORDER BY ' + lastModifiedDate + ' DESC ';
             List<sObject> lst = database.query(queryString1);
             totalRecords = lst.size();
             //----------------   End To get the size------------------ 
             queryString = 'Select '+ String.escapeSingleQuotes(String.join(lstfieldstoget,','))+
                 ' from '+ String.escapeSingleQuotes(ObjectName) ;
             queryString += ' ORDER BY ' + lastModifiedDate + ' DESC ';
            system.debug('queryString' + queryString);
            ltngTableWrapper.tableRecord = database.query(queryString);
            system.debug('ltngTableWrapper.tableRecord'+ltngTableWrapper.tableRecord);
            ltngTableWrapper.totalRecords = totalRecords;
            return ltngTableWrapper;
            
    }
    
     @AuraEnabled
    public static lightningTableWraper getSearchResSubmission(String srchKeyword){
        String searchKey = srchKeyword;
        system.debug('searchKey'+searchKey);
         List <Submission__c> returnList = new List <Submission__c> ();
        String res = 'Find :searchKey IN ALL FIELDS RETURNING Submission__c(Submission_Number__c, Name,Account__r.Name,Licensee_Reference_Number__c,Property__c,Product__c,Submission_Status__c,Seasons__c,Region__c,Date_Created__c )';
        system.debug('res' +res);
        lightningTableWraper objDT =  new lightningTableWraper(); 
        objDT.lstdist = search.query(res);
        system.debug('result'+objDT.lstdist.size()); 
        system.debug('result'+objDT.lstdist);
        if(objDT.lstdist!=null && objDT.lstdist.size()>0)
        {    
            List<SObject> lstOfSerchdDist = objDT.lstdist.get(0);
            system.debug('final result'+lstOfSerchdDist);
            system.debug('final result size'+lstOfSerchdDist.size());
            if(lstOfSerchdDist!=null && lstOfSerchdDist.size()>0){
                for(SObject obj : lstOfSerchdDist){
                    Submission__c eachDist = (Submission__c)obj;
                    returnList.add(eachDist);
                }
            }
        }
         
        //-----------------
         List <Submission__c> returnList1 = new List <Submission__c> ();
         String res1 = 'Find :searchKey IN ALL FIELDS RETURNING Submission__c(Submission_Number__c,Name,Account__r.Name,Licensee_Reference_Number__c,Property__c,Product__c,Submission_Status__c,Seasons__c,Region__c,    Date_Created__c ';
        res1 += ' Limit ' + pSize ; 
           res1 += ' OFFSET ' + offset + ')' ;
        system.debug('res' +res1);
        lightningTableWraper objDT1 =  new lightningTableWraper(); 
        objDT.lstdist = search.query(res1);
        system.debug('result'+objDT.lstdist.size()); 
        system.debug('result'+objDT.lstdist);
        
        if(objDT.lstdist!=null && objDT.lstdist.size()>0)
        {    
            List<SObject> lstOfSerchdDist = objDT.lstdist.get(0);
            system.debug('final result'+lstOfSerchdDist);
            system.debug('final result size'+lstOfSerchdDist.size());
            if(lstOfSerchdDist!=null && lstOfSerchdDist.size()>0){
                for(SObject obj : lstOfSerchdDist){
                    Submission__c eachDist1 = (Submission__c)obj;
                    returnList1.add(eachDist1);
                }
            }
        }
        
        //-------------
         system.debug('returnList'+returnList);
        system.debug('returnListsize'+returnList.size());
        Integer totalRecords = returnList.size();
        system.debug('totalRecords' + totalRecords);
        objDT.tableRecordSubmission =  returnList1;
        objDT.totalRecords = totalRecords;
        system.debug('objDT' + objDT);
        return objDT;
   }
  
    public class lightningTableWraper{
        @AuraEnabled
        public List<sObject> tableRecord {get;Set;}
        @AuraEnabled
        List<List<SObject>> lstdist{get;set;}
        @AuraEnabled
        public List<Submission__c> tableRecordSubmission {get;Set;}
        @AuraEnabled
        public Integer totalRecords {get;set;}
    }
 
}
As you see i am getting the value in Submission Number column (first column) when the table is loaded i.e. initialised.

User-added image

But when on searching with any string (Eg Agent),the values are not getting populated in the submission number column(first column). Although , i am receiving the value for that column in the result in the helper class of the lightning component(can see the value for submission number in the alert.)

User-added image

User-added image
User-added image


 
Hi
i have created a lightning datatable and in that i have a column that displays text formula field. But the table shows html instead of image. Any solution for this??

Thanks
Hi,

I want to display the opportunity records with fields Oppotunity Name, Type in the lightniing dataTable. In that table, the opportunity Name column should be clickable and redirect to record detail page.
I want to create a picklist in lightning (<lightning:select>) and the value for the options should be fetched from List custom Setting. How can we do this?
Thanks

 
I have a lightning:inputRichText and a lightning:button named "Submit" on a lightning component. To start with, i have also created another ui:outputText to display the logged in user id. On the click of this button, i would like to post the text eneterd in the rich text area to the mentioned logged in  user id's chatter.
<aura:component controller="chatterpost" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:appHostable,force:hasRecordId,force:lightningQuickAction" access="global">
     <aura:attribute name="myVal" type="String" />
     <aura:handler name="init" value="{! this }" action="{! c.init }"/>
     <lightning:inputRichText value="{!v.myVal}" />
    <aura:attribute name="myText" type="string" />
    <ui:outputText class="field" value="{!v.userId}" />
    <lightning:button variant="brand" label="Send" onclick="{!c.init}"/> 
</aura:component>

------------------------------------------------------------------------------------------------

({
    init: function(cmp) {
        cmp.set('v.myVal', '<b>Hello!</b>');
        var userId = $A.get("$SObjectType.CurrentUser.Id");
        cmp.set('v.userId', userId);
        var action = cmp.get("c.getUserId");
        action.setCallback(this, function(response){
        var state = response.getState();
        if (state === "SUCCESS") {
            cmp.set("v.userId", response.getReturnValue());
         }
      });
       $A.enqueueAction(action);
     }

})
----------------------------------------------------------------------------------------------------
public class chatterpost {
 @AuraEnabled
public string body { get; set;}
 @AuraEnabled public string userID { get; set;}
  @AuraEnabled
public static void postFeed(){
FeedItem post = new FeedItem();
//post.ParentId = userID;
//post.Body = body;
insert post;
}
 @AuraEnabled
public static String getUserId() {
    return userinfo.getUserId();
}
}
I dont have much knowledge in lightning so its the rough code that i was trying to build up.Can anybody suggest me the solution to this.
Thanks
 Hi,
I want to display all the records returned by SOQL query in a VF Page through PageBlockTable and Pagination. But the tweak is that retrieved records are more than 50k and there is limit of 50K records . This has to be done in a synchronous way.
Hi ,

I have a scenario where i want to update the lead record's rating field when the status changes to status == 'Closed - Not Converted'.And i wrote after update trigger  for this: Below is the code
 trigger leadUpdate on Lead (after update) {
list<lead> leadUpdate = new List<Lead>();
    for(Lead l :trigger.new){
        if(trigger.oldMap.get(l.id).status != l.status && l.status == 'Closed - Not Converted'){
           lead ld = new lead(id = l.id,rating = 'cold');
            leadUpdate.add(ld); 
        }
    
    }
    update leadUpdate; 
}


And samething can be achieved through  before trigger as well. Below code:
trigger  leadUpdate on Lead (before update) {
List<lead> leadUpdate = new List<Lead>();
if(trigger.isBefore && trigger.isUpdate){
         for(Lead l :trigger.new){
        if(trigger.oldMap.get(l.id).status != l.status && l.status == 'Closed - Not Converted'){
           l.rating = 'cold';
            leadUpdate.add(l); 
        }
    
    }
   
    
    }
}
 
HI All,

I want to sort the column in lightning datatable. All other columns are getting sorted properly except Account Name

<aura:component controller="AccountListController"
                 implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    Component
    <aura:attribute type="Account[]" name="acctList"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="sortedBy" type="String" default="Name"/>
    <aura:attribute name="sortedDirection" type="String" default="asc"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>
    
    <lightning:datatable data="{!v.acctList}" 
                         columns="{!v.mycolumns}" 
                         keyField="id"
                         hideCheckboxColumn="true"
                         onsort="{!c.updateColumnSorting}"
                         sortedBy="{!v.sortedBy}"  
                         sortedDirection="{!v.sortedDirection}"/>
    
</aura:component>

CONTROLLER.JS

({
    fetchAccounts : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Account Name', fieldName: 'accUrl__c', type: 'url', sortable: true,typeAttributes: {label: { fieldName: 'Name' }, target: '_blank',sortable:'true'}},
            {label: 'Industry', fieldName: 'Industry', type: 'text'},
            {label: 'Type', fieldName: 'Type', type: 'Text'}
        ]);
        var action = component.get("c.fetchAccts");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.acctList", response.getReturnValue());
                helper.sortData(component, component.get("v.sortedBy"), component.get("v.sortedDirection"));
            }
        });
        $A.enqueueAction(action);
    },
    updateColumnSorting: function (cmp, event, helper) {
        var fieldName = event.getParam('fieldName');
        if (fieldName == 'accUrl__c'){fieldName = 'Name';}
        alert('fieldName >> '+fieldName);
        var sortDirection = event.getParam('sortDirection');
        alert('sortDirection >> '+sortDirection);
        cmp.set("v.sortedBy", fieldName);
        cmp.set("v.sortedDirection", sortDirection);
        helper.sortData(cmp, fieldName, sortDirection);
    }
})

Helper.Js

({
    sortData: function (cmp, fieldName, sortDirection) {
        var data = cmp.get("v.acctList");
        var reverse = sortDirection !== 'asc';
        data.sort(this.sortBy(fieldName, reverse))
        cmp.set("v.acctList", data);
    },
    
    sortBy: function (field, reverse, primer) {
        var key = primer ?
            function(x) {return primer(x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'aaa')} :
            function(x) {return x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'aaa'};
       alert('direction2 >> '+reverse);
        alert('direction3 >> '+reverse);
        reverse = !reverse ? 1 : -1;
       alert('direction4 >> '+reverse);
        return function (a, b) {            
           // return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
           return a = key(a)?key(a):'', b = key(b)?key(b):'', reverse * ((a > b) - (b > a));
        }
    }
})

Apex Class:
public class AccountListController {

    @AuraEnabled
    public static List < Account > fetchAccts() {
        return [ SELECT Id, Name, Industry, Type,accUrl__c FROM Account  ];
    }
    
}​

accUrl__c ​ is a formula field on Account with return type text : "https://toons-dev-ed.lightning.force.com/one/one.app#/sObject/" &Id& "/view" 
Hi
i have created a lightning datatable and in that i have a column that displays text formula field. But the table shows html instead of image. Any solution for this??

Thanks
Hi,
I am getting null value in the parameter "contactField" which is being passed to the apex class. i am expecting the value in the lightning :input to be passed to the apex controller.
public class wrapperDisplayController {
   @AuraEnabled
    public static void saveRecords(String contactField){
        system.debug('contactField >> ' +contactField);
        if(!string.isBlank(contactField)){
            Contact c = new Contact();
             
                MainClass.wrapperClass oWrapField = (MainClass.wrapperClass)System.JSON.deserialize(contactField,MainClass.wrapperClass.class);
                c.Wrapper_Field__c = oWrapField.headerMsg;
                c.LastName = 'Test wrap';
        }
        
    }
Wrapper Class
public class MainClass {
     public class wrapperClass{
         @AuraEnabled public String headerMsg {get;set;}
    }
}
Lightning Component
<aura:component controller="wrapperDisplayController" implements="lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <!--aura init handler , call js "loadData" function on component load, and display contact data on table-->   
     <aura:attribute name="wrapperList" type="MainClass.wrapperClass"/>  
  <lightning:input name="contactedPerson" label="Person being Contacted" placeholder="type here..." value="{!v.wrapperList.headerMsg}"/>   
    <p>
    Contacted Person : {!v.wrapperList.headerMsg}
    </p>
    <div class="slds-size--1-of-3 slds-large-size--1-of-3 slds-align--absolute-center"> 
                                    <lightning:button class="slds-button slds-button--brand"  onclick="{!c.saveContactReport}">Save Contact Report</lightning:button> 
                                 </div>    
</aura:component>
 Js Controller:
({
    saveContactReport : function(component,event,helper) {
        alert('save method called');
        var field = component.get("v.wrapperList");
        var action = component.get('c.saveRecords');
        alert('field is >> '+field);
        var fieldVal = JSON.stringify(field);
        alert('fieldVal is >> '+fieldVal);
         action.setParams({
                "contactField" : fieldVal
            });
        action.setCallback(this, function(response) {
        var state = response.getState();
        if (state === "SUCCESS") {
            alert("SUCCESS");
        }
      });
      $A.enqueueAction(action);
    },
    
})
  
    
}
Hi ,
I want to create multiple tabs dynamically. I am iteraring through for loop and inside for loop i am creating tab dynamically.
Below is the code:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <aura:attribute name="moretabs" type="Aura.Component[]"/>
        <lightning:tabset variant="scoped">
            <lightning:tab label="Item One">
                 Some content here
            </lightning:tab>
            {!v.moretabs}
        </lightning:tabset>
        <lightning:button label="Add tab" onclick="{!c.addTab}"/>
</aura:component>

CONTROLLER:
({
    addTab: function(component, event) {
        for(var i=0; i <4; i++){
        $A.createComponent("lightning:tab", {
            "label": "New Tab"+i,
            "id": "new",
            "onactive": component.getReference("c.addContent")
        }, function (newTab, status, error) {
            if (status === "SUCCESS") {
                alert('success');
                var body = component.get("v.moretabs[i]");
                component.set("v.moretabs[i]", newTab);
            } else {
                throw new Error(error);
            }
        });
    }
    },
    addContent : function(component, event) {
        var tab = event.getSource();
        switch (tab.get('v.id')){
            case 'new':
                $A.createComponent("lightning:badge", {
                    "label": "NEW"
                }, function (newContent, status, error) {
                    if (status === "SUCCESS") {
                        tab.set('v.body', newContent);
                    } else {
                        throw new Error(error);
                    }
                });
                break;
        }
    }
})

For some reason, my tabs are not gettiing created.
Hi,

I am Getting the below error

User-added image
COMPONENT:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="componentController">
    <aura:attribute name="stage" type="String"  />
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="moretabs" type="Aura.Component[]"/>
    <!--aura:attribute name="moretabs" type="String"/-->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <ui:outputText value="{!v.stage}" />
     <lightning:tabset variant="scoped">
        {!v.moretabs}
    </lightning:tabset>
</aura:component>

CONTROLLER:

​({
    doInit: function(component, event, helper) 
    {
        var cmpId = component.get("v.recordId");
        var stage = component.get("v.stage");
        var actiondisplay = component.get("c.fetchStage"); 
        actiondisplay.setParams({
           "ComponentId": cmpId,
           });    
        actiondisplay.setCallback(this,function(response)
        {
            var state=response.getState();
            var result=response.getReturnValue();
            if(state === "SUCCESS"){
                component.set("v.stage",response.getReturnValue());
                var stage = component.get("v.stage");
             if(stage == "Concept"){
          $A.createComponent("lightning:tab", {
            "label": "Revision1" ,
            "id": "new",
            "onactive": component.getReference("c.addContent")
             }, function (newTab, status, error) {
            if (status === "SUCCESS") {
                var body = component.get("v.moretabs[0]");
                component.set("v.moretabs[0]", newTab);
                    var nT = component.get("v.moretabs[0]")
            } else {
                throw new Error(error);
            }
        });
                
      
        
},
    addContent : function(component, event) {
        var tab = event.getSource();
        var cmpId = component.get("v.recordId");
        switch (tab.get('v.id')){
            case 'new':
                 $A.createComponent("sharinpix:SharinPix", {
                     "aura:id" : "sharinpix-cmp", 
                     "AlbumId" : cmpId,
                     "height" : "500"
                 }, function (newContent, status, error) {
                    if (status === "SUCCESS") {
                        tab.set('v.body', newContent);
                    } else {
                        throw new Error(error);
                    }
                });
                break;
        }
    }
})
Hi,

I want to place the managed package component (we can find this component under custom - managed in lightning app builder) inside the dynamically created Tab. How can this be done?
 
Hi,

I am creating lightning tabs dynamically from inside the lightning client side controller.

How can i put my visualforce page inside these tabs?
 
Hi all.

I have a lightning component where i am using lightning:listview. Below is the code.

I want to fix the header of the listview. How can i achieve this?

 <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >     
    <lightning:listView aura:id="listViewAccounts"
    objectApiName="object__c"
    listName="Default"
    rows="20"
    showActionBar="true"
    enableInlineEdit="false"
    showRowLevelActions="true"
/>        
</aura:component>

Thanks
I want to create a picklist in lightning (<lightning:select>) and the value for the options should be fetched from List custom Setting. How can we do this?
Thanks

 
I'm migrating an org from Classic to Lightning Experience, where the Detail page currently has a button that opens a Visualforce page (rendered as a PDF, e.g. /apex/myPdf?id={record.Id}) in a new window

In Lightning Experience, the detail page button will open the URL in the same window (despite behaviour being set to Display in new window). The only solution I've found so far would be to use a Lightning Component as an Action, and in the init method, open a new window. This part is fine, but then if the user returns to the original window (record page), they will see the modal still open.

From what I've read so far, if I want to auto-close the modal (i.e. $A.get("e.force:closeQuickAction").fire()) I cannot do that in the init method, so I would have to call this asynchronously (e.g. https://salesforce.stackexchange.com/questions/189248/forceclosequickaction-not-working ).

Is this really the only way to accomplish this? It seems like an overly complicated implementation to do something which seems very trivial (open a new window).
I have linked my lightning component with Quick action button,
but width of that pop-up has fixed width, my requirement is I want full screen to be acquire by that component.
through mew window or new tab,
How should I achieve this
I have a function that uses a sosl query:

private List<Product2> runSoslToExecute() {
    List<List<Product2>> searchResults = [FIND :query IN ALL FIELDS RETURNING Product2 (Id, Name)];
    List<Product2> results = new List<Product2>();
    for(Product2 p : searchResults[0]) {
        results.add(p);
    }
    return results;
}

If I search for "AB*" then I also get results that include "1AB...". I thought the "*" wildcard only searches in the middle and end of the search and not at the beginning? Is there a way to run the sosl search so it only searches "AB" at the beginning?

Thanks for any help.