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

Embedded Service API scripting help for Salesforce Chat

$
0
0
  • I have setup Embedded Chats for Sales flow
  • So new chats will be linked to Leads
  • I am using Embedded Service API for overriding this behavior to implement my usecase
  • My use case -
    • When a new request is coming first lookup to existing Contacts if found then link it with chat
    • If existing Contacts not found then lookup to existing Leads
    • If no existing records are found then create new Lead
  • SF implements this usecase by default when Contacts are created by converting Leads
  • My client org is having Contacts which are not converted from Leads
  • So following script I am using to achieve my use case -
         embedded_svc.settings.extraPrechatInfo = [                {"entityName": "Contact" ,"saveToTranscript " : "ContactId","entityFieldMaps": [                        {"isExactMatch": true , "fieldName": "FirstName" , "doCreate": false , "doFind": true , "label": "First Name"} ,                        {"isExactMatch": true , "fieldName": "Email" , "doCreate": false , "doFind": true , "label": "Email"} ,                        {"isExactMatch": true , "fieldName": "LastName" , "doCreate": false , "doFind": true , "label": "Last Name"}                    ]                } ,                 {"entityName": "Lead" ,"saveToTranscript " : "LeadId","entityFieldMaps": [                        {"isExactMatch": true , "fieldName": "FirstName" , "doCreate": true , "doFind": true , "label": "First Name"} ,                        {"isExactMatch": true , "fieldName": "Email" , "doCreate": true , "doFind": true , "label": "Email"} ,                        {"isExactMatch": true , "fieldName": "LastName" , "doCreate": true , "doFind": true , "label": "Last Name"}                    ]                }            ];
  • This script work fine for Existing Leads and new Leads, but when existing Contacts are coming from Chats then it creates a new Lead (a extra record)

I am not sure this approach will implement my requirement, open for any suggestion / helpThanks in advance


Enhanced Notes in salesforce Lightning

$
0
0

We have enabled the Enhanced Notes in our Instance and added the related list in to the page layout. When our users add a note using the enhanced notes other users can only view them and cannot edit them. By default the permission on the note is set to Read only for the other users

enter image description here

Is there some setting that we need to enable to have our users edit the notes. We tried sharing the notes even then the default role we see when sharing is the Viewer. Any help is greatly appreciated

Quick Action on related list

$
0
0

In lightning you are not able to do URL hacking. In order to do any prepopulation of fields, it is suggested to use a quick action.

If we have a related list object and we are trying to prepopulate the object of the related list, we would make a quick action and remove the "New" button. However, to a user, this will probably be very confusing since sometimes the new button is on the related list, sometimes you have to go to the top right/highlights panel to find the quick action button. Is there anyway to standardize both quick action and "new" button?

The link below mentions that it is not possible to put the quick action onto the related list.

https://success.salesforce.com/answers?id=9063A000000pDJlQAM

I thought about the idea of overriding the "New" button to call a quick action, but that doesn't seem to be possible.

Any suggestions is greatly appreciated!

Email Author in Lightning Experience : URL Hacking, Spring 20

$
0
0

Is there a way to open the Email Author Layout with pre defined email template in Lightning Experience. I know that earlier we don't have the possibility to do this since LEX was not supporting the URL hacks. But as per spring 20, LEX is supporting the URL Hacks.

Classic : /_ui/core/email/author/EmailAuthor?rtype=003&p3_lkid={!Opportunity.Id}&retURL=/{!Opportunity.Id}&p24=Reporters@WizardNews.com&template_id=00X40000001XQwz

What is the equivalent url for Lighting Experience ??

openUtility on case change event

$
0
0

I am working on an utility bar component that displays a form to agents to give feedback (See feedback utility in the left bottom of the picture). I want to open the utility on case closed event (without agent manually clicking the utility component). Workflow is as below:

Agent close case -> auto open the utility -> Agent answer questions and click submit button -> minimize utility on submit button click

utilityBarAPI provides a method called openUtility to open the utility. I am having trouble figuring out a way to open the utility when a case is closed. This is in the salesforce lightning experience.

Options I explored:

  1. Create an Apex trigger that captures case closed event and call the openUtility method in it. But I didn't find a way to make UI changes from backend triggers. I am not sure if this is even supported.

  2. Create a custom button to close a case. When the button is clicked, call the openUtility method. The problem here is there are multiple ways to close cases like (change status field directly, button click etc). How would I cover all these options?

  3. Create an Apex trigger and send platform event. UI component would listen on the event and open the form. This seems most achievable but there is a problem:

    Imagine 2 agents in an org working on cases and both have this component. When Agent 1 closes Case 1, the components in both Agent browsers will listen to the event and open the feedback form. But I only want the Agent 1 component to open as he/she closed the case. Agent 2 should not see any changes in his browser/component due to this particular event. Similarly when Agent 2 close a case, only he/she should see the utility bar open up and display the form.

The final solution should work in both Cases page layout and single case layout.

If someone has better ways to solve this problem, I would like to know. Let me know if you need more information. Thank you.

If this use case is not possible with utility bar component, I am open to using other custom components or pop-up modals etc.

Feedback widget

how to capture onchange field value in record edit from LWC

$
0
0

I am trying to clone a record by using recordeditform in LWC. On quick action click i am populating record fields.

If a user is changing value on Text__c field and keeping name field as it is, how to get the changed field value and not changed field value in this.oppRecord variable and send it to apex.

currently even if i change value, i am getting the old value.

HTML

<lightning-record-edit-form layout-type="Full" record-id={recordId} object-api-name="Opportunity" onload={handleonLoad}><lightning-layout multiple-rows="true"><lightning-layout-item padding="horizontal-small" size="6"><lightning-input-field data-field="Name" field-name="Name"></lightning-input-field></lightning-layout-item><lightning-layout-item padding="horizontal-small" size="6"><lightning-input-field data-field="Text__c" field-name="Text__c" onchange={handlechange}></lightning-input-field></lightning-layout-item></lightning-record-edit-form><footer><div class="modal-footer slds-modal__footer attach-to-bottom">&nbsp;&nbsp;&nbsp;&nbsp;<lightning-button variant="brand" label="Save" onclick={insertCloneOpp}></lightning-button></div></footer>

JS

handleonLoad(event) {        if (!this.loadedForm) {            let fields = Object.values(event.detail.records)[0].fields;            const recordId = Object.keys(event.detail.records)[0];            console.log(this.recordTypeName);            this.oppRecord = {                Id: recordId,                ...Object.keys(fields)                    .filter((field) => !!this.template.querySelector(`[data-field=${field}]`))                    .reduce((total, field) => {                        total[field] = fields[field].value;                        return total;                    }, {})            };            this.loadedForm = true;        }    }    handlechange(event) {    cosole.log(event.target.value);   }    insertCloneOpp() {        console.log('Opp', JSON.stringify(this.oppRecord));    }

Error message from server side controller lightning

$
0
0

Hi i want the error message to be displayed, i am getting value in response.getError() function, i want message argument in this function.Below is the snippet of how i'm doing, i am getting undefined in str console statement.

JS

  var errors = response.getError();           if (errors) {  var str = errors[0].message;  console.log('str'+ JSON.stringify(str));  component.set("v.Error", str);  console.log('Here cmp'+ component.get("v.Error")); }

Image stored in Static resource not getting displayed in lightning component

$
0
0

I have a lightning component that shows the image of a car from the static resource. I have uploaded this zip file which contains images of cars as a Static resource. following is the code of the lightning component.

<aura:component implements="flexipage:availableForAllPageTypes" access="global" ><aura:attribute name ="car" type="Car__c" access="public"                     default= "{'sObjectType' : 'Car__c','Name' : 'Aditya','Picture__c' : '/resource/cars/luxury/ford_mustang.jpeg'}"/><lightning:button variant="neutral" ><div style="{# 'background-image:url('+ v.car.Picture__c +') '}" class="innertile"><div class="lower-third"><h1 class="slds-truncate">{!v.car.Contact__r.Name}</h1></div></div></lightning:button></aura:component>

and CSS file

.THIS .tile{    position:relative;    display:inline-block;    width:100%;    height:500px;    padding: 1px !important;}.THIS .innertile{    background-size:cover;    background-position:center;    background-repeat:no-repeat;    width:100%;    height:100%;}.THIS .lower-third {    position:absolute;    bottom:0;    left:0;    right:0;    color:#FFFFFF;    background-color:rgba(0,0,0, .4);    padding:6px 8px;}

Note: Picture__c is a URL(255) field.

and when I run the code, the image is not getting displayed. Please refer to the below screenshot.enter image description here

am I missing anything? Please advise.


Lightning Component for quick action

$
0
0

I built a lightning component to make some changes to Lead Record and I added it as a quick action.

This is my helper.js:

changeOwnerAction : function(cmp,event) {    var recordId = cmp.get("v.recordId");    var action = cmp.get("c.changeOwnerForSelectedRecord");    action.setParams({        recordId : recordId    });    action.setCallback(this,function(res){        var state = res.getState();        if(state === "SUCCESS"){            //do something        }    });    $A.enqueueAction(action);},closeAction: function(cmp, event){     var recordId = cmp.get("v.recordId");    var sObectEvent = $A.get("e.force:navigateToSObject");        sObectEvent .setParams({"recordId": recordId,"slideDevName": "detail"    });    sObectEvent.fire(); }

And the controller calls those functions one after another:

doInit : function(component, event, helper) {    helper.changeOwnerAction(component,event);    helper.closeAction(component,event);}

The doInit is used in an handler:

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

At the end of the action the modal still shows for just a second but I've to wait few seconds to get the update available in the detail view as well as in the Lead state wizard.

has anyone else faced this issue?

Not able to access record in lightning but able to in classic

$
0
0

I'm able to access records of a custom object in salesforce classic and also in lightning. But recently i'm seeing

Looks like there's a problem.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.

But i'm able to access the same record in classic though. When i login as different user with same profile i'm able to access the record in lightning, not with my user though.

Refresh lightning component from Visualforce Page on button click

$
0
0

I have a lightning component that is placed on Visualforce Page via lightning out. I have a button on Visualforce Page on click on which the lightning component should refresh.

Is there a way I can achieve this?

Not able to access event.currentTarget when locker service is enabled

$
0
0

There's a question already asked regarding this here Issue with event.currentTarget

According to Salesforce Known Issues , they've updated that it has already been fixed in almost all the servers (except eight as of now). But, for me it's still not working (it has already been shown as fixed in the instance I'm working on).

My code is as follows:-

Component:-

<div class="slds-form-element__icon" onclick ="{!c.displayPopup}">

Controller:-

displayPopup : function(component) {        component.set("v.isDisplayPopup", true);    }

Renderer:-

({    rerender: function(component, helper) {        this.superRerender();           helper.renderPopup(component, helper);    }   })

Helper:-

renderPopup : function(component, helper) {        if(component.isValid() && component.get("v.isDisplayPopup")) {                      var selectedItem = event.currentTarget;            var svgElement = selectedItem.querySelector("svg");            var scrollableWrapElement = document.getElementsByClassName('scrollableWrap')[0];                                               var position = this.getPosition(svgElement);            var wrapperPosition = this.getPosition(scrollableWrapElement);            var notesPanelComponent = component.find('notesPanel').getElement();            var noteObject = notesPanelComponent.querySelectorAll("div")[selectedItem.dataset.rownumber];                        for(var i=0; i<document.querySelectorAll(".notes").length-1; i = i + 1){                document.querySelectorAll(".notes:not(#\\3"+noteObject.id+")")[i].classList.remove('slds-visible');                    document.querySelectorAll(".notes:not(#\\3"+noteObject.id+")")[i].classList.add('slds-hidden');                     }            noteObject.classList.toggle('slds-visible');            noteObject.style.top = position.top - wrapperPosition.top + 35+"px";            noteObject.style.left = position.left - wrapperPosition.left -127+"px";            component.set("v.isDisplayNotes", false);        }}

When I click on that particular, it throws an error saying [TypeError: Cannot read property 'currentTarget' of undefined]

The event is undefined!

Can anyone tell me why am I not able to access the same here?

Is there any way so that I would be able to access the clicked DOM element from helper?

PS:- I'm trying to access the event.currentTarget from the helper via renderer (and not directly from controller) is because DOM manipulation is involved(which cannot be done outside the rendering lifecycle as per the Lightning Developer Guide), once I get the DOM element.

$A.get('e.force:refreshView').fire();t view is not working in mobile

$
0
0

Please provide alternate solution for $A.get('e.force:refreshView').fire(); in mobile

How to open VF page in lightning Experience using URL link?

$
0
0

Is there a way to open VF page in lightning experience using URL link?. I know we can use sforce.one.navigateToURL but in our case it would not work because The URL link is outside the salesforce.

Use case

  • We are sending an vf page link in the email some thing like <a href="https://na16.visual.force.com/apex/myTask"> Click Here</a>. this is working fine with classic but we are facing the issue if user is in lightning experience.

Issue

  • If user is in lightning experience then this URL link is not working as expected. It's open the VF page but without one.app container.

I have attached the screen short of both classic and lightning experience output.

If user is in classic then URL Link open below screen

enter image description here

If user is in lightning experience then URL Link open below screen

enter image description here

Expected output in lightning experience

enter image description here

Is there any way to get expected output?

(Properly) Link to custom Lightning App from record detail page?

$
0
0

I have a custom lightning app.

How can I link to this app from a record's detail LEX page (e.g. Opportunity) and pass the Opp's ID to it?The end-user is supposed to launch the app and do some additional Opportunity-stuff.

I've tried this so far:

  1. Create a custom button (type = URL). Content:

    {!URLFOR('/c/OppAwesomizer.app?opp='+ Opportunity.Id )}

The button/action shows up on the Opp's detail page (in LEX), but...

So e.g. my Chrome just displays a blank area and the console shows this message:

Uncaught SecurityError: Failed to read the 'sessionStorage' property from 'Window': Access is denied for this document.

  1. Create a custom action to a LEX-enabled VF page that redirects to the app: Same behaviour as above...

Any help is greatly appreciated, I don't think SF has no way to achieve this but I have not been able to find anything on this...


Refresh the page after flow completes

$
0
0

I am trying to refresh the page once the flow is completed using the lightning component I downloaded from here https://unofficialsf.com/update-screen/ but it doesnt refresh the page. I am not sure what I am missing here. Below is the flow where Screen is the where I have the users choose from picklist option

enter image description here

enter image description hereAnd I am calling the flow through URL button like

/flow/Transfer_Case_TIS?recordId={!Case.Id}&retURL={!Case.Id}

enter image description here

but when the flow is executed the and the record is updated it comes back to the record page but it is not refreshed. I am not sure what I am missing here.

When I debug I see that recordId is passed to the lightning component and there are no errors

enter image description here

enter image description here

Multiple instance of child component does not function the same in For:Each in LWC

$
0
0

I have a lwc in which I have a lookup field and pick-list field, where lookup field is a child component and pick-list field is standard lightning-input.

Here's the screenshot of the UI:

enter image description here

Problem is, I am only able to select value in the first instance of lookup field, and then I am not able to look up values in any further rows. It does call the methods when I click on the field or type something but does not call apex or search anything.

Here's the .html

<template for:each={itemList} for:item="item" for:index="index"><lightning-record-edit-form key={item.id} object-api-name=OpportunityTeamMember onsuccess={handleSuccess} onsubmit={handleSubmit} onerror={handleError}>             {item} &nbsp;{index}<div class="bodyContainer slds-scrollable"><template if:true={showSpinner}><div class="spinnerContainer"><lightning-spinner alternative-text="Loading..." size="large" variant="brand"></lightning-spinner></div></template><div class="slds-section slds-is-open slds-m-top_xxx-small slds-m-right_x-small slds-m-left_x-small slds-p-right_x-small slds-p-left_x-small"><div class="slds-section__content"><div class="slds-form slds-form_stacked"><lightning-layout class="slds-wrap" horizontal-align="spread" multiple-rows="true"><lightning-layout-item size="5" class="slds-p-horizontal_xxx-small"><div key={item.id} class="slds-form-element slds-form-element_edit"><c-lookup                                            selection={userSelection}                                            errors={errors}                                            onfocus={handleLookupFocus}                                            onsearch={handleSearch}                                            onselectionchange={handleSelectionChange}                                            label="User Id"                                            placeholder="Search User..."                                            is-multi-entry={isMultiEntry}                                            required></c-lookup></div></lightning-layout-item><lightning-layout-item size="5" class="slds-p-horizontal_xxx-small"><div class="slds-form-element slds-form-element_edit"><lightning-input-field                                                 data-inputname="teamRoleField"                                                field-name="TeamMemberRole"                                                name="Role"                                                value={role}                                                variant="label-stacked"                                                required></lightning-input-field><br/><br/><br/><br/><br/></div></lightning-layout-item><lightning-layout-item size="2"                                    padding="around-small"><div><lightning-icon class="slds-var-m-around_xx-small" icon-name="action:new" access-key={item.id} id={index}                                        alternative-text="Add Row" size="small" title="Add Row" onclick={addRow}></lightning-icon><lightning-icon class="slds-var-m-around_xx-small" icon-name="action:delete" access-key={item.id} id={index}                                        alternative-text="Delete Row" size="small" title="Delete Row" onclick={removeRow}></lightning-icon></div></lightning-layout-item></lightning-layout></div></div></div></div></lightning-record-edit-form></template>

.JS

@track itemList = [        {            id: 0,            user:[],            role:''        }    ];addRow() {++this.keyIndex;        var newItem = [{ id: this.keyIndex, user:[], role:'' }];        this.itemList = this.itemList.concat(newItem);    }    removeRow(event) {        if (this.itemList.length >= 2) {            this.itemList = this.itemList.filter(function (element) {                return parseInt(element.id) !== parseInt(event.target.accessKey);            });        }    }    handleLookupFocus(event){        console.log(' in focus');        if (event.detail.hasSearchInput) {            return;        }        getRecent()            .then((results) => {                this.template.querySelector('c-lookup').setSearchResults(results);            })            .catch((error) => {                this.notifyUser('Lookup Error', 'An error occured while searching with the lookup field.', 'error');                // eslint-disable-next-line no-console                this.errors = [error];            });    }    handleSearch(event) {        console.log('handle search');        apexSearch(event.detail)            .then((results) => {                this.template.querySelector('c-lookup').setSearchResults(results);            })            .catch((error) => {                this.notifyUser('Lookup Error', 'An error occured while searching with the lookup field.', 'error');                console.error('Lookup search error', JSON.stringify(error));                this.errors = [error];            });    }    //sets the selection in the Lookup field and the selected user's id    handleSelectionChange(event){        this.userSelection = this.template.querySelector('c-lookup').getSelection();        this.userId = (this.userSelection && this.userSelection.length) ? this.userSelection[0].id : undefined;    }

How do I Initiate the lookup component again in the new row and get the search result to work?

Lightning component does not refresh

$
0
0

I have modified new button on a custom object (which is a child object to case object) to open a lightning component where it either chooses a contact or create one and then i have used below code to open the standard page layout of that custom object. The user goes to a case and go to that child object and click new which opens our lightning component and selects a contact and click next which opens child object new form with pre-populated information and he fills or modifies his data and saves that new record.

var createRecordEvent = $A.get("e.force:createRecord");

        createRecordEvent.setParams({"entityApiName" : custom objectname,"recordTypeId" : customobjectreocrdtypeid,"defaultFieldValues" : {             }        });        createRecordEvent.fire();

Then, user goes to another case and go to related tab and click new button on that custom object again they see the data of previous case instead of the new one.

How do i refresh every time they click on new ?

Change the Case tabs to the Subject instead of the Case Number in Lightning(Service Cloud)

$
0
0

Is there anyway to change the Case tab title to the SUBJECT instead of the CASE NUMBER in Lightning(Service Cloud)?

Please see below snapshot.Using Lightning Service Cloud

Your help will be highly appreciated.

Thanks in advance!

Lightning Action to VisualForce Page. Why opens in new Window?

$
0
0

I have lightning action set to open VF page. But not sure why it is opening into new browser window. Is there any hidden configuration? i do not see any navigation rule on Lightning action edit page.

enter image description here

Viewing all 2964 articles
Browse latest View live


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