Skip to main content Join the Agentforce Virtual Hackathon to build innovative solutions and compete for a $50k Grand Prize. Sign up now. Terms apply.

#Custom LWC0 diskutieren mit

Hi,

I am trying to reload the previous page after saving an edit form. After clicking on Save, I have used  window.history.back(); but it only navigates to the previous page, I require it to reload as well. Is there a way to do this?

#LWC  #LWC Component #Custom LWC #LWC Development #LWC Components

4 Antworten
  1. 10. Dez. 2024, 07:23

    Hii,

    To navigate back and reload the previous page, the most straightforward solution is to use window.history.back() followed by a short delay and window.location.reload().

     

    The implementation may look something like this : 

    window.history.back();

    setTimeout(function() {

    window.location.reload();

    }, 500);

0/9000

I have new error about this, have checked that component already have in Org but i check on PageEdit and Development Status it still haven't got the Component because deploy failed. Do you know what problem i have ? And how to fix it thanks.

 

"Unable to build Lightning Component source for markup://c:helloWorld2: Invalid suffix: json."

 

Error about Invalid Suffix: JSON Lightning Web Component

 

#LWC, #Custom LWC, #LWC Development , #LWC Components , #Lightning Web Components, #Deployment Issues

2 Antworten
0/9000

Dynamic Interaction Between Two Lightning Web Components  

Many times we have requirements to update or show detail on other components based on the action of the first component. Like we can have one component which will show a list of accounts and on selection, we will show the address of that account on a map. This post will explain to create a dynamic interaction between two  Lightning Web Components.

 

Check out post Dynamic Interaction Between Two Lightning Web Components to get step-by-step detail.

 

Dynamic Interaction Between Two Lightning Web Components Many times we have requirements to update or show detail on other components based on the action of the first component.

 

@Lightning Web Components @LWC @LWC Patterns

#Salesforce Developer #LWC #Custom LWC #Salesforce

0/9000

My images are stored on salesforce files, and I'm using content download URL to load images on website developed on Experience cloud (Community cloud),which is working fine on all other browser but not loading on safari. I have already gone through below troubleshooting 

 

 (*note: loading image from cms or asset is not part of the requirement). #Experience Cloud #Experience Builder #Safari Browser #Media Files #Custom LWC

5 Antworten
  1. 22. März 2022, 23:48

    @Amit Jindal Yes, I think what I did at that time as a part of the solution, I uploaded those images on Documents folder in Salesforce classic and referenced the URL and it worked for me. Also, make sure the community URLs are included in remote site settings. 

0/9000

Hi Experts,  Can anyone help me out, how to create list view along with filter criteria using LWC.

 

#LWC Development #LWC #LWC Component #LWC Components #Custom LWC 

2 Antworten
0/9000

Hi Experts,

 

I need to create a record on the selection of record type,  I have created a Combobox and populated the record type, now my requirement is that on the selection of that record type I need to create a record.

 

<template>

<div if:true={objectInfo.data}>

<lightning-combobox name="recordType" label="Record Type" placeholder="Choose Status"

value={value}

options={recordTypeId1}>

</lightning-combobox>

</div>

</template>

jS:

import { LightningElement, track, wire, api } from 'lwc';

import { getObjectInfo } from 'lightning/uiObjectInfoApi';

import CONTACT_OBJECT from '@salesforce/schema/Support_Request__c';

export default class CreateContact extends LightningElement {

@track statusOptions;

@track value;

@api objectApiName;

@track objectInfo;

@wire(getObjectInfo, { objectApiName: CONTACT_OBJECT,})

objectInfo;

get recordTypeId1() {

var recordtypeinfo = this.objectInfo.data.recordTypeInfos;

var uiCombobox = [];

console.log("recordtype" + recordtypeinfo);

for(var eachRecordtype in recordtypeinfo)//this is to match structure of lightning combo box

{

if(recordtypeinfo.hasOwnProperty(eachRecordtype))

uiCombobox.push({ label: recordtypeinfo[eachRecordtype].name, value: recordtypeinfo[eachRecordtype].name })

}

console.log('uiCombobox' + JSON.stringify(uiCombobox));

return uiCombobox;

}

}

Meta:

<?xml version="1.0" encoding="UTF-8"?>

<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">

<apiVersion>52.0</apiVersion>

<isExposed>true</isExposed>

<targets>

<target>lightning__AppPage</target>

<target>lightning__RecordPage</target>

<target>lightning__HomePage</target>

</targets>

</LightningComponentBundle>

#LWC  #LWC Development  #LWC Component  #LWC Components  #Lighting Web Components  #Custom LWC  #Sales Cloud

18 Antworten
0/9000

import { LightningElement, api, wire, track } from 'lwc';

import retrieveContacts from '@salesforce/apex/downloadContcatApexClass.retrieveContactMethod';

export default class DownloadContacts extends LightningElement {

@api recordId;

@track contacts;

@track error;

@api invoke(){

retrieveContacts({ recordIdAccount: this.recordId })

.then((result) => {

console.log('line 12:' + result);

this.contacts = result;

this.error = undefined;

})

.catch((error) => {

this.error = error;

this.contacts = undefined;

});

var columnEnd = ',';

var lineEnd = '\n';

// Get the CSV header from the list.

var keys = new Set();

this.contacts.forEach(function (record) {

Object.keys(record).forEach(function (key) {

keys.add(key);

});

});

keys = Array.from(keys);

var csvString = '';

csvString += keys.join(columnEnd);

csvString += lineEnd;

for (var i = 0; i < this.contacts.length; i++) {

var counter = 0;

for (var sTempkey in keys) {

var skey = keys[sTempkey];

// add , after every value except the first.

if (counter > 0) {

csvString += columnEnd;

}

// If the column is undefined, leave it as blank in the CSV file.

var value = this.contacts[i][skey] === undefined ? '' : this.contacts[i][skey];

csvString += '"' + value + '"';

counter++;

}

csvString += lineEnd;

var hiddenElement = document.createElement('a');

hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);

hiddenElement.target = '_self';

//hiddenElement.download = component.get("v.fileName");

document.body.appendChild(hiddenElement); //Required for FireFox browser

hiddenElement.click(); // using click() js function to download csv file

}

}

}

 

I have to create lwc quick action to convert related contacts in to csv download. i had  created lwc quick action button and retrieved the data needed.there is problem in converting to csv. I have tried everything .below is my code. thanks in advance for any help.please help.

 

ERROR :-Cannot read properties of undefined (reading 'forEach')

 

#LWC Components  #LWC  #LWC Component  #Lightning Web Components  #Lightning  #LWC Development  #Custom LWC  #LWC Javascript Files

2 Antworten
  1. 27. Okt. 2021, 04:45

    import { LightningElement, api, wire, track } from 'lwc';

    import retrieveContacts from '@salesforce/apex/downloadContcatApexClass.retrieveContactMethod';

    export default class DownloadContacts extends LightningElement {

    @api recordId;

    @track contacts;

    @track error;

    @api invoke(){

    retrieveContacts({ recordIdAccount: this.recordId })

    .then((result) => {

    console.log('line 12:' + result);

    this.contacts = result;

    this.error = undefined;

    var columnEnd = ',';

    var lineEnd = '\n';

    // Get the CSV header from the list.

    var keys = new Set();

    this.contacts.forEach(function (record) {

    Object.keys(record).forEach(function (key) {

    keys.add(key);

    });

    });

    keys = Array.from(keys);

    var csvString = '';

    csvString += keys.join(columnEnd);

    csvString += lineEnd;

    for (var i = 0; i < this.contacts.length; i++) {

    var counter = 0;

    for (var sTempkey in keys) {

    var skey = keys[sTempkey];

    // add , after every value except the first.

    if (counter > 0) {

    csvString += columnEnd;

    }

    // If the column is undefined, leave it as blank in the CSV file.

    var value = this.contacts[i][skey] === undefined ? '' : this.contacts[i][skey];

    csvString += '"' + value + '"';

    counter++;

    }

    csvString += lineEnd;

    var hiddenElement = document.createElement('a');

    hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);

    hiddenElement.target = '_self';

    //hiddenElement.download = component.get("v.fileName");

    document.body.appendChild(hiddenElement); //Required for FireFox browser

    hiddenElement.click(); // using click() js function to download csv file

    }

    })

    .catch((error) => {

    this.error = error;

    this.contacts = undefined;

    });

    }

    }

0/9000

I have Custom Quick Action button (Create_Record)

Action Type: Create a Record

 

I also have Lightning Web Component - Quick Action button on the same object. 

to perform some calculations.

 

Goal: I need to navigate from lwc to custom Quick Action button.

 

How to navigate from Lwc Quick Action to Custom Quick action button?

 

this won't work... this works only for new,edit,view..etc

 

What's the right way of doing this?

 

#LWC Component  #LWC  #LWC Development  #Custom LWC

2 Antworten
  1. Khyati Mehta (Speridian Technologies) Forum Ambassador
    23. Okt. 2021, 04:27

    Hi Amar,

     

    Do you've any outstanding questions on this which I can help you with?

0/9000

My below code is working fine, however, while creating a new child record, parentid is not populating automatically, again I am selecting to add that child record to parent, can anyone help me out. For example, in the account record related list if we create contact record automatically that specific accountid(name) will come on the record detail page of contact. Same functionality I need in my below component. can anyone help me out?

 

Template:

<template>

<lightning-card title={titleWithCount} icon-name="standard:record">

<lightning-button label="New" slot="actions" onclick={createNew}></lightning-button>

<div slot="footer">

<div if:true={countBool}>

<lightning-button label="View All" onclick={navigateToRelatedList}></lightning-button>

</div>

</div>

<div class="slds-m-around_medium">

<div if:true={listRecords}>

<template for:each={listRecords} for:item="rec">

<div key={rec.Id} class="slds-box">

<lightning-record-view-form record-id={rec.id} object-api-name={objectName}>

<div class="slds-grid">

<div class="slds-col slds-size_1-of-2">

<lightning-output-field field-name={field1}></lightning-output-field>

<lightning-output-field field-name={field2}></lightning-output-field>

</div>

<div class="slds-col slds-size_1-of-2">

<lightning-output-field field-name={field3}></lightning-output-field>

<lightning-output-field field-name={field4}></lightning-output-field>

</div>

</div>

</lightning-record-view-form><br/><br/>

</div>

</template>

</div>

</div>

</lightning-card>

</template>

JS:

import { LightningElement, api, wire, track } from 'lwc';

import fetchRecords from '@salesforce/apex/RelatedListController.fetchRecords';

import { NavigationMixin } from 'lightning/navigation';

export default class RelatedList extends NavigationMixin( LightningElement ) {

@api objectName;

@api parentObjectName;

@api fieldName;

@api fieldValue;

@api parentFieldAPIName;

@api recordId;

@api strTitle;

@api filterType;

@api operator;

@api fieldsList;

@api relationshipApiName;

@track field1;

@track field2;

@track field3;

@track field4;

@track listRecords;

@track titleWithCount;

@track countBool = false;

//@api recordid;

connectedCallback() {

var listFields = this.fieldsList.split( ',' );

console.log( 'Fields are ' + listFields );

this.field1 = listFields[ 0 ].trim();

this.field2 = listFields[ 1 ].trim();

this.field3 = listFields[ 2 ].trim();

this.field4 = listFields[ 3 ].trim();

console.log( 'Field 1 is ' + this.field1 );

console.log( 'Field 2 is ' + this.field2 );

console.log( 'Field 3 is ' + this.field3 );

console.log( 'Field 4 is ' + this.field4 );

}

get vals() {

return this.recordId + '-' + this.objectName + '-' +

this.parentFieldAPIName + '-' + this.fieldName + '-' +

this.fieldValue + '-' + this.filterType + '-' + this.operator + '-' + this.fieldsList;

}

@wire(fetchRecords, { listValues: '$vals' })

accountData( { error, data } ) {

if ( data ) {

this.listRecords = data.listRecords;

console.log(JSON.stringify(this.listRecords));

if ( data.recordCount ) {

if ( data.recordCount > 3 ) {

this.titleWithCount = this.strTitle + '(3+)';

this.countBool = true;

} else {

this.countBool = false;

this.titleWithCount = this.strTitle + '(' + data.recordCount + ')';

}

}

}

}

createNew() {

this[NavigationMixin.Navigate]({

type: 'standard__objectPage',

attributes: {

objectApiName: this.objectName,

actionName: 'new'

}

});

}

navigateToRelatedList() {

this[NavigationMixin.Navigate]({

type: 'standard__recordRelationshipPage',

attributes: {

recordId: this.recordId,

objectApiName: this.parentObjectName,

relationshipApiName: this.relationshipApiName,

actionName: 'view'

}

});

}

}

META:

<?xml version="1.0" encoding="UTF-8"?>

<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="RelatedList">

<apiVersion>52.0</apiVersion>

<isExposed>true</isExposed>

<targets>

<target>lightning__RecordPage</target>

</targets>

<targetConfigs>

<targetConfig targets="lightning__RecordPage">

<property name="strTitle" type="String" label="Title" description="Enter the title"/>

<property name="objectName" type="String" label="Object Name" description="Enter the object name"/>

<property name="parentObjectName" type="String" label="Parent Object Name" description="Enter the parent object name"/>

<property name="relationshipApiName" type="String" label="Relationship Name" description="Enter the relationship API name"/>

<property name="parentFieldAPIName" type="String" label="Parent Field API Name" description="Enter the parent field API Name"/>

<property name="fieldName" type="String" label="Field Name" description="Enter the field name"/>

<property name="fieldValue" type="String" label="Field Value" description="Enter the field value"/>

<property name="filterType" type="String" label="Filter Type" description="Enter the filter type"/>

<property name="operator" type="String" label="Operator" description="Enter the operator"/>

<property name="fieldsList" type="String" label="Fields List" description="Enter the field API names separated by coma. Do not enter more than 4 fields"/>

</targetConfig>

</targetConfigs>

</LightningComponentBundle>

#Lightning Web Components  #LWC  #LWC Development  #LWC Components  #Custom LWC  #Salesforce Developer  #Salesforce Developers  #Sales Cloud

1 Antwort
  1. Khyati Mehta (Speridian Technologies) Forum Ambassador
    22. Okt. 2021, 07:58

    Check if this thread helps you in any way:https://developer.salesforce.com/forums/?id=9060G000000UaqdQAC

0/9000

Hi Experts,

 

How to create  or edit a record based on the record type in LWC(component should be generic) can anyone help me out. 

 

#Lightning Web Components  #LWC  #LWC Component  #LWC Development  #LWC Components  #Custom LWC  #Salesforce Developer  #Sales Cloud

7 Antworten
  1. Lakhan Meghani (NA) Forum Ambassador
    22. Okt. 2021, 06:01

    Hi Aditya,

     

    I understand but i will recommend to confirm the design may be the way i suggested or something else.

    Secondly, you start learning and try to develop by your own.

    Last, this forum is always open for you to take any help 

     

    You can learn from LWC library

    https://developer.salesforce.com/docs/component-library/overview/components

0/9000