• Raksha Jha
  • NEWBIE
  • 20 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
How to send notification via LMS on change of data in LWC - Datatable?
I have created a leaderboard which display the scores of winning player through LWC- Datatable. i have to publish message through LMS whenever winning player change.
This is Apex class:
public with sharing class SquadLeaderBoardHandler {
	@AuraEnabled(cacheable=true)
    public static List<Account> getUpdatedScore() 
    {
        Contact con = [SELECT AccountId FROM Contact WHERE Email = :UserInfo.getUserEmail()];

        Account objAccount = new Account();
        objAccount = [SELECT Name, Squad__r.Name, Id FROM Account WHERE Id = :con.AccountId];
        //WHERE Id = :objUser.Id


        return [SELECT Name, Weekly_Arete_Number__c, Squad__r.Name FROM Account 
        WHERE Squad__r.Name = :objAccount.Squad__r.Name ORDER BY Weekly_Arete_Number__c DESC LIMIT 3];
    }
}
Leaderboard.html:
<template>
	<lightning-card title={squadName} onchange={publishMessage} icon-name="utility:activity">		
			<div if:true={accounts}>
				<lightning-datatable data={accounts}
					columns={columns}
					key-field="id"
					hide-checkbox-column="true">
				</lightning-datatable>
			</div>		
</lightning-card>
</template>

LeaderBoard.js
import { LightningElement, wire, track } from 'lwc';
import getUpdatedScore from '@salesforce/apex/SquadLeaderBoardHandler.getUpdatedScore';
import LBMC from '@salesforce/messageChannel/LeaderBoardMessageChannel__c';
import { MessageContext, publish } from 'lightning/messageService';

// datatable columns
const COLUMNS = [
    { label: 'Hero Name', fieldName: 'Name', hideDefaultActions: true, type: 'text' },
    { label: 'Hero Score', fieldName: 'Weekly_Arete_Number__c', hideDefaultActions: true, type: 'Number' },
];

export default class SquadLeaderboard extends LightningElement {
    @track squadName;
    @track accounts;
    @track columns = COLUMNS;
    @track error;

    @wire(getUpdatedScore)
    wiredupdatedScore({ error, data }) {
        if (data) {
            this.accounts = data;
            this.error = undefined;
            this.squadName = 'Squad Leaderboard for: ' + this.accounts[0].Squad__r.Name;
            console.log(this.accounts);

        } else if (error) {
            this.error = error;
            this.accounts = undefined;
        }
    }

    @wire(MessageContext)
    context;
    publishMessage(event) {
        this.squadName = event.target.value;
        console.log('SquadName: ' + this.squadName);
        const message = { slbData: { value: this.squadName } };
        publish(this.context, LBMC, message);

    }

}
message channel
<?xml version="1.0" encoding="UTF-8" ?>
<LightningMessageChannel xmlns="http://soap.sforce.com/2006/04/metadata">
    <masterLabel>LeaderBoardMessageChannel</masterLabel>
    <isExposed>true</isExposed>
    <description>Message Channel to pass data</description>
   	<lightningMessageFields>
			 <fieldName>slbData</fieldName>
        <description>This is the field to pass SquadLeaderBoard Data</description>
		</lightningMessageFields>
		<lightningMessageFields>
			<fieldName>clbData</fieldName>
			<description>This is the field to pass CohortLeaderBoard Data</description>
		</lightningMessageFields>
		<lightningMessageFields>
			<fieldName>tlbData</fieldName>
			<description>This is the field to pass TeamLeaderBoard Data</description>
    </lightningMessageFields>
	</LightningMessageChannel>

Thanks!

 
I have two object Auction(master) and Bid(child). i have used lightning datatable(Aura) to display bid history and record-view form(LWC) to display related auction record. my question is how can I pass the record Id from the Auction detail page to my both the components when someone will click the bid history button on detail page?

Thank You! 
trigger TriggerOnContract on Contract (after insert, after update, after delete, after undelete) {
    switch on Trigger.operationType{
        when AFTER_INSERT{
            //creating a new set of account Ids from contract whose status is active 
            set<Id> accountIds = new set<Id>();
            for(Contract contract:Trigger.new ){
                if(contract.Status == 'Activated'){
                    accountIds.add(contract.AccountId);
                }
            }
            //creating a list of contract of the selected account Ids of the set
            List<Contract> contracts=[SELECT Id, AccountId, Status, Productc, Property_Rentc FROM Contract 
                                      WHERE Status='Activated' AND AccountId IN:accountIds];

            //build final list of account to update
            List<Account> accountsToUpdate = new List<Account>();
            for(Contract contract:contracts){
                Account acct= new Account(Id = contract.AccountId, 
                                          Property_Namec = contract.Productc,
                                          Rent_Amountc = contract.Property_Rentc);

                accountsToUpdate.add(acct);
            }
            //update the final list of account
            update accountsToUpdate;

this is the trigger, i would like to update Property and rent field on Account form the active contract. account and contract are standard object . property and rent field on both the objects are custom field. this  is not working, how can i fix it. need help...Thanks!
How to send notification via LMS on change of data in LWC - Datatable?
I have created a leaderboard which display the scores of winning player through LWC- Datatable. i have to publish message through LMS whenever winning player change.
This is Apex class:
public with sharing class SquadLeaderBoardHandler {
	@AuraEnabled(cacheable=true)
    public static List<Account> getUpdatedScore() 
    {
        Contact con = [SELECT AccountId FROM Contact WHERE Email = :UserInfo.getUserEmail()];

        Account objAccount = new Account();
        objAccount = [SELECT Name, Squad__r.Name, Id FROM Account WHERE Id = :con.AccountId];
        //WHERE Id = :objUser.Id


        return [SELECT Name, Weekly_Arete_Number__c, Squad__r.Name FROM Account 
        WHERE Squad__r.Name = :objAccount.Squad__r.Name ORDER BY Weekly_Arete_Number__c DESC LIMIT 3];
    }
}
Leaderboard.html:
<template>
	<lightning-card title={squadName} onchange={publishMessage} icon-name="utility:activity">		
			<div if:true={accounts}>
				<lightning-datatable data={accounts}
					columns={columns}
					key-field="id"
					hide-checkbox-column="true">
				</lightning-datatable>
			</div>		
</lightning-card>
</template>

LeaderBoard.js
import { LightningElement, wire, track } from 'lwc';
import getUpdatedScore from '@salesforce/apex/SquadLeaderBoardHandler.getUpdatedScore';
import LBMC from '@salesforce/messageChannel/LeaderBoardMessageChannel__c';
import { MessageContext, publish } from 'lightning/messageService';

// datatable columns
const COLUMNS = [
    { label: 'Hero Name', fieldName: 'Name', hideDefaultActions: true, type: 'text' },
    { label: 'Hero Score', fieldName: 'Weekly_Arete_Number__c', hideDefaultActions: true, type: 'Number' },
];

export default class SquadLeaderboard extends LightningElement {
    @track squadName;
    @track accounts;
    @track columns = COLUMNS;
    @track error;

    @wire(getUpdatedScore)
    wiredupdatedScore({ error, data }) {
        if (data) {
            this.accounts = data;
            this.error = undefined;
            this.squadName = 'Squad Leaderboard for: ' + this.accounts[0].Squad__r.Name;
            console.log(this.accounts);

        } else if (error) {
            this.error = error;
            this.accounts = undefined;
        }
    }

    @wire(MessageContext)
    context;
    publishMessage(event) {
        this.squadName = event.target.value;
        console.log('SquadName: ' + this.squadName);
        const message = { slbData: { value: this.squadName } };
        publish(this.context, LBMC, message);

    }

}
message channel
<?xml version="1.0" encoding="UTF-8" ?>
<LightningMessageChannel xmlns="http://soap.sforce.com/2006/04/metadata">
    <masterLabel>LeaderBoardMessageChannel</masterLabel>
    <isExposed>true</isExposed>
    <description>Message Channel to pass data</description>
   	<lightningMessageFields>
			 <fieldName>slbData</fieldName>
        <description>This is the field to pass SquadLeaderBoard Data</description>
		</lightningMessageFields>
		<lightningMessageFields>
			<fieldName>clbData</fieldName>
			<description>This is the field to pass CohortLeaderBoard Data</description>
		</lightningMessageFields>
		<lightningMessageFields>
			<fieldName>tlbData</fieldName>
			<description>This is the field to pass TeamLeaderBoard Data</description>
    </lightningMessageFields>
	</LightningMessageChannel>

Thanks!

 
I have two object Auction(master) and Bid(child). i have used lightning datatable(Aura) to display bid history and record-view form(LWC) to display related auction record. my question is how can I pass the record Id from the Auction detail page to my both the components when someone will click the bid history button on detail page?

Thank You! 
trigger TriggerOnContract on Contract (after insert, after update, after delete, after undelete) {
    switch on Trigger.operationType{
        when AFTER_INSERT{
            //creating a new set of account Ids from contract whose status is active 
            set<Id> accountIds = new set<Id>();
            for(Contract contract:Trigger.new ){
                if(contract.Status == 'Activated'){
                    accountIds.add(contract.AccountId);
                }
            }
            //creating a list of contract of the selected account Ids of the set
            List<Contract> contracts=[SELECT Id, AccountId, Status, Productc, Property_Rentc FROM Contract 
                                      WHERE Status='Activated' AND AccountId IN:accountIds];

            //build final list of account to update
            List<Account> accountsToUpdate = new List<Account>();
            for(Contract contract:contracts){
                Account acct= new Account(Id = contract.AccountId, 
                                          Property_Namec = contract.Productc,
                                          Rent_Amountc = contract.Property_Rentc);

                accountsToUpdate.add(acct);
            }
            //update the final list of account
            update accountsToUpdate;

this is the trigger, i would like to update Property and rent field on Account form the active contract. account and contract are standard object . property and rent field on both the objects are custom field. this  is not working, how can i fix it. need help...Thanks!