Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Max EvryMax Evry 
I'm trying to implement a Combination chart (line/bar) for a report and ultimately as a dashboard component in Salesforce Lightning. Currently I'm not seeing any options for it among the generic chart settings within a report. Is this achievable or a feature that's only available for Salesforce Classic?
Best Answer chosen by Max Evry
Kundan Kumar JhaKundan Kumar Jha
Refer : https://trailblazer.salesforce.com/ideaView?id=08730000000DtjHAAS       

            https://help.salesforce.com/articleView?id=reports_combination_charts_examples.htm&type=5
 
Jamie McGarrigleJamie McGarrigle 
Hi there,

I have recently created a new app and the way that users access objects in the app is through a strip of objects at the top (see screen grab 1).

I want to change this so that the objects are instead accessed from a dropdown menu (see screen grab 2).

Does anyone know how to make this update?

Thanks,

Jamie

--

Screen grab 1:
User-added image

Screen grab 2:

User-added image
Best Answer chosen by Jamie McGarrigle
Eric PraudEric Praud
Hi Jamie,

Tgis is because screenshot2 is a console app. You cannot change a "standard" app to a console app though, you'll need to create a new one under Set up> App Manager
harsh shuklaharsh shukla 
Hi,
I am tryiing to create simple voting criteria in Lightning.

If age>=18. Alert = Congrats!! You can vote. Show button =  Submit your vote

else---  alert = 'Sorry you can't vote'.

Below is the code i am trying but failed..

Component Code:
<aura:component implements="force:appHostable,
                flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,
                force:hasRecordId,forceCommunity:availableForAllPageTypes,
                force:lightningQuickAction" access="global" >
    <aura:attribute name = "EligibleForVoting" type = "boolean"></aura:attribute>
    <ui:inputText label = "First Name:" aura:id="firstName" placeholder = "Enter your first name"></ui:inputText>
    <ui:inputText label = "Last Name:" aura:id="lastName" placeholder = "Enter your last name"></ui:inputText>
    <ui:inputText label = "Age:" aura:id="age" placeholder = "Enter your age"></ui:inputText>
    <ui:button aura:id = "buttonforaction" label = "submit" press = "{!c.getEligibility}"></ui:button>
    
  <aura:if isTrue = "{!v.EligibleForVoting}">
      Congrats! You can vote.
      <ui:button  label  = "Please vote"></ui:button>
              <aura:set attribute = "else">
          Sorry! You can't Vote.
      </aura:set>
   </aura:if>
</aura:component>
    
Controller Code:
({
    getEligibility : function(component) {
        var firstname = component.find("firstName").get("v.value");
        var lastname = component.find("lastName").get("v.value");
        var age = component.find("age").get("v.value");
        
        if(age>=18){
            component.set("EligibleForVoting", true);
        }
        else{
            component.set("EligibleForVoting", false);
        }
        
    }
})

Please help for best output.
 
Best Answer chosen by harsh shukla
Ghanou LahbibGhanou Lahbib

Hello,
when setting aura:attribute value use component.set("v.attribute", value)

in your case component.set("v.EligibleForVoting",true) or false

Grace DavidsonGrace Davidson 
Hello 

I have a existing date field called Contract end date and I want to create a new field called Rnewal 
In the renewal field I want to add a formula to show Contract end date minue 6 mths 

How do I write this? 

Thanks in advance 
Grace 
Best Answer chosen by Grace Davidson
Eric PraudEric Praud
Then do this:
ADDMONTHS(Contract_End_Date__c,-6)
Ashutosh SarpalAshutosh Sarpal 
Not able to complete challenge "Create a method for inserting accounts." in module " Manipulate Records with DML". Below is the challenge :

To pass this challenge, create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null.
The Apex class must be called AccountHandler and be in the public scope
The Apex class must have a public static method called insertNewAccount
The method must accept an incoming string as a parameter, which will be used to create the Account name
The method must insert the account into the system and then return the record
The method must also accept an empty string, catch the failed DML and then return null
Best Answer chosen by Ashutosh Sarpal
Bablu Kumar PanditBablu Kumar Pandit
Hey ashutosh,
try Below code
public class AccountHandler {
public static Account insertNewAccount(String strname) {
Account obj = new Account();
obj.Name = strname;
try
{
insert obj;
} catch (Exception e) {
return null;
}
return obj;
}
}

try above code and let me know
Ashutosh SarpalAshutosh Sarpal 
Not able to complete challenge "Create an Apex class with a method that returns an array (or list) of strings" in "Get Started with Apex" module. Please help
Best Answer chosen by Ashutosh Sarpal
Ankush AgarwalAnkush Agarwal
Hi Ashutosh,

you may try with below:
 
public class StringArrayTest
{
    public static List<String> generateStringArray(Integer n)
    {
        List<String> List1 = new List<String>();
        for(Integer i =0; i < n; ++i)
            List1.add('Test ' + i);
        return List1;
    }
}

 
Tran Ha AnhTran Ha Anh 
I am on the trailhead module "Injection Vulnerability Prevention" and am trying to sign up for "Kingdom Management App"  using the below URL https://developer.salesforce.com/promotions/orgs/trust-de
I am unable to verify account.
When click verify link on email, it's always display missing IP error message like below
User-added image
Many thanks,
Anh
Best Answer chosen by Tran Ha Anh
Andrew FragiasAndrew Fragias
Hi Tran,

I would suggest closing all your browser tabs and then trying again. Also may be worthwhile trying this in an incognito window. If neither of these work then clear your browsing cahce and try again
 
Patricia LimPatricia Lim 
Sorry if this question is a little wordy - what I am trying to achieve is to have a picklist of three values of which all have three different prices and ideally it is linked to an object.

Price books are the first thing that come to mind, however we only need three different 'products'.

For context, my organization awards scholarships. We have three scholarships all at different dollar values. We would like to ideally associate scholarship 1 with a contact, and have the amount autopopulated when selecting scholarship 1. Afterwards, we could add the scholarships related list to a contact page layout, along with adding the related list to a school to only display scholarships awarded for that school.

Thanks
Best Answer chosen by Patricia Lim
Andrew FragiasAndrew Fragias
Hi Patricia,

Although you only need 3 different products I would suggest you go down the Pricebook route because all the functionality is already built for you and you will only need to create a lookup from the Product to the object you are using then add it to the page layout as a related list
balinder singhbalinder singh 
I am getting following error while validating step 14 on LWC super badge
Challenge Not yet complete... here's what's wrong:
We can’t find the correct target configuration for the similarBoats component. Make sure the component is configured according to the requirements, including the object name, the parameters, label, and isExposed setting.
My current metadata file for LWC component looks like 
similarBoats.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>similarBoats</masterLabel>    
    <description>Similar Boats</description>
    <targets>
        <target>lightning__RecordPage</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordPage">
            <property label="Enter the property you want to compare by" name="similarBy" type="String" datasource="Type,Price,Length"  />
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>


 
Best Answer chosen by balinder singh
Jean-Noel CasassusJean-Noel Casassus
You should have an object filter
Lokesh MLokesh M 
I got struck on lwc super badge challenge 8

User-added image

boatSearchResults.HTML
<template>
    <template if:true={boats}>
        <lightning-tabset variant="scoped">
            <lightning-tab label="Gallery">
                <div class="slds-scrollable_y">
                    <!-- layout horizontally aligned to the center  -->
                    <!-- layout allowing multiple rows -->
                    <lightning-layout multiple-rows horizontal-align="center">
                        <!-- template looping through each boat -->
                        <template for:each={boats} for:item="boat">
                            <!-- lightning-layout-item for each boat -->
                            <lightning-layout-item key={boat.Id}
                                size="12"
                                large-device-size = "3"
                                medium-device-size = "4"
                                small-device-size = "6"
                                padding ="around_small">
                                <c-boat-tile boat={boat} selected-boat-id={selectedBoatId} onboatselect={updateSelectedTile}>
                                </c-boat-tile>
                            </lightning-layout-item>
                        </template>
                    </lightning-layout>
                </div>
            </lightning-tab>
            <lightning-tab label="Boat Editor">
                <!-- Scrollable div and lightning datatable go here -->

                <lightning-datatable key-field="Id" data={boats} show-row-number-column row-number-offset={rowOffset}
                    columns={columns} hide-checkbox-column onsave={handleSave} draft-values={draftValues}>
                </lightning-datatable>
            </lightning-tab>
            <lightning-tab label="Boats Near Me">
                <!-- boatsNearMe component goes here -->
                <c-boats-near-me></c-boats-near-me>
            </lightning-tab>
        </lightning-tabset>
    </template>
</template>

boatSearchResults.JS
import { LightningElement, api, wire, track } from 'lwc';
import { updateRecord } from 'lightning/uiRecordApi'
import getBoats from '@salesforce/apex/BoatDataService.getBoats';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';
//import { subscribe, unsubscribe, APPLICATION_SCOPE, MessageContext, publish } from 'lightning/messageService';
//import BOATMC from "@salesforce/messageChannel/BoatMessageChannel__c";

const COLUMNS = [
    {label: 'Name' , fieldName:'Name' , type: 'text',editable:"true"},
    {label: 'Length', fieldName: 'Length__c', type: 'number',editable:"true"},
    {label: 'Price', fieldName: 'Price__c', type: 'currency',editable:"true"},
    {label: 'Description', fieldName: 'Description__c', type: 'text',editable:"true"},
]

export default class BoatSearchResults extends LightningElement {
    @api boatTypeId;
    @track boats;
    @track error;
    result;
    columns = COLUMNS;
    rowOffset = 0;
    @track draftValues = [];

    @track selectedBoatId;
    isLoading = false;

    @wire(getBoats , { boatTypeId : ''})
    wiredBoats(result){
        this.result = result;
        const {data, error} = result
        if(data){
            this.boats = data;
            this.dispatchCustomEvent('doneloading');
        }
        else if(error) {
            this.error = error;
            this.dispatchCustomEvent('doneloading');
            console.log('error', JSON.stringify(error));
        }
    }

    @api async searchBoats(boatTypeId) {
        this.dispatchCustomEvent('loading');
        try {
            this.boats = await getBoats({boatTypeId : boatTypeId});
            this.dispatchCustomEvent('doneloading');
        }
        catch(error) {
            this.error = error;
            this.dispatchCustomEvent('doneloading');
        }
    }

    dispatchCustomEvent(value) {
        this.dispatchEvent(new CustomEvent(value));
    }


    updateSelectedTile() {
        this.dispatchCustomEvent('loading');
        this.selectedBoatId = event.detail.boatId;
    }


    handleSave(event) {
        this.dispatchCustomEvent('loading');
       //console.log(event.detail.draftValues);
       const recordInputs = event.detail.draftValues.slice().map(draft=>{
           const fields = Object.assign({}, draft);
           return {fields};
       });

       console.log(recordInputs);
       const promises = recordInputs.map(recordInput => updateRecord(recordInput));
       Promise.all(promises).then(res => {
           this.dispatchEvent(
               new ShowToastEvent({
                   title: 'Success',
                   message: 'Ship It!',
                   variant: 'success'
               })
           );
           this.draftValues = [];
           //return refreshApex(this.boats);
           this.dispatchCustomEvent('doneloading');
           return refreshApex(this.result);
           
       }).catch(error => {
           this.error = error;
           this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Error',
                    message: 'Contact System Admin!',
                    variant: 'error'
                })
            );
            this.dispatchCustomEvent('doneloading');
       })
    }
}

I've created the component according to the requirements, but I'm not able to find the mistake. Is there anything I'm missing from the requirement? 
Best Answer chosen by Lokesh M
Lokesh MLokesh M
Finally I managed to pass the challenge by fixing lot of problems in the code

boatSearchResults.html
<template>
    <lightning-tabset variant="scoped">
        <lightning-tab label="Gallery">
            <template if:true={boats.data}>
                <div class="slds-scrollable_y">
                    <lightning-layout horizontal-align="center" multiple-rows>
                        <template for:each={boats.data} for:item="boat">
                            <lightning-layout-item key={boat.Id} padding="around-small" size="12" small-device-size="6"
                                medium-device-size="4" large-device-size="3">
                                <c-boat-tile boat={boat} selected-boat-id={selectedBoatId}
                                    onboatselect={updateSelectedTile}></c-boat-tile>
                            </lightning-layout-item>
                        </template>
                    </lightning-layout>
                </div>
            </template>
        </lightning-tab>
        <lightning-tab label="Boat Editor">
            <!-- Scrollable div and lightning datatable go here -->
            <template if:true={boats.data}>
                <div class="slds-scrollable_y">
                    <lightning-datatable key-field="Id" data={boats.data} columns={columns} onsave={handleSave}
                        draft-values={draftValues} hide-checkbox-column show-row-number-column>
                    </lightning-datatable>
                </div>
            </template>
        </lightning-tab>
        <lightning-tab label="Boats Near Me">
            <!-- boatsNearMe component goes here -->
            <c-boats-near-me boat-type-id={boatTypeId}></c-boats-near-me>
        </lightning-tab>
    </lightning-tabset>
</template>

boatSearchResults.js
import { LightningElement, wire, api, track } from 'lwc';
import getBoats from '@salesforce/apex/BoatDataService.getBoats';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';
import { publish, MessageContext } from 'lightning/messageService';
import BoatMC from '@salesforce/messageChannel/BoatMessageChannel__c';

export default class BoatSearchResults extends LightningElement {
    boatTypeId = '';
    @track boats;
    @track draftValues = [];
    selectedBoatId = '';
    isLoading = false;
    error = undefined;
    wiredBoatsResult;

    @wire(MessageContext) messageContext;

    columns = [
        { label: 'Name', fieldName: 'Name', type: 'text', editable: 'true'  },
        { label: 'Length', fieldName: 'Length__c', type: 'number', editable: 'true' },
        { label: 'Price', fieldName: 'Price__c', type: 'currency', editable: 'true' },
        { label: 'Description', fieldName: 'Description__c', type: 'text', editable: 'true' }
    ];

    @api
    searchBoats(boatTypeId) {
        this.isLoading = true;
        this.notifyLoading(this.isLoading);
        this.boatTypeId = boatTypeId;
    }

    @wire(getBoats, { boatTypeId: '$boatTypeId' })
    wiredBoats(result) {
        this.boats = result;
        if (result.error) {
            this.error = result.error;
            this.boats = undefined;
        }
        this.isLoading = false;
        this.notifyLoading(this.isLoading);
    }

    updateSelectedTile(event) {
        this.selectedBoatId = event.detail.boatId;
        this.sendMessageService(this.selectedBoatId);
    }

    handleSave(event) {
        this.notifyLoading(true);
       const recordInputs = event.detail.draftValues.slice().map(draft=>{
           const fields = Object.assign({}, draft);
           return {fields};
       });

       console.log(recordInputs);
       const promises = recordInputs.map(recordInput => updateRecord(recordInput));
       Promise.all(promises).then(res => {
           this.dispatchEvent(
               new ShowToastEvent({
                   title: 'Success',
                   message: 'Ship It!',
                   variant: 'success'
               })
           );
           this.draftValues = [];
           return this.refresh();
       }).catch(error => {
           this.error = error;
           this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Error',
                    message: 'Contact System Admin!',
                    variant: 'error'
                })
            );
            this.notifyLoading(false);
       }).finally(() => {
            this.draftValues = [];
        });
    }

    @api
    async refresh() {
        this.isLoading = true;
        this.notifyLoading(this.isLoading);      
        await refreshApex(this.boats);
        this.isLoading = false;
        this.notifyLoading(this.isLoading);        
    }


    notifyLoading(isLoading) {
        if (isLoading) {
            this.dispatchEvent(new CustomEvent('loading'));
        } else {
            this.dispatchEvent(CustomEvent('doneloading'));
        }
    }

     sendMessageService(boatId) { 
        publish(this.messageContext, BoatMC, { recordId : boatId });
    }
}