• Venu9999
  • NEWBIE
  • 65 Points
  • Member since 2015


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 9
    Replies
apex controller

public with sharing class CoronaTableLWC {
    
    public static  List<CronaWrapLWC> CountryWrapperList{get;set;}
    @AuraEnabled(Cacheable=true)
    public static List<CronaWrapLWC>   ConList(){
        
        CountryWrapperList = new List<CronaWrapLWC>();
        
        HttpRequest req = new HttpRequest();
        
        HttpResponse res = new HttpResponse();
        
        Http http = new Http();
        
        
        req.setEndpoint('https://api.covid19api.com/countries');
        
        req.setMethod('GET');
        
        res = http.send(req);
        
        
        if(res.getstatusCode() == 200 && res.getbody() != null){
            
            CountryWrapperList=(List<CronaWrapLWC>)json.deserialize(res.getbody(),List<CronaWrapLWC>.class);
            //CountryWrapperList.sort();
        }
        
        return Countrywrapperlist;
    }

public with sharing class CronaWrapLWC {
   
        @AuraEnabled
        public String Country{get;set;}
}

controller.js

import { LightningElement, wire, track } from 'lwc';
import ConData from '@salesforce/apex/CoronaTableLWC.ConData';
import ConList from '@salesforce/apex/CoronaTableLWC.ConList';
 
let i=0;
export default class CoronaRecord extends LightningElement {
    @track columns = [ { label: 'Country', fieldName: 'Country',type: 'text', sortable: "true"},
                  { label: 'Confirmed', fieldName: 'Confirmed',type: 'text', sortable: "true"},
                  { label: 'Deaths', fieldName: 'Deaths', type: 'text',sortable: "true"},
                  { label: 'Recovered', fieldName: 'Recovered',type: 'text', sortable: "true" },
                  {label: 'NewDate', fieldName: 'NewDate', type: 'date', sortable:"true"}]
    //@track error;
    @track data ;
    @track countryData;
    @track error;   //this holds errors
    @track items = []; //this holds the array for records with value & label
    @track value = '';
    @track sortBy;
    @track sortDirection;
    
  
    
    @wire(ConList)
    wiredContacts({ error, data }) {
        if (data) {
            for(i=0; i<data.length; i++) {
                console.log('id=' + data[i]);
                this.items = [{value: data}];                                   
            }                
            this.error = undefined;
        } else if (error) {
            this.error = error;
            this.contacts = undefined;
        }
    }
    get statusOptions() {
        console.log(this.items);
        return this.items;
    }
    handleChange(event) {
        // Get the string of the "value" attribute on the selected option
        const selectedOption = event.detail.value;
        console.log('selectedOption=' + selectedOption);
    }
}

html

<template>
    <lightning-card title="CORONA CHART" icon-name="standard:contact" >
        
        <lightning-combobox
            name="contacts"
            label="Contacts"
            placeholder="Choose Contact"
            value={value}
            onchange={handleChange}
            options={statusOptions}>
        </lightning-combobox>
</template>
Basically this.caseWithComments is my track variable and it holds the list of case and using <template displaying data.
am trying to change the collection with in the JS file on button click and this.caseWithComments is read only so trying to change with new declaration and able to change the value and binding value back to the list but DOM is not rendering.
showCaseComments(event) {
        let caseWithCommentsNew = this.caseWithComments;
        //console.log('Final==='+JSON.stringify(this.caseWithComments));
        for(var i=0;i < this.caseWithComments.length; i++ ){
            console.log('first variable==='+JSON.stringify(this.caseWithComments[i]));
            let ccNew = JSON.parse(JSON.stringify(this.caseWithComments[i]));
            ccNew.showCComments = true;
            //console.log('after show comment'+ccNew.showCComments ); 
            caseWithCommentsNew.push(ccNew);
            //this.caseWithComments[i] = ccNew;
            
        }
        
        //console.log('final===='+JSON.stringify(caseWithCommentsNew));
        this.caseWithComments = casewithCommentsNew;
        console.log('length===='+this.caseWithComments.length);
        //this.caseWithComments.splice(1,1);
        console.log('Final==='+JSON.stringify(this.caseWithComments));
    }

<template if:true={caseWithComments}>
                <template for:each={caseWithComments} for:item="cs" for:index="indexVar">
                    <tr key={cs.showCComments} class="slds-hint-parent">
                        <td><lightning-button variant="base" icon-name="utility:edit"  title="Primary action" onclick={showCaseComments} > </lightning-button></td>
                        <td > {cs.caseRecord.CaseNumber}</td>
                        <td>{cs.caseRecord.Owner.Name}</td>
                        <td>{cs.caseRecord.Status}</td>
                        <td>{cs.caseRecord.CreatedDate}</td>
                        <td>{cs.caseRecord.ClosedDate}</td>
                        <td>{cs.caseRecord.Origin}</td>
                        <td>{cs.caseRecord.Reason}</td>
                        <td>{cs.caseRecord.SourceId}</td>
                        <td>{cs.caseRecord.Description}</td>
                        <td> <template if:true={cs.ccCount}><lightning-button variant="brand" label="Show" title="Primary action" onclick={showCaseComments} class="slds-m-left_x-small"> </lightning-button> </template></td>
                    </tr>
</template>
</template>

 
global class ManageCustomer {
  public ManageCustomer() {
     }

  global class customerWrapper {
    webservice Account account;
    webservice list<Card__c> cards;

  }
  webservice static Boolean upsertCusomer(customerWrapper customer){
    return true;
  }

  webservice static Account getCustomer(String customerId){
    return null;
  }
    
  webservice static list<customerWrapper> getCustomerByMaxxingIds(list<String> maxxingIds)
  {
    list<Account> accounts = [Select MaxxingID__c from Account where MaxxingID__c IN : maxxingIds];

    return new list<customerWrapper>();
  }
}
public class GETProductAvailability_CTRL {
  
    public String response {get; set;}
    public String ItemCode {get; set;}
    public  List<AvailabilityDetail> results {get; set;}
    
    public GETProductAvailability_CTRL(ApexPages.StandardController stdController) { 
        id itemID = ApexPages.currentPage().getParameters().get('id');
        if(itemID!=NULL) {
           list<Product2> item = [SELECT ID, ProductCode from Product2 WHERE ID = : itemID LIMIT 1];
           if(item.size()>0 && item[0].ProductCode!=NULL)
               ItemCode = item[0].ProductCode;
        }
        
    }

    public PageReference getProductAvailability()
    {  
        if(ItemCode!=NULL) {
            try
            {
                results = new List<AvailabilityDetail>();
                ProductAvailabilitySOAP.availableToPromiseInvService stub = new ProductAvailabilitySOAP.availableToPromiseInvService();
                ProductAvailabilitySOAP.availableLocations_element[] result = stub.availableToPromiseInvService(ItemCode);
                for(ProductAvailabilitySOAP.availableLocations_element res:result) {
                    results.add(GetAvailabilityDetail(res));
                }            
                return null;  
                
            }
            catch(Exception e)
            {
              string resultMessage = 'Failed to get this product availability. Error = ';           
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, resultMessage + e.getMessage()));
              return null;
            }                 
        } else {
            string productAvailabilityPageError = Label.productAvailabilityPageError;
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, productAvailabilityPageError));
            return null;
        }
    }

    // utility method to convert the xml element to the inner class
    private AvailabilityDetail GetAvailabilityDetail(ProductAvailabilitySOAP.availableLocations_element element) {

        AvailabilityDetail AvDetail = new AvailabilityDetail();
        AvDetail.loc_name = element.loc_name;
        AvDetail.loc_type = element.loc_type;
        AvDetail.location = element.location;
        AvDetail.vstore = element.vstore;
        AvDetail.available_on = element.available_on;
        AvDetail.item = element.item;
        AvDetail.avail_qty = element.avail_qty;        
        AvDetail.threshold = element.threshold;
        AvDetail.avail_online = element.avail_online;
        return AvDetail;
    }
    
  public class AvailabilityDetail {
        public String loc_name {get; set;}
        public String loc_type {get; set;}
        public String location {get; set;}
        public String vstore {get; set;}
        public String available_on {get; set;}
        public String item {get; set;}
        public String avail_qty {get; set;}
        public String threshold {get; set;}
        public String avail_online {get; set;}        
    }
}

public class MedalliaIntegrationHelper {
    
    public class NPSInviteWrapper {
        //Transaction/Order Attributes
    public String Invite_Type  {set; get;}
    public String Invoice_Date  {set; get;}
    public String Invoice_No  {set; get;}
    public String Shopping_Amount  {set; get;}        
    public String Branch_Code  {set; get;}
    public String Tag  {set; get;}
    public String Customer_Idnt  {set; get;}        
        //Customer Attributes
    public String Amber_Idnt  {set; get;}
    public String Tiername  {set; get;}
    public String Title  {set; get;}
    public String First_Name  {set; get;}
    public String Last_Name  {set; get;}
    public String Mobilenumber  {set; get;}
    public String Sms_Market  {set; get;}
    public String Postbox  {set; get;}
    public String City  {set; get;}
    public String Country  {set; get;}
    public String Email_Address  {set; get;}
    public String Gender  {set; get;}
    public String Age_Group  {set; get;}
    public String Ethnic_Group  {set; get;}
    public String Birth_Date  {set; get;}
    public String Tenure  {set; get;}
        //Location Attributes
    public String Brand_Name  {set; get;}
    public String Branch_Name  {set; get;}
    public String Mall_Name  {set; get;}
    public String Store_City  {set; get;}        
    }
}
Hello All,
I have a LWC wrapped inside an aura component.
This is used in a Quick action.
I am trying to redirect to the newly created child record but the page save but does not redirect.  It stays on the parent record.
Code is called on success:
import {CurrentPageReference,NavigationMixin} from 'lightning/navigation'   

export default class GetValueInLWC extends NavigationMixin (LightningElement)  {

this[NavigationMixin.Navigate]({
                type: 'standard__recordPage',
                attributes: { 
                     recordId: event.detail.id,
                     objectApiName: 'Payment_Term__c', 
                     actionName: 'view'
                } 
            });
I know I am getting the new record id but it does not redirect.  Is it becuase the LWC is wrapped in an aura component?  What are my options?
Thanks,
P
 
i'm trying to select all rows and approve them at once with the pagination., but only rows in first page are getting updated when i click on approve button eventhough all rows are selected.How do i make all rows updated at once
  • August 11, 2020
  • Like
  • 0
apex controller

public with sharing class CoronaTableLWC {
    
    public static  List<CronaWrapLWC> CountryWrapperList{get;set;}
    @AuraEnabled(Cacheable=true)
    public static List<CronaWrapLWC>   ConList(){
        
        CountryWrapperList = new List<CronaWrapLWC>();
        
        HttpRequest req = new HttpRequest();
        
        HttpResponse res = new HttpResponse();
        
        Http http = new Http();
        
        
        req.setEndpoint('https://api.covid19api.com/countries');
        
        req.setMethod('GET');
        
        res = http.send(req);
        
        
        if(res.getstatusCode() == 200 && res.getbody() != null){
            
            CountryWrapperList=(List<CronaWrapLWC>)json.deserialize(res.getbody(),List<CronaWrapLWC>.class);
            //CountryWrapperList.sort();
        }
        
        return Countrywrapperlist;
    }

public with sharing class CronaWrapLWC {
   
        @AuraEnabled
        public String Country{get;set;}
}

controller.js

import { LightningElement, wire, track } from 'lwc';
import ConData from '@salesforce/apex/CoronaTableLWC.ConData';
import ConList from '@salesforce/apex/CoronaTableLWC.ConList';
 
let i=0;
export default class CoronaRecord extends LightningElement {
    @track columns = [ { label: 'Country', fieldName: 'Country',type: 'text', sortable: "true"},
                  { label: 'Confirmed', fieldName: 'Confirmed',type: 'text', sortable: "true"},
                  { label: 'Deaths', fieldName: 'Deaths', type: 'text',sortable: "true"},
                  { label: 'Recovered', fieldName: 'Recovered',type: 'text', sortable: "true" },
                  {label: 'NewDate', fieldName: 'NewDate', type: 'date', sortable:"true"}]
    //@track error;
    @track data ;
    @track countryData;
    @track error;   //this holds errors
    @track items = []; //this holds the array for records with value & label
    @track value = '';
    @track sortBy;
    @track sortDirection;
    
  
    
    @wire(ConList)
    wiredContacts({ error, data }) {
        if (data) {
            for(i=0; i<data.length; i++) {
                console.log('id=' + data[i]);
                this.items = [{value: data}];                                   
            }                
            this.error = undefined;
        } else if (error) {
            this.error = error;
            this.contacts = undefined;
        }
    }
    get statusOptions() {
        console.log(this.items);
        return this.items;
    }
    handleChange(event) {
        // Get the string of the "value" attribute on the selected option
        const selectedOption = event.detail.value;
        console.log('selectedOption=' + selectedOption);
    }
}

html

<template>
    <lightning-card title="CORONA CHART" icon-name="standard:contact" >
        
        <lightning-combobox
            name="contacts"
            label="Contacts"
            placeholder="Choose Contact"
            value={value}
            onchange={handleChange}
            options={statusOptions}>
        </lightning-combobox>
</template>
Basically this.caseWithComments is my track variable and it holds the list of case and using <template displaying data.
am trying to change the collection with in the JS file on button click and this.caseWithComments is read only so trying to change with new declaration and able to change the value and binding value back to the list but DOM is not rendering.
showCaseComments(event) {
        let caseWithCommentsNew = this.caseWithComments;
        //console.log('Final==='+JSON.stringify(this.caseWithComments));
        for(var i=0;i < this.caseWithComments.length; i++ ){
            console.log('first variable==='+JSON.stringify(this.caseWithComments[i]));
            let ccNew = JSON.parse(JSON.stringify(this.caseWithComments[i]));
            ccNew.showCComments = true;
            //console.log('after show comment'+ccNew.showCComments ); 
            caseWithCommentsNew.push(ccNew);
            //this.caseWithComments[i] = ccNew;
            
        }
        
        //console.log('final===='+JSON.stringify(caseWithCommentsNew));
        this.caseWithComments = casewithCommentsNew;
        console.log('length===='+this.caseWithComments.length);
        //this.caseWithComments.splice(1,1);
        console.log('Final==='+JSON.stringify(this.caseWithComments));
    }

<template if:true={caseWithComments}>
                <template for:each={caseWithComments} for:item="cs" for:index="indexVar">
                    <tr key={cs.showCComments} class="slds-hint-parent">
                        <td><lightning-button variant="base" icon-name="utility:edit"  title="Primary action" onclick={showCaseComments} > </lightning-button></td>
                        <td > {cs.caseRecord.CaseNumber}</td>
                        <td>{cs.caseRecord.Owner.Name}</td>
                        <td>{cs.caseRecord.Status}</td>
                        <td>{cs.caseRecord.CreatedDate}</td>
                        <td>{cs.caseRecord.ClosedDate}</td>
                        <td>{cs.caseRecord.Origin}</td>
                        <td>{cs.caseRecord.Reason}</td>
                        <td>{cs.caseRecord.SourceId}</td>
                        <td>{cs.caseRecord.Description}</td>
                        <td> <template if:true={cs.ccCount}><lightning-button variant="brand" label="Show" title="Primary action" onclick={showCaseComments} class="slds-m-left_x-small"> </lightning-button> </template></td>
                    </tr>
</template>
</template>

 
how to pass record id from one component to another in lightning web component ??

please do tell using the example,, suppose i have one component in which i am creating campaign and after clicking on save button it jumps to another component and in  that component i want to create a campaign member for the (id) campaign which is created in previous component.

thank you
  • August 04, 2020
  • Like
  • 0
Hello,

I am trying to navigate to a record page when a button is clicked. I receive an error each time saying the page does not exist and to enter a valid url and try again. I tried navigating to a webpage to see if that would work and it did. Based on code examples and documentation I've seen I can't figure out why navigating to a record page is not working properly. 

Some context: My LWC sits on the campaign object and creates a button for each volunteer job that is connected to the campaign. Right now I am just trying to get the button to go to one of the volunteer job record pages. Once I know the navigation works I am going to try and fill the recordId attribute with the recordId associated with each button to direct to the correct volunteer job.

HTML:
<template>
    <lightning-card title="Program Navigation" record-id={recordId}>
        <ul class="slds-button-group-row slds-align_absolute-center">
            <template for:each={data} for:item="program">
                <li key={program.Id} class="slds-button-group-item">
                    <button class="slds-button slds-button_brand" onclick={navigateToVolunteerJob}>
                    {program.Name}</button>
                </li>
            </template>
        </ul>
    </lightning-card>
</template>

JS
import { LightningElement, track, api, wire } from 'lwc';
import getPrograms from '@salesforce/apex/programButtonController.getPrograms';
import { NavigationMixin } from 'lightning/navigation';

export default class ProgramButtons extends NavigationMixin(LightningElement) {
    @track data = [];
    @api recordId;

    @wire(getPrograms, {
        recordId: '$recordId'
    })
    wiredRecord(result) {
        if(result.data) {
            this.data = result.data;
            this.error = undefined;

        } else if (result.error) {
            this.error = 'Unknown error';
            this.data = undefined;
        }

        
    }

//Navigate to recordpage on click
    navigateToVolunteerJob() {
        this[NavigationMixin.Navigate]({
            type: 'standard_recordPage',
            attributes: {
                recordId: 'a0T02000000GoISEA0',
                objectApiName: 'GW_Volunteers__Volunteer_Job__c',
                actionName: 'view'
            }
        });

    }

//test naviagting to webpage
    navigateToWebPage() {
        // Navigate to a URL
        this[NavigationMixin.Navigate]({
            type: 'standard__webPage',
            attributes: {
                url: 'http://salesforce.com'
            }
        },
        true // Replaces the current page in your browser history with the URL
      );
    }
}



Thanks!
Katie 
User-added image

I have created two LWC component and in my prop.html I want to add lWC component.

<template>
    <ligthning-input label="percentage" type="number" min="0"
    max="100" value={percentage} onchange={changepercent}></ligthning-input>   
    <c-lwc percentage={percentage}></c-lwc>
</template>

When I try to push this to my scratch org I am getting the following error

User-added image

I am new to LWC
Hi,

I am trying to display a lightning-datatable with few columns in lightning web component. As I get the data from apex, I try to add new column in the JS controller dynamically with hyperlink (as we did in aura component), but it does not allow me to add this new column.

Aura Component
component.set('v.mycolumns', [
            {label: 'Account Name', fieldName: 'linkName', type: 'url', 
            typeAttributes: {label: { fieldName: 'Name' }, target: '_blank'}},
            {label: 'Industry', fieldName: 'Industry', type: 'text'},
            {label: 'Type', fieldName: 'Type', type: 'Text'}
        ]);
 
action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                records.forEach(function(record){
                    record.linkName = '/'+record.Id;
                });
                component.set("v.acctList", records);
            }
        });

I am trying to do similar implementation in LWC but no luck. Can someone please help me on this.

Thanks.
Hi all,

in the documentation (https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation) a way is documented to preselect rows programmatically.
For this reason you should use "selected-rows"-attribut on lightning-datatable.

DOCUMENTATION

The selected-rows attribute enables programmatic selection of rows, which is useful when you want to preselect rows.
<lightning-datatable
    columns={columns}
    data={data}
    key-field="id"
    selected-rows={selectedRows}>
</lightning-datatable>
<lightning-button
    label="Select"
    onclick={handleSelect}>
</lightning-button>

To select a row programmatically, pass in the row key-field value.
// Load data via init handler first
// then handle programmatic selection
handleSelect() {
   const rows = ['a'];
   this.selectedRows = rows;
}

My component looks (simplfied) the following way:
export default class MergeDuplicates extends LightningElement {
    @track preSelectedRows = ['0011x00000KOMiJAAX'];
    
    [...]
}

My html-file (simplified) looks the following way:
<lightning-datatable
       key-field="Id"
       data={data}
       columns={columns}
       onrowselection={handleSelected}
       selected-rows={preSelectedRows}
       is-loading={tableLoadingState}>
</lightning-datatable>

My purpose: Preselect the current account, because the lwc is placed on a lightning record page for account.

My problem: Nothing happens. No checkbox is active.

One of my first ideas was the key-field. I changed it from "id" (lowercase) to "Id" (uppercase) but that don't solve the problem.

I don't know any other simpler way to test the preselect of rows for datatable than my example above.

Any suggestions?