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

Salesforce: Drag & Drop not working in lightning web components or drop events are not triggering

$
0
0

I have a Lightning web component to drag one div into other dropzones (div). But the ondrop & ondragover events are not firing.

Here is my code

<template><div class="draggable" draggable="true" ondragstart={dragged} ondragend={enddragged}>        drag  item 1</div><div  ondrop={dropped} class="droppable" ondragover={allowDrop}  ></div><div  ondrop={dropped} class="droppable" ondragover={allowDrop}></div><div  ondrop={dropped} class="droppable" ondragover={allowDrop}  ></div><div ondrop={dropped} class="droppable" ondragover={allowDrop} ondragenter={dragEnter} onmouseover={onhover}></div>

and the js controller:

import { LightningElement } from 'lwc';export default class LwcTestDragANDDrop extends LightningElement {    constructor() {        super();        //register dragover event to the template        //this.template.addEventListener('dragover', this.allowDrop.bind(this));        console.log('constructor');    }    allowDrop(ev) {        console.log('over drag ');        ev.preventDefault();    }    dropped(ev) {                          console.log('on drop ');        ev.preventDefault();        /*let data = ev.dataTransfer.getData("text");        console.log('strt drag ');*/    }    dragged(ev) {        console.log('dragg start ');        ev.dataTransfer.setData("Text", 'ev.target.id');    }    enddragged(ev) {        console.log('dragg end ');    }    dragEnter(event) {        console.log(12);        event.target.style.border = "3px dotted red";    }    onhover(){        console.log('on hover');    }}

And the rendered UI:enter image description here

I wanted to drag the drag Item 1 to any of the below boxes.

The events ondrop={dropped} ondragover={allowDrop} are not firing. I have a requirement to use Firefox browser. Its working in Google chrome.

In raw JavaScript, the drag & drop is working. The only difference in LWC is the way of event binding

Am I missing anything? or not a proper HTML structure? how can I make it workable?


Sending wrapper object to apex controller from lightning component

$
0
0

I am trying to send a wrapper class from lightning component to Apex controller. But it is throwing following error:

This page has an error. You might just need to refresh it.Error in $A.getCallback() [Cannot read property 'name' of null]Failing descriptor: {ui:input}

Following are the classes and components:

Wrapper Class:

    public class WrapperAccountContact {        @AuraEnabled        public String name{get;set;}        @AuraEnabled        public String accountNumber{get;set;}    }

Apex Controller:

    public class CreateAccountContact {         @AuraEnabled        public static void createRecord (String candidates){            try{                System.debug('CreateCandidateRecord::createRecord::candidate'+candidates);                if(candidates != null){                    WrapperAccountContact obj = (WrapperAccountContact)JSON.deserialize(candidates, WrapperAccountContact.class);                    Account a = new Account();                    a.name = obj.Name;                    a.AccountNumber = obj.AccountNumber;                    insert a;                }            } catch (Exception ex){                System.debug('Exceptionnnn:'+ex);            }        }     }

JS Controller:

    ({        create : function(component, event, helper) {            console.log('Create record');            //getting the candidate information            var candidates = component.get("v.candidate");            //Validation            /*if($A.util.isEmpty(candidate.name) || $A.util.isUndefined(candidate.name)){                alert('Name is Required');                return;            }                        if($A.util.isEmpty(candidate.accountNumber) || $A.util.isUndefined(candidate.accountNumber)){                alert('AccountNumber is Required');                return;            }*/            //Calling the Apex Function            var action = component.get("c.createRecord");            //Setting the Apex Parameter           /* action.setParams({                candidate : candidate            });*/            action.setParams({ "candidates" : JSON.stringify(candidates) });            //Setting the Callback            action.setCallback(this,function(a){                //get the response state                var state = a.getState();                //check if result is successfull                if(state == "SUCCESS"){                    //Reset Form                    /*var newCandidate = {'sobjectType': 'WrapperAccountContact','name': '', 'accountNumber': ''                                       };                    //resetting the Values in the form                    component.set("v.candidate",newCandidate);*/                    alert('Record is Created Successfully');                } else if(state == "ERROR"){                    alert('Error in calling server side action');                }            });            //adds the server-side action to the queue                    $A.enqueueAction(action);        }    })

Lightning Component:

<aura:component controller="CreateAccountContact" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes"                access="global"><ltng:require styles="/resource/Bootstrap/Bootstrapzip/bootstrap.min.css"                  scripts="/resource/JQuery/jquery-3.3.1.min.js,/resource/Bootstrap/Bootstrapzip/bootstrap.min.js"/><aura:attribute name="candidate" type="WrapperAccountContact"/><div class="container-fluid"><h3>Please Enter Account Information</h3><div class="form-group"><label>Name</label><ui:inputText class="form-control" value="{!v.candidate.name}"/></div><div class="form-group"><label>AccountNumber</label><ui:inputText class="form-control" value="{!v.candidate.accountNumber}"/></div></div><div class="col-md-4 text-center"><ui:button class="btn btn-default" press="{!c.create}">Create Contact</ui:button></div>    </aura:component>

Please let me know if there is any problem with input tags of component and how to resolve the following error:

This page has an error. You might just need to refresh it.Error in $A.getCallback() [Cannot read property 'name' of null]Failing descriptor: {ui:input}

Thanks!

Page Layout in Change Set

$
0
0

I Added Page Layout to outbound change set, added profiles to change set and deployed it in Production but page layouts were unchanged in production. What is the reason?

Clickjack protection block VF Page in Lightning Component

$
0
0

I created VF page and a lightning component, then embed VF Page to lightning component. Like follow code:

<iframe src="/apex/MyTestPage" width="100%" frameBorder="0" />

In Session Settings my settings as follow imageenter image description here

I set Whitelisted Domains as followenter image description here

When I use this lightning component in Lightning App Builder I got a gray screen and show refused to connect error.

May I ask help for how to resolved this issue.

Best wishes,Lee

Download data as Excel File in Aura Component

$
0
0

I have a Lightning Component that renders data in a table. I currently have the logic that downloads as a CSV file. For some users,Excel is not auto formatting the file to display as Columns. So they want the file to be downloaded as an Xls or Xlsx file. I have done some research to see if there is a solution for downloading as an excel file on the client side itself but I couldn't find any. The logic that I currently have is below :

csvSample.cmp

<aura:component controller="csvDownloadCtrl">          <aura:handler name="init" value="{!this}" action="{!c.loadContactList}"/> <aura:attribute name="ListOfContact" type="contact[]"/> <div class="slds-m-around--xx-large">   <button class="slds-button slds-button--brand" onclick="{!c.downloadCsv}">Download As CSV</button> <br/><br/><table class="slds-table slds-table--bordered slds-table--cell-buffer"><thead><tr class="slds-text-title--caps"><th class="slds-is-sortable slds-text-title--caps" scope="col"><span class="slds-truncate" title="Name">First Name</span>  </th><th class="slds-is-sortable slds-text-title--caps" scope="col"><span class="slds-truncate" title="Last Name">Last Name</span></th><th class="slds-is-sortable slds-text-title--caps" scope="col"><span class="slds-truncate" title="Department">Department</span></th><th scope="col"><div class="slds-truncate" title="MobilePhone">Mobile Phone</div></th></tr></thead><!--table body start,       Iterate contact list as a <tr>     --><tbody><aura:iteration items="{!v.ListOfContact}" var="con">  <tr><th scope="row"><div class="slds-truncate" title="{!con.FirstName}">{!con.FirstName}</div></th><th scope="row"><div class="slds-truncate" title="{!con.LastName}">{!con.LastName}</div></th><th scope="row"><div class="slds-truncate" title="{!con.Department}">{!con.Department}</div></th><th scope="row"><div class="slds-truncate" title="{!con.MobilePhone}">{!con.MobilePhone}</div></th> </tr></aura:iteration></tbody></table> </div></aura:component>

csvSampleController.js:

({    loadContactList: function(component, event, helper){       helper.onLoad(component, event);    },    downloadCsv : function(component,event,helper){        var stockData = component.get("v.ListOfContact");        var csv = helper.convertArrayOfObjectsToCSV(component,stockData);            if (csv == null){return;}          var hiddenElement = document.createElement('a');          hiddenElement.href = 'data:text/csv;charset=utf-8,'+ encodeURI(csv);          hiddenElement.target = '_self';            hiddenElement.download = 'ExportData.csv';            document.body.appendChild(hiddenElement);          hiddenElement.click();         },  })

csvSampleHelper.js:

({   onLoad: function(component, event) {      var action = component.get('c.fetchContact');      action.setCallback(this, function(response){         var state = response.getState();         if (state === "SUCCESS") {            component.set('v.ListOfContact', response.getReturnValue());         }      });      $A.enqueueAction(action);   },   convertArrayOfObjectsToCSV : function(component,objectRecords){        var csvStringResult, counter, keys, columnDivider, lineDivider;        if (objectRecords == null || !objectRecords.length) {            return null;         }        columnDivider = ',';        lineDivider =  '\n';        keys = ['FirstName','LastName','Department','MobilePhone','Id' ];        csvStringResult = '';        csvStringResult += keys.join(columnDivider);        csvStringResult += lineDivider;        for(var i=0; i < objectRecords.length; i++){               counter = 0;             for(var sTempkey in keys) {                var skey = keys[sTempkey] ;                    if(counter > 0){                       csvStringResult += columnDivider;                    }                  csvStringResult += '"'+ objectRecords[i][skey]+'"';                counter++;            }              csvStringResult += lineDivider;          }         return csvStringResult;            },})

csvDownloadCtrl.apxc :

public class csvDownloadCtrl {@AuraEnabled   public static list <contact> fetchContact(){      List <contact> returnConList = new List < contact > ();      for(contact con: [SELECT firstName, LastName, Department, MobilePhone From contact LIMIT 1000]) {             returnConList.add(con);          }         return returnConList;   }}

PS : The data that is being downloaded is a list of Wrapper object. For keeping things simple I have added the Apex controller to return list of contacts. Also the use can filter the data on the component, So I have to download the data that is available on the Component after filtering.

Any help is greatly appreciated. Thanks

Handle error in Lightning Component using Lightning Data Service

$
0
0

I am having a lightning component that uses the Lightning Data services. The component is like below which has a button which when clicking on it changes the case status to Closed.

<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:spinner aura:id="spinner" variant="brand" /> --><lightning:inputField aura:id="statusInput" fieldName="Status" class="slds-hide" /><lightning:button variant="brand" type="submit" label="Close Case(LDS)" /></lightning:recordEditForm>    </aura:component>

And controller

({    handleSubmit: function(component, event, helper) {        component.set('v.loaded',true);        event.preventDefault();              var fields = event.getParam('fields');        fields.Status = 'Closed';        console.log(JSON.stringify(fields));         component.find('form').submit(fields);     },    handleError: function(component, event, helper) {        component.set('v.loaded',false);        $A.get("e.force:showToast")        .setParams({            type: 'error',            mode: 'pester',            message: 'Case cannot be closed, please verify the required fields like Category are filled !!' }).fire();      },    handleSuccess: function(component, event, helper) {        component.set('v.loaded',false);            $A.get("e.force:showToast")            .setParams({            type: 'success',            message: 'Case is closed!',            mode: 'pester'            })        .fire();    }})

I am currently in the handleError hard coding the error message but I am trying to get the errors from the Validation/ if something goes wrong instead of hard coding the errors. I tried to get the error

    var error = event.getParams();    // Get the error message    var errorMessage = event.getParam("message"); 

and give it in the message it just gives the generic error message in the toast likeenter image description hereinstead I should be getting the validation error

A Category is required to close the case.

How to get the Validation errors in to the lightning component from the Lightning Data Services.

enter image description here

lightning:menuItem in lightning:buttonMenu is not working in a nested component

$
0
0

I have two lightning components. One gets account's basic information on load and iterates over it and another displays the each account's basic information in a row. I have explained the div tag after the code snippet

Here's the code: viewAccountsList.cmp

<aura:iteration items="{!v.accountsList}" var="account" indexVar="i"><c:accountListItem account="{!account}" /></aura:iteration><div class="slds-truncate" title="Actions"><lightning:buttonMenu alternativeText="Toggle menu"><lightning:menuItem label="Some Account Action" value="someAction" iconName="utility:table" /></lightning:buttonMenu></div>

accountListItem.cmp

<table class="slds-table slds-table_bordered"><thead><th scope="col"><div class="slds-truncate slds-text-heading_small" title="Account Name">Account Name</div></th><th scope="col"><div class="slds-truncate slds-text-heading_small" title="Account Status">Account Status</div></th><th scope="col"><div class="slds-truncate slds-text-heading_small" title="Account Balance">Account Balance</div></th><th scope="col"><div class="slds-truncate slds-text-heading_small" title="Account Balance">Actions</div></th></thead><tbody><td data-label="Account Name"><div class="slds-truncate" title="Account Name">                    {!v.account.name}</div></td><td data-label="Account Status"><div class="slds-truncate" title="Account Status">{!v.account.status}</div></td><td data-label="Account Balance"><div class="slds-truncate" title="Account Balance">{!v.account.balance}</div></td><td data-label="Account Balance"><div class="slds-truncate" title="Actions"><lightning:buttonMenu alternativeText="Toggle menu"><lightning:menuItem label="Some Account Action" value="someAction" iconName="utility:table" /></lightning:buttonMenu></div></td></tbody></table>

I want to add a lightning:buttonMenu to do additional operations on the account in the child component. The last div tag in the child component doesn't show the menuItem but the same div tag in the parent component does.

Why is this happening?

How to increase the list size on button click on lightning component?

$
0
0

Below is my code .please do let me know how to increase the size of the list on my component on button click?Right now it is replacing the previous value . I want to add the new value to the existing array.

Component :-<lightning:layout ><aura:iteration items="{!v.ArrLst}" var="item"><lightning:layoutItem padding="around-small">                   {!item.id}</lightning:layoutItem><lightning:layoutItem padding="around-small">                   {!item.Name}</lightning:layoutItem></aura:iteration></lightning:layout><lightning:input aura:id="inpId" value=""/><lightning:button label="Add" onclick="{!c.addIt}"/>Controller :-    addIt : function(component, event, helper) {        var arrTsk=[];        arrTsk.push({id:'123',Name:component.find('inpId').get("v.value")});        alert(JSON.stringify(arrTsk));        component.set("v.ArrLst",arrTsk);                   }

Adding Lightning Components Tab To The Existing Sales App

$
0
0

I have created a lightning components tab and wanted to surface it to users by adding to the Sales app but users are not seeing it. However If they go to App Launcher--> Other Items, they see the tab. However If I create a new custom app and add the tab, they see the tab as part of the custom app.

Can't we add Lightning Components Tab to existing apps like Sales? Should we always a custom app to surface lightning components tabs.

Would appreciate any feedback.

how to set default value with force:inputField?

$
0
0

Cant set default value for the lookup

enter image description here

<aura:component controller="OverrideNewMaterialController" implements="lightning:actionOverride,flexipage:availableForRecordHome,force:hasRecordId" access="global"><aura:attribute name="oppId" type="id" /><aura:attribute name="tab" type="Tabla_para_exposicion__c" default="{'sobjectType':'Tabla_para_exposicion__c'}"/>display: {!v.tab.Exposicion__c}<br></br><aura:handler name="init" value="{!this}" action="{!c.doInit}" /><force:inputField aura:id="lookup" value="{!v.tab.Exposicion__c}" required="true" class="slds-size--1-of-2 slds-p-horizontal_x-small" />

({doInit : function(component, event, helper) {    var value = [{         type: 'Opportunity',         id: "0060Q000005HuNSQA0",         label: "navigate",     }];     component.find("lookup").get("v.body")[0].set("v.values", value);}

})

Unbale to save lighting RecordEditForm in lwc

$
0
0

while saving thelightning-record-edit-form it throws an error Like this in the picture. There is any resolved solution...While saving the record it throws an error

My requirement is when I save the record, should be saved on the cardThis my code:

HTML:

<template><div class="slds-card slds-card_boundary"><div class="slds-grid slds-page-header forceRelatedListCardHeader"><header class="slds-media slds-media_center slds-has-flexi-truncate"><div class="slds-media__figure"> <lightning-icon icon-name="action:add_file" size="xx-small" alternative-text="Connected"></lightning-icon>     </div><div class="slds-media__body"><h2 class="slds-card__header-title slds-text-title_bold"> Bank Account  ({recordCount}) </h2></div><div class="slds-no-flex"> <lightning-button label="New" title="Non-primary action" onclick={openModal} class="slds-m-left_x-small"></lightning-button></div></header></div><div if:true={recordFound} class="slds-media__body"><lightning-datatable                hide-checkbox-column                 data={data}                 columns={columns}                key-field="id"                onrowselection={getSelectedRecords}                onrowaction={handleRowActions}></lightning-datatable></div></div><div if:true={showLoadingSpinner}><lightning-spinner alternative-text="Loading" size="small"></lightning-spinner></div><template if:true={isModalOpen}><!-- Modal/Popup Box LWC starts here --><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"><!-- Modal/Popup Box LWC header here --><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"                        alternative-text="close"                        variant="inverse"                        size="small" ></lightning-icon><span class="slds-assistive-text">Close</span></button><h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">New Bank Account</h2></header><!-- Modal/Popup Box LWC body starts here --><div class="slds-modal__content slds-p-around_x-large slds-p-top_none" style="overflow-y: auto;" id="modal-content-id-1"><div class="slds-col slds-size_1-of-1 slds-p-top_small"><c-look-up obj-name="Contact" icon-name="custom:custom87" required unique-key='Contact_Lookup_calculator'                    label-name="Contact" create-record=true onvalueselect={selectedContact}> </c-look-up></div><lightning-record-edit-form object-api-name="Bank_Account__c" onsubmit={handleSubmit} onsuccess={handleSuccess}><lightning-messages></lightning-messages><lightning-input-field field-name="Account_Number__c"></lightning-input-field><lightning-input-field field-name="Account_Type__c"></lightning-input-field><lightning-input-field field-name="Sort_Code__c"></lightning-input-field><div class="modal-footer slds-modal__footer slds-size_1-of-1"><lightning-button variant="neutral" label="Cancel" title="Cancel" onclick={closeModal}> </lightning-button><lightning-button class="slds-m-top_small" type="submit" label="Save"></lightning-button>                        </div></lightning-record-edit-form></div><!-- Modal/Popup Box LWC footer starts here --></div></section><div class="slds-backdrop slds-backdrop_open"></div></template><c-new-record-lookup obj-name="Contact" unique-key='Contact_Lookup_calculator'></c-new-record-lookup>

Js

 import { LightningElement, track, api, wire } from 'lwc';import { NavigationMixin } from 'lightning/navigation';import { ShowToastEvent } from 'lightning/platformShowToastEvent';import releatedFiles from '@salesforce/apex/DocumentController.releatedFiles';import deleteFile from '@salesforce/apex/DocumentController.deleteFile';import { CurrentPageReference } from 'lightning/navigation';import { getObjectInfo } from 'lightning/uiObjectInfoApi';import Contact_OBJECT from '@salesforce/schema/Bank_Account__c';const actions = [    { label: 'View', name: 'record_details' },    { label: 'Delete', name: 'delete' }];const columns = [{        label: 'Number',        fieldName: 'View__c',        type: 'url',        typeAttributes: { label: { fieldName: 'Title' } },        sortable: false    },    { label: 'Sort Code', fieldName: 'Sort_Code__c' },    {label:'Account Number', fieldName:'Account_Number__c'},    {        type: 'action',        typeAttributes: {            rowActions: actions,            menuAlignment: 'auto'        }    }];export default class BankRelatedList extends LightningElement { @api recordId;    renderedCallback() {        const inputFields = this.template.querySelectorAll('lightning-input-field'        );    }    handleSubmit(event){        event.preventDefault();       // stop the form from submitting       // Check your custom validation        const inputFields = this.template.querySelectorAll('lightning-input-field'        );        if (inputFields) {            inputFields.forEach(field => {                if(field.fieldName == 'Name') {                    //custom Error                }            });        }        let BankAC  = { 'sobjectType': 'Bank_Account__c' };         BankAC.Account__c=this.AccountId;         BankAC.Client__c=this.ContactId;        const fields = event.detail.fields;        this.template.querySelector('lightning-record-edit-form').submit(fields);        this.recordFound = true;     }     handleSuccess(event){        //const updatedRecordId = event.detail.id;        // Generate a URL to a User record page        console.log('==============record id', event.detail.id);        this[NavigationMixin.Navigate]({            type: 'standard__recordPage',            attributes: {                recordId: event.detail.id,                actionName: 'view',            },        });     }    @api objectApiName;    @track columns = columns;    @track data;    @track fileName = '';    @track UploadFile = 'Upload File';    @track showLoadingSpinner = false;    @track isTrue = false;    @track recordFound = false;    @track recordCount = 0;    @track _options = [];    @track SortCode;    @track AppInfo;    @track accountnumber;    @track AccountId;    @track ContactId;    @track recordTypeId;    selectedRecords;    filesUploaded = [];    file;    fileContents;    fileReader;    content;    MAX_FILE_SIZE = 1500000;    @track isModalOpen = false;    @wire(CurrentPageReference) pageRef;    @wire(getObjectInfo, { objectApiName: Contact_OBJECT, })    AppInfo;    getRecordTypeId(recordTypeName) {        let recordtypeinfo = this.AppInfo.data.recordTypeInfos;        let recordTypeId;        for (var eachRecordtype in recordtypeinfo) {            if (recordtypeinfo[eachRecordtype].name === recordTypeName) {                recordTypeId = recordtypeinfo[eachRecordtype].recordTypeId;                break;            }        }        return recordTypeId;    }    connectedCallback() {        this.getRelatedFiles();    }    handleRowActions(event) {        let actionName = event.detail.action.name;        window.console.log('actionName ====> '+ actionName);        let row = event.detail.row;        window.console.log('row ====> '+ row);        // eslint-disable-next-line default-case        switch (actionName) {            case 'record_details':                window.open('/lightning/r/'+ row.ContentDocumentId +'/view')                break;            case 'delete':                this.deleteCons(row);                break;        }    }    deleteCons(currentRow) {        deleteFile({ id: currentRow.Id })            .then(data => {                if (data) {                    this.showLoadingSpinner = true;                    this.getRelatedFiles();                    this.dispatchEvent(                        new ShowToastEvent({                            title: 'Deleted Successfully.',                            variant: 'success',                        }),                    );                }            })    }    openModal() {        // to open modal set isModalOpen tarck value as true        this.isModalOpen = true;    }    closeModal() {        // to close modal set isModalOpen tarck value as false        this.ContactId='';        this.AccountId='';        this.isModalOpen = false;    }    selectedContact(event){   this.ContactId=event.detail.selectedId      this.accountId = null;        }  // Getting releated files of the current record  getRelatedFiles() {    releatedFiles({ idParent: this.recordId })        .then(data => {            this.data = data;            if (data != null && data != undefined && data.length > 0) {                this.recordFound = true;                this.recordCount = data.length;            }            this.showLoadingSpinner = false;        })        .catch(error => {            this.dispatchEvent(                new ShowToastEvent({                    title: 'Error!!',                    message: error.message,                    variant: 'error',                }),            );        });}}

assign a case to queue using lightning component and queue must be dynamically assigned

$
0
0

public class assignloginowner {@AuraEnabledpublic static Case loginowner(Id caseId){if(caseId !=null){Case C= [select ownerId from Case where id=:caseId];C.ownerId=UserInfo.getUserId();update C;return C;}return null;}

}///// case assigned to login user is done please help me out to assign it to queue.

I want to populate respected account on account field when any opportunity select

$
0
0

I have created a component and i created a onchange event on opportunity field it called a controller method and this controller method called a apex method with opp id and return acc id so i can populated on it but i am not able to pass the opp id to the apex method.

Component

This component has record edit from

<lightning:inputField fieldName="Account__c" aura:id="accountIdField" value= "{!v.AccId}" /></lightning:layoutItem><lightning:layoutItem size="12" smallDeviceSize="6" mediumDeviceSize="6" largeDeviceSize="6" padding="around-medium"><lightning:inputField fieldName="Opportunity__c" aura:id="opportunityIdField" value= "{!v.OppId}" onchange="{!c.getaccountId}" /></lightning:layoutItem>

Controller

    {       // console.log(evt.target.value);      var opp=component.find("opportunityIdField").get("v.value");        var accid=component.find("accountIdField").get("v.value");        alert("oppId  "+opp+'accId  '+accid);        var action=component.get("c.getAccId");        action.setParam({"opId" : opp});        action.setCallback(this,function(response){            let state=response.getState();            let resultId = response.getReturnValue();            if(state=='SUCCESS'){alert('success'+resultId);}        });        $A.enqueueAction(action);    }

Apex Class

 @AuraEnabled    public static id getAccId(String opId)    {        id accid;        system.debug('called'+opId);        if(opId!=null)        { accid = [select id,account.id,name from opportunity where id=:opId].account.id;         system.debug('Account id '+accid);         return accid;        }        else{system.debug('not found result');             return null;            }    }

Downloading all documents through the URL hack gives "This content pack is empty...and cannot be downloaded" error

$
0
0

Based on some answers and google searching, I've understood that all content documents attached to a record can be downloaded if a url is with '/' separated content document IDs formed as below :

https://xxxxxxxxxxxx/sfc/servlet.shepherd/document/download/06AN0000002deibMAA/06AN00000030E6BMAU/06AN00000030E6pMAE/06AN00000030E6uMAE?

To create a button out of it, I've written a function :

public static List<Id> getContentDocumentLinks(Id loanId) {        try {            String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();            List<ContentDocumentLink> contentDocumentLinks = [  SELECT Id, COntentdocumentId                                                                 FROM  ContentDocumentLink                                                                 WHERE LinkedEntityId = :loanId];            List<Id> contentDocIds = new List<Id>();            for (ContentDocumentLink cdl : contentDocumentLinks) {                contentDocIds.add(cdl.Id);            }            String downloadUrl = baseUrl+'/sfc/servlet.shepherd/document/download/'+String.join(contentDocIds,'/');            System.debug('downloadUrl : '+downloadUrl);            return contentDocIds;        } catch (Exception ex) {            System.debug('Error : '+ex.getMessage() +' --> '+ ex.getStackTraceString());            throw new downloadDocsException(ex.getMessage());        }   }

But opening that url while i'm logged in as the administrator gives me error - This content pack is empty or contains only links and Google Docs, and cannot be downloaded.

enter image description here

How could this be fixed ??

How to highlight Outlook calendar event after sync to Salesforce using Lightning for Outlook (LFO)

$
0
0

I am currently using Lighting for outlook and was able to Sync Events and Email with my Salesforce instance.Once the email is Synced in Saleforce it appears as "Related to Salesforce" on email, but this is not happening for events after the event is logged there is no tag saying "Related to Salesforce" orevent is not highlighted in outlook calendar.As it happens in Salesforce for Outlook.

Any help is appreciated.


Can I use parent field in the new Lightning Email Templates

$
0
0

Summer 18 added the features Lightning Email Templates and also added support for Handlebars Template Language - HML

I really hoped that also the ability to add a merged field of a parent object would be available (see Cross Object Merge Fields in Email Template idea)

So for example in my email composer I have added with no luck:

{{{Opportunity.Account.Name}}}

{{{Opportunity.Account.Id}}}

I get this error while sending:

Hmm. The merge field Opportunity.Account.Id doesn’t look right. Fix the expression and try again.

QUESTION

Is it possible today with the new features of Lightning Email Templates and Handlebars Template Language to add a parent merged field?

If it is possible then - how to do it (I don't need the solution of adding formula field for each required field)?

How to add fields to "New Event" under "Activity" tab in Lightning?

$
0
0

I am trying to add custom fields to the "New Event" layout under "Activities" on Opportunity:

enter image description here

However, it appears this component is a static, non-customizable component because when I click on it in Builder, I only see this:

enter image description here

One forum post suggested that one cannot customize this component and therefore cannot add custom fields.

Another post suggests it is possible by editing the Global Action Layout, but this only changed the Global Action for Classic UI.

How can I make available a custom "New Event" layout in Lightning Experience under the "New Event" tab?

issue with lightning lookup using lightning input field

$
0
0

Guys I have embedded a lightning component on a VF Page, so there is a lighting lookup field on my component, the lookup is perfectly working fine except onething. So usually when we start typing in a lookup field it does show a magnifying glass below.

For example here when I start typing it shows the account names. So I have an account name called "test". So If I have type until "te" it is showing a magnifying glass symbol below my lookup field but when I click on it it is not showing a list of account names starting with "te". I can understand that it is not working as this component is called from VF Page.Image using Lightning input field

Can Barcode Scanner API support continuous scan?

$
0
0

I use LWC Barcode Scanner API try to develop continuous scan feature. LWC Barcode Scanner API document as follow link:https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_barcodescanner

My code for continuous scan as follow

     for (let index = 0; index < this.maxContinuousScanCount; index++) {        this.scanner.beginCapture(options).then((result) => {            var value = decodeURIComponent(result.value);            this.scanResults.push([value]);            setTimeout(() => {                this.handleContinuousScanEachTime(value);                this.playSound(true);            });        }).catch((error) => {            setTimeout(() => {                this.playSound(false);                this.showFailedToast(error);            });            this.scanner.endCapture();        }).finally(() => {            this.scannerResult = this.scanResults.join('\n\r');                        });                }    this.scanner.endCapture();

Is this code issue or just LWC Barcode Scanner API not support continuous scan yet?

Best wishes,Lee

backgroundContext not working for Edit NavigationMixin LWC

$
0
0

I have overridden standard edit page with a lightning controller which will redirect to standard lightning record page or custom lightning component by different recordtypes.

The problem i am facing is when i press the standard Cancel button which appears on the modal, it just closes the modal, but it doesn't reditrect to record detail page.

To resolve this i checked for backgroundContext. This is working fine for New record page navigation, but for edit the backgroundContext is not working.

i am trying to make the page see like this

enter image description here

but currently the background is coming as blank.

JS

  if (this.mode === 'edit') {        this[NavigationMixin.Navigate]({            type: 'standard__objectPage',            attributes: {                recordId: this.recordId,                objectApiName: 'XYZ__c',                actionName: 'edit'            },            state: {                nooverride: 1,                backgroundContext: '/lightning/r/XYZ__c/a2Q1j0000001nomEAA/view'            }        });    }
Viewing all 3000 articles
Browse latest View live


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