Quantcast
Channel: Active questions tagged lightning-experience - Salesforce Stack Exchange
Viewing all 2967 articles
Browse latest View live

lightning:recordViewForm and force:recordData refresh issues

$
0
0

I'm having TestObject as parent object and New Custom Object having M-D relationship to it. TestObject having Min and Max Rollup summary fields which will rollup number field in child object.

I was rendering parent information using lightning:recordViewForm And force:recordData date service with certain fields, if we perform any dml in child need to refresh the parent record information.

Here's my Markup code:

<aura:component controller="MyCustomController" access="global"><aura:attribute name="records" type="List" access="public" default="[]" /><aura:attribute name="fields" type="List" access="public" default="Name,Max__c,Min__c" /><aura:attribute name="testObject" type="Map" access="public" default="{}" /><aura:attribute name="record" type="Map" access="public"/><aura:attribute name="recordError" type="String" access="public"/><aura:handler name="init" value="{!this}" action="{!c.doInit}" /><div>       <lightning:recordViewForm recordId="a0G2800000KJxZp" objectApiName="TestObject__c"><lightning:layout class=" slds-wrap custom-layout"><lightning:layoutItem size="4" padding="around-small"><lightning:outputField fieldName="Name" class="output-element"/></lightning:layoutItem><lightning:layoutItem size="4" padding="around-small"><lightning:outputField fieldName="Max__c" class="output-element"/></lightning:layoutItem><lightning:layoutItem size="4" padding="around-small"><lightning:outputField fieldName="Min__c" class="output-element"/></lightning:layoutItem></lightning:layout></lightning:recordViewForm><div class="slds-box " style="padding:0px !important;"><lightning:button label="Save" variant="brand" onclick="{!c.update}" class="slds-m-right_medium" /><table class="slds-table slds-table_bordered slds-table_fixed-layout" > <thead><tr class="slds-text-title_caps"><th scope="col"><div class="slds-truncate" title="Name">Name</div></th><th scope="col"><div class="slds-truncate" title="Number">Number</div></th><th scope="col"><div class="slds-truncate" title=" Total"> Total</div></th></tr></thead>   <tbody class="milestone-list"> <aura:iteration items="{!v.records}" var="record" indexVar="index"><tr> <td><div class="slds-truncate" ><ui:inputText value="{!record.Name}" /></div></td><td><div class="slds-truncate" ><ui:inputCurrency value="{!record.Number__c}" /></div></td><td><div class="slds-truncate" ><ui:outputCurrency value="{!record.Number_Sum__c }" /></div></td></tr></aura:iteration></tbody></table></div><force:recordData aura:id="recordData"                              recordId="a0G2800000KJxZp"                              fields="{!v.fields}"                              targetRecord="{!v.record}"                              targetFields="{!v.testObject}"                              targetError="{!v.recordError}"                              mode="EDIT"                               recordUpdated="{!c.recordUpdated}"/> </div></aura:component>

I'm rendering the child records underneath the recordViewForm, when the child records updated i just want to refresh the parent record details.

Here's my controller code:

update : function(component, event, helper) {    var action = component.get("c.updateParentValues");    action.setParams({'updateList': component.get("v.records")    });    action.setCallback(this, function(response) {        var state = response.getState();        if (state === "SUCCESS") {            component.set("v.records", response.getReturnValue());            console.log('recordData-->', component.find("recordData"));            component.find("recordData").reloadRecord();            console.log('*** refresh is done');        }    });    $A.enqueueAction(action);},recordUpdated : function(component, event, helper) {    var changeType = event.getParams().changeType;    console.log('**** change type-->', changeType);    if (changeType === "CHANGED") {         component.find("recordData").reloadRecord();    } }

Technically it should reload the record with this statement component.find("recordData").reloadRecord(), but it's not.

enter image description hereBut in console if i store the value of the data service to the temp variable and ran this temp1.reloadRecord();, now the content is get refreshed.enter image description here

Is there anything i'm missing here. Any ideas or suggestions are greatly appreciated.


Link to a library directory in Files in Lightning Experience

$
0
0

I am doing a Lightning remediation for a client moving over from Classic. They have a home page component that has a link pointing to a library directory in Files, not a specific File, but just a directory under Libraries. How does one obtain this URL and link to it in Lightning? I've googled around and have found just about everything EXCEPT what I am looking for. Any ideas? Please and thanks!

Lightning component failing for users of specific profiles?

$
0
0

I have faced this issue for the first time ever. I have a custom button on clicking of which a lightning component gets open. It is working fine for system admin + user of specific profiles.

But for users of certain profile, clicking on the component throws the attached screen. The error which comes up is as follows :

This page has an error. You might just need to refresh it. First, would you give us some details? (We're reporting this as error ID: )

Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details.An internal server error has occurredError ID: 2094392832-34943 (-159444901)quickActionHandlerHelper.js failed to create component - forceChatter:lightningComponent

Please help me to get this issue resolved, this is a show stopper for my application.

enter image description here

Callback failed Error for Lightning Aura Component

$
0
0

I am facing the below error for the Lightning component. I tried to debug but was not able to find the root cause.

This page has an error. You might just need to refresh it.Error in $A.getCallback() [ErrorAn internal server error has occurredError ID: 1410665541-125747 (-429116149)]Callback failed: apex://CarSearchController/ACTION$getCarsFailing descriptor: {markup://c:Base}

Following is the code:CarSearchResult.cmp

<aura:component implements="force:appHostable" extends="c:Base" access="global" controller="CarSearchController"><aura:attribute type="Car__c[]" name="cars" access="public"/><aura:attribute type="String" name="carTypeId" access="private" default=""/><aura:attribute type="boolean" name="carFound" access="private" default="false"/><aura:handler name="init" action="{!c.doInit}" value="{!this}"/><lightning:layout multipleRows="true" horizontalAlign="center"><aura:if isTrue="{!v.carFound}"><aura:iteration items="{!v.cars}" var="car"><lightning:layoutItem padding="around-small"                                       size="12"                                       smallDeviceSize="6"                                       mediumDeviceSize="4"                                       largeDeviceSize="3">                    {!car.Name}</lightning:layoutItem> </aura:iteration><aura:set attribute="else"><div class="slds-align_absolute-center">                    No Cars Found</div></aura:set></aura:if></lightning:layout></aura:component>

CarSearchResultHelper.js

({    onSearch : function(component,helper) {        console.log('before helper');        debugger;        helper.callServer(component,"c.getCars",                          function(response){                              console.log('in response function');                              if(response.length > 0){                                  console.log('in helper');                                  component.set("v.cars",response);                                  component.set("v.carFound",true);                              }else{                                  component.set("v.carFound",false);                              }                          },{                              carTypeId:'a0R7F00000iqPDsUAM'                          });    }})

BaseHelper.js

({    callServer : function(component,method,callback,params ) {        console.log('in base helper'+params);        var action = component.get(method);        if(params){            action.setParams(params);        }        console.log('in base helper action'+action);        action.setCallback(this,function(response){            var state = response.getState();            if(state === "SUCCESS"){                callback.call(this,response.getReturnValue());            }else if(state === "ERROR"){                var error = response.getError();                if(error){                    console.log("Errors"+error);                    if(error[0] && error[0].message){                        throw new Error("Error"+ error[0].message);                    }                }else{                   throw new Error("Unknown Error");                }            }        });        $A.enqueueAction(action);    }})

CarSearchController class

public with sharing class CarSearchController {    @AuraEnabled    public static List<Car__c> getCars(String carTypeId){        if(carTypeId.equalsIgnoreCase('')){            return[SELECT Id, Name, Build_Year__c, Car_Type__c, Contact__r.Name, Description__c,                   Geolocation__Latitude__s, Geolocation__Longitude__s,                   Geolocation__c, Mileage__c, Per_Day_Rent__c, Picture__c FROM Car__c where Available_For_Rent__c = true];        }else{            return[SELECT Id, Name, Build_Year__c, Car_Type__c, Contact__r.Name, Description__c,                   Geolocation__Latitude__s, Geolocation__Longitude__s,                   Geolocation__c, Mileage__c, Per_Day_Rent__c, Picture__c FROM Car__c where Available_For_Rent__c = true AND                    Car_Type__c = :carTypeId];        }    }}

Is the Potential Duplicate Standard Component also for Custom Objects on the roadmap?

$
0
0

I found that there is an Potential Duplicate Lightning Component (Standard) available for Lead, Accounts and Contacts. The components has also a merge process build in. This is very nice and important for Data Quality. However this component is not available for any Custom Objects or other standard objects. The process and the logic behind this should be very similar for any objects.

The components is the second in the right panel - the one with the yellow icon and the bold text.

enter image description here

Here is the documentation on that feature: https://help.salesforce.com/articleView?id=duplicates_existing_setup.htm&type=5

We have already created a custom lightning component for any objects (pink icon with the bell), but it is still buggy and the merge process is incomplete. Especially the merge is a lot of work and I found a strange behavior on DuplicateRecordItem (this is elaborated in this question here)

I want to plan ahead and avoid wasting time to create things which will eventually become available as standard.

So I would like to know if there is an update for this components on the roadmap which will be usable in the same manner, but for all objects - standard as well as custom? Any hint under Safeharbor is highly appreciated.

recordEditForm : event.preventDefault() not submitting the pre populated values in the form

$
0
0

I have a custom aura component for record creation. The onload() function calls the apex method to load values in the form. When I try to submit the form by using onsubmit(), the new record is created but its not showing the pre populated values on the new record created. I tried using event.preventDefault() and manually setting the field values in the onsubmit() handler, its not submitting the form, neither its creating a record, it throws an error saying that the record already exists with the lookup values.

In the form I'm doing the following lines of code to capture the values:

<lightning:inputField aura:id = "candidateSummaryField" feildName = "Candidate_Summary__c" /><lightning:inputField aura:id = "stageField" fieldName = "Stage__c"/>

In the controller in the onload() handler:

var stageFieldValue = component.find("stageField").set("v.value", "Contacted");var candidateSummaryFieldValue = component.find("candidateSummaryField").set("v.value", result[0]['Candidate_Summary__c']);

In the controller in the onsubmit() handler:

handleSubmit : function(component, event, helper) {        console.log("Inside handleSubmit");        event.preventDefault();        var fields = event.getParams('fields');        console.log("fields::::: "+JSON.stringify(fields));        fields['Candidate_Summary__c'] = 'New Candidate Summary';        fields['Stage__c'] = 'Contacted';        component.find("applicantForm").submit(fields);    }

Kindly suggest what I might be missing here, which is not allowing me to achieve record creation with already pre populated values from the form.

Thanks!

Remove a Global Quick Action from Salesforce 1 App Home Page

$
0
0

I am viewing my home page in sf1 app. There I can see a global action Called New Contact. What I want to understand is is there any way to remove it from Home page? I want to add a custom quick action instead

Append files to the first upload in

$
0
0

I am using the following code in my lightning component to upload multiple files

<lightning:input aura:id="fileId" onchange="{!c.handleUploadFinished}" type="file" name="file" label="Upload Attachment" multiple="true"/>

JS Controller Code handleUploadFinished: function (component, event, helper) {

    // Get the list of uploaded files    var fileInput = component.find("fileId").get("v.files");

}

  1. So what I can see is that if I upload 2 files together, then upload another one, the previous two files get removed. My question is that is there any possible way to append the 3 files together instead of the first two getting removed?

  2. My second question would be that can I assign the fileInput to an array attribute of the corresponding component? If so then what would be attribute type?

I am using the following blog as the base.http://sfdcmonkey.com/2017/09/25/file-upload-lightning-component


Rendering header menu for vf page in lightning experience

$
0
0

I have a vf page which needs to be visible in both classic and lightning experience. I added lightningStyleSheets="true" to enable lightning kind of styling in lightning experience for the page.

However, when the page is viewed in lightning experience, the sidebar and header get disappeared. I checked for it, so it's because the lightning experience overrides the sidebar and showheader to false by default.But how can we make this available in the lightning experience?I tried with "setup = true" . But this enables setup bar in classic only, and when tried in lightning experience, the classic setup gets visible.Has anyone worked on this?

enter image description here

Additional styles added to body tag in Lightning

$
0
0

In Lightning, we're getting some additional styles added to our body tag:

html body.sfdcBody {    font-family: 'Helvetica';    color: #3c3d3e;    background: none transparent;    margin: 0;    padding: 10px 20px 0 20px;    height: 100%;    overflow: auto;    -webkit-overflow-scrolling: touch;}

Coming from AuraAlohaContentFrame.css.

I raised an issue with the Lightning design guys, but they tell me it's not their doing.

the AuraAlohaContentFrame.css is not related to the Lightning Design System's CSS. I'm unsure of whether that may change or not.

We're reluctant to overwrite SF styles out of hand.

Would anyone have any extra information on these styles and why they're taking effect?

Service Cases: Email Quick Action Button/Tab Not Showing Up

$
0
0

I have read a lot of documentation on this, and feel like there's something simple that I am missing that is not allowing the email quick action button/tab to show up on my service case feeds. My company mainly uses Classic mode, and I (as an administrator) am using Lightning mode, but even when I switch back to Classic mode, the email quick action doesn't show up there either.

What I've done:

  1. Email-to-Case is enabled, and routing has been verified
  2. Email Deliverability access is set to All email
  3. Case object feed tracking is enabled
  4. Object Manager > Page Layouts > Account Layout: "Email" quick action field has been added
  5. Object Manager > Salesforce Cases > Salesforce Cases Page Layouts > Case Layout: "Email" quick action field has been added
  6. Double-checked my System Administrator account has "Send Outbound Messages" enabled
  7. My profile has Service Cloud Console checked
  8. Tried creating a new custom layout
  9. I have tested creating a case manually as well as emailing the routing address to create a case. Both work fine, but I can't respond to them.

Is there somewhere other than the Account Layout that I am supposed to add the quick action button? That is the only layout I'm finding.

LWC not refreshing related list count after creating new record

$
0
0

On contact object, the standard new button is overridden with a LWC component. From account object i try to create contact.

Before creating contact count is 1

enter image description here

After creating a contact, it sill show 1 m but actually its two

enter image description here

After clicking viewAll

enter image description here

Unless and untill i refresh the browser, the count won't get populated properly. I know this is a caching issue. But is there any workaround

HTML

<template><div class="slds-theme_default"><template if:true={openmodel}><div class="demo-only"><section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open"><div class="slds-modal__container"><header class="slds-modal__header"><button class="slds-button slds -button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeModal}><lightning-icon icon-name="utility:close" size="medium"></lightning-icon><span class="slds-assistive-text">Close</span></button><h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Test</h2></header><div class="slds-is-relative"><div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1" style="height: 50vh;"><div class="slds-p-around_x-small"><lightning-input label="FirstName" class="firstName"></lightning-input><lightning-input label="LastName" class="lastName"></lightning-input><lightning-input type="Phone" label="Phone" class="phone"></lightning-input><br /><lightning-input type="Email" label="Email" class="email"></lightning-input><br /><lightning-input label="Account" class="accountId" value={accId}></lightning-input><br /></div></div></div><footer class="slds-modal__footer"><lightning-button variant="brand" label="Save" onclick={handleClick}></lightning-button></footer></div></section><div class="slds-backdrop slds-backdrop_open"></div></div></template></div></template>

JS -

import {    LightningElement, track, api, wire} from 'lwc';import {    NavigationMixin} from "lightning/navigation";import CONTACT_OBJECT from '@salesforce/schema/Contact';import FIRSTNAME_FIELD from '@salesforce/schema/Contact.FirstName';import LASTNAME_FIELD from '@salesforce/schema/Contact.LastName';import PHONE_FIELD from '@salesforce/schema/Contact.Phone';import EMAIL_FIELD from '@salesforce/schema/Contact.Email';import ACCOUNTID_FIELD from '@salesforce/schema/Contact.AccountId';import {    createRecord} from 'lightning/uiRecordApi';export default class Modalspinner extends NavigationMixin(LightningElement) {    @track spinner;    @api recordId;    @track openmodel = true;    @track accId = '0012v00002InPVmAAN';    @track cntId;    handleClick() {        const fields = {};        fields[FIRSTNAME_FIELD.fieldApiName] = this.template.querySelector('.firstName').value;        fields[LASTNAME_FIELD.fieldApiName] = this.template.querySelector('.lastName').value;        fields[PHONE_FIELD.fieldApiName] = this.template.querySelector('.phone').value;        fields[EMAIL_FIELD.fieldApiName] = this.template.querySelector('.email').value;        fields[ACCOUNTID_FIELD.fieldApiName] = this.recordId;        const recordInput = {            apiName: CONTACT_OBJECT.objectApiName,            fields        };        createRecord(recordInput)            .then(result => {                this.message = result;                this.cntId = JSON.parse(JSON.stringify(this.message)).id;                this.redirect();            })    }    redirect() {        this[NavigationMixin.Navigate]({            type: 'standard__recordPage',            attributes: {                recordId: this.cntId,                objectApiName: 'Contact',                actionName: 'view'            },        });    }}

Lightning Email Template Attachment issue

$
0
0

I have created Lightning Email Template with attachment from my local system as System Admin user. This template displayed without attachment for Partner Community Profile user. How can we share the attachment for Partner Community Profile user.

lightning:spinner Overlay screen

$
0
0

How do I remove the white patch on overlay screen?

<div class="slds-align--absolute-center"><lightning:spinner aura:id="spinner" variant="brand" size="large" class="slds-hide"/></div>

JS:

saveNewRecord: function(component) {        var spinner = component.find('spinner');        $A.util.toggleClass(spinner, 'slds-show');    }

Issue:enter image description here

Refresh the page from the Lightning component

$
0
0

I am having the Lightning component that uses the Lightning Data Services to update the fields on the Case record, it works fine if the component is updating fields like status or origin like that. But when I try to update the record type/owner the page is not refreshed after the update happens.

Below is the component where I am updating the record type and Owner basically it is like transfering the case from one Dept to another

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global"  ><aura:attribute name="loaded" type="Boolean" default="false" /><lightning:spinner variant="brand" alternativeText="Loading..." class="{!(v.loaded? 'slds-show': 'slds-hide')}" /><lightning:recordEditForm aura:id="form"         objectApiName="Case"         recordId="{!v.recordId}"        onsubmit="{!c.handleSubmit}"        onerror="{!c.handleError}"        onsuccess="{!c.handleSuccess}"><lightning:inputField aura:id="statusInput" fieldName="Status" class="slds-hide" /><lightning:button variant="brand" type="submit" label="SF Support" /></lightning:recordEditForm>    </aura:component>

Controller

({    handleSubmit: function(component, event, helper) {        component.set('v.loaded',true);        event.preventDefault();              var fields = event.getParam('fields');        fields.OwnerId = 'xxxxxxxxxx'; // Owner is SF Support                   fields.RecordTypeId = 'YYYYYYYYYYYYY';        fields.Status = 'New';        console.log(JSON.stringify(fields));         component.find('form').submit(fields);    },    handleError: function(component, event, helper) {        component.set('v.loaded',false);        const fieldErrors = event.getParam('output').fieldErrors;        const separator = '';        let errMessage = Object.values(fieldErrors).map(field => {            return field.map(error => error.message).join(separator);        }).join(separator);        $A.get("e.force:showToast")        .setParams({            type: 'error',            mode: 'pester',            message: errMessage  }).fire();           },    handleSuccess: function(component, event, helper) {        component.set('v.loaded',false);        $A.get("e.force:showToast")        .setParams({            type: 'success',            message: 'Case passed to Salesforce Support!',            mode: 'pester'        })        .fire();    }})

Though the Owner/RecordType is updated the page is not refreshed. Below screesnshot shows the page is not refreshed , I should be seeing the Owner as SF Support but it still shows the old owner Services but Toast is fired saying the case is passed.

enter image description here

But when do the full page refresh it shows up SF Support. Can anyone please help me what I am missing here


Can I use SF Lightning quick action buttons to open a visualforce page?

$
0
0

I have a custom quick action button on a record detail page. onclick of it, I want to open a visualforce page.(The default behaviour opens a popup window).

Use lightning-formatted-date-time inside tag

$
0
0

I want to use <lightning-formatted-date-time> inside <a> tag but it displays Page doesn't exist.

I have a requirement to display code - name - formatted date as a url to point to the object.

My code is as follows :

<dd class="slds-item_detail slds-truncate"><a href="javascript:void(0);" onclick={handleView} title="View Detail" data-id={object.Id} class="link-style">        {object.Code__c} - {object.Name__c}<template if:true={object.Effective_Date__c}>           - <lightning-formatted-date-time              value={object.Effective_Date__c} year="numeric"              month="numeric" day="numeric"></lightning-formatted-date-time></template></a></dd>

When clicking on code or name the link redirects to the proper view, but on clicking on date part it says page doesn't exist, enter a valid url and try again.

Kindly help, I need to format the dynamic date to mm/dd/yyyy format and also it should point to the correct view on click.

DML Exception on send Email quick action

$
0
0

I am trying to send an email using existing default send Email quick action and once I hit the send button it prompts following error.

"Upsert failed. First exception on row 0; first error: MISSING_ARGUMENT, RecordID__c not specified: []"

I am pretty new to salesforce and could someone help me sort this out?

VSCODE for Salesforce Authorize org using session Id

$
0
0

I'm trying to Authorize my salesforce org to VSCODE using session Id as mentioned in the documentation. But it is not working. Can you please let me know what mistake I'm doing here.

  1. sfdx force:config:set instanceUrl=https://na35.salesforce.com (from documentation)
  2. sfdx force:mdapi:deploy --deploydir md-dir --targetusername access-token

Documentation link :https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_existing_access_token.htm

I'm getting the following error : ERROR runningforce:mdapi:deploy:report: Must pass a username and/or OAuth optionswhen creating an AuthInfo instance.

Below is the error

Why does lightning experience use a different url for svg icons?

$
0
0

It's great that stylesheets are included by default in lightning experiencem but where do we access the icon svg resources. Lightning experience loads the svg in what looks like a different way than we are provided with.

For example a lead icon url looks like this: "https://cs62.salesforce.com/img/icon/t4v35/standard/lead_120.png" how can we get access to the standard svg icons without loading static resources or is it best practice to load them from a static resource?

Viewing all 2967 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>