• Biswojeet Ray 11
  • NEWBIE
  • 180 Points
  • Member since 2018

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 31
    Replies
Hello friends, I've been having an issue comparing a set of records across different objects. I need to retrieve a list of Lead Records where Lead.Email is the exact value as the email for a corresponding Person Account. 

I've tried doing this in Excel via a VLOOKUP, but the dataset is too large and will not work in Excel. I'm new to SOQL, so I'm wondering if this is possible. 

I'd need to retrieve a List of all Person Accounts where the email = Lead.Email with the following fields selected: Account ID, Account Name, Account Owner, Person_ID__pc. 
Hello,

I have a wrapper extension class that's intended to bring back grandchild records for a pageblock table within a Visualforce page. However, I keep getting errors when trying to save the Visualforce page referencing the extension controller. I'm not sure if there's a problem with the extension controller or the Visualforce page? Please see code below, any help is greatly appreciated!

VF Page:

<apex:page standardController="Consolidated_Invoicing__c" extensions="WrapperSarah"  renderas="pdf">

Extension Controller:

public class WrapperSarah{ 
private final Consolidated_Invoicing__c consinvs;
    public WrapperSarah(ApexPages.StandardController stdController) {
this.consinvs = (Consolidated_Invoicing__c)stdController.getRecord();
    }

Can provide the full code if needed but only getting errors after this has been added in following a salesforce guide.

Thanks!
Hi,

I have written below code in Apex Class. But I am not able to cover this code coverage. Please help on this.
public List<SelectOption> RelatedAccounts
    {
        get{
            system.debug('ACCOUUNTS:' + Accs);
        
            List<SelectOption> options = new List<SelectOption>();
            options.add(new selectOption('--Select--',''));
            
            for(CPF_Relationship__c r : Accs)
            {
                options.add(new SelectOption(r.id,r.child_account__r.name));
            }
            return options;
        }
    }

 
How do I display only the current record rather than all records of an object (consolidated invoicing in this instance) using a custom wrapper class and visualforce page with an apex pageblocktable that shows the related records to the current object record (ie, all invoices and then treatments related to Consolidated invoices)?

Parent: Consolidated Invoicing
Child: Invoice
GrandChild: Treatments

I've created a wrapper class:

public class Wrapper{ 
    public List<Consolidated_Invoicing__c> consolidatedInvoiceList { get; set; }
    public List<Invoice__c> invoiceList { get; set; }
    public Map<Id, List<Invoice__c>> coninvIdinvListMap { get; set; }
    Set<Id> invoiceIds = new Set<Id>();
    Map<Id, Consolidated_Invoicing__c> memberMap = new Map<Id, Consolidated_Invoicing__c>();
    
    public List<ConsolidatedInvoiceWrapper> consolidatedInvoiceWrapperList { get; set; }

    public Wrapper() {   
        consolidatedInvoiceList = [SELECT  Total__c, Name FROM Consolidated_Invoicing__c];
        coninvIdinvListMap = new Map<Id, List<Invoice__c>>();
        consolidatedInvoiceWrapperList = new List<ConsolidatedInvoiceWrapper>();
        if(consolidatedInvoiceList.size() > 0) {
            for(Consolidated_Invoicing__c cons: consolidatedInvoiceList) {
                invoiceIds.add(cons.Id);
                memberMap.put(cons.Id, cons);
            }
            invoiceList = [SELECT Name, Consolidated_Invoice__c, (SELECT Name, Charge_Description__c FROM Treatments__r) FROM Invoice__c WHERE Consolidated_Invoice__c IN : invoiceIds];
            system.debug('Invoice List is ' + invoiceList);
        }
        if(invoiceList.size() > 0) {
            for(Invoice__c intrst : invoiceList) {
                if(!coninvIdinvListMap.containsKey(intrst.Consolidated_Invoice__c)){
                    coninvIdinvListMap.put(intrst.Consolidated_Invoice__c, new List<Invoice__c>());
                }
                coninvIdinvListMap.get(intrst.Consolidated_Invoice__c).add(intrst);
            }
            for(Id invoiceId : coninvIdinvListMap.keySet()) {
                consolidatedInvoiceWrapperList.add(new ConsolidatedInvoiceWrapper(memberMap.get(invoiceId), coninvIdinvListMap.get(invoiceId)));
            }
        }
    } 
    
    public class ConsolidatedInvoiceWrapper{
        public Consolidated_Invoicing__c consinv { get; set; }
        public List<Invoice__c> invclist { get; set; }
        
        public ConsolidatedInvoiceWrapper(Consolidated_Invoicing__c consinv, List<Invoice__c> invclist) {
            this.consinv= consinv;
            this.invclist = invclist;
        }
    }
}

And the the Visualforce page:

<apex:page Controller="Wrapper" renderas="pdf">
<apex:form >
<apex:pageBlock >
    <apex:pageBlockTable value="{!consolidatedInvoiceWrapperList}" var="W">
        <apex:column headerValue="Consolidated Invoice Number" value="{!W.consinv.Name}"/>
        <apex:column headerValue="Total Amount Due" value="{!W.consinv.Total__c}"/>
        <apex:column >
            <apex:pageblockTable value="{!W.invclist }" var="I">
                <apex:column headerValue= "Invoice Number" value="{!I.Name}"/>
                <apex:column >
                    <apex:pageBlockTable value="{!I.Treatments__r}" var="E">
                        <apex:column headerValue="Charge Code" value="{!E.Name}"/>
                        <apex:column headerValue= "Description" value="{!E.Charge_Description__c}"/>
                    </apex:pageBlockTable>
                </apex:column>
            </apex:pageblockTable>
        </apex:column>
    </apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

Is there something obvious i'm missing?

Thanks




 
trigger countmeetings on Event (after insert, after delete) {
List<id> levent = new List<id>();
Set<id> accid = new Set<id>();
List<Event> eventtoupdate = new List<Event>();
public integer inp=0;
if(trigger.isInsert){
for(Event ce:trigger.new){
accid.add(ce.WhatId);
}
}
if(trigger.IsDelete){
for(Event ce: trigger.old){
accid.add(ce.WhatId);
}
}
for(Event ev:[SELECT id FROM event WHERE whatid=:accid]){
    levent.add(ev.id);
}
for(Event event :[SELECT id,Distribution_Meetings__c FROM Event WHERE id=:levent]){
    event.Distribution_Meetings__c = levent.size();
    eventtoupdate.add(event);
    }
If(eventtoupdate.size()>0){
    update eventtoupdate;
}
    }
  • April 11, 2019
  • Like
  • 0
/* eslint-disable no-console */
import { LightningElement, wire, track } from 'lwc';
import { getPicklistValues, getPicklistValuesByRecordType, getObjectInfo } from 'lightning/uiObjectInfoApi';
import ACCOUNT_SOURCE from '@salesforce/schema/Account.AccountSource';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';

export default class PicklistDemo extends LightningElement {
    @track pickListvaluesByRecordType;
    @track accountsource;

    @wire(getPicklistValues, {
        recordTypeId : '012000000000000AAA',
        fieldApiName : ACCOUNT_SOURCE
    })
        wiredPickListValue({ data, error }){
            if(data){
                console.log(` Picklist values are `, data.values);
            }
            if(error){
                console.log(` Error while fetching Picklist values  ${error}`);
            }
        }
    @wire(getPicklistValuesByRecordType, {
        recordTypeId : '012N0000000x2HE',
        objectApiName : ACCOUNT_OBJECT
    })
        wiredRecordtypeValues({data, error}){
            if(data){
                console.log(' Picklist Values ', data.picklistFieldValues.Industry.values);
                this.pickListvaluesByRecordType = data.picklistFieldValues.Industry.values;
                this.accountsource = data.picklistFieldValues.AccountSource.values;
            }
            if(error){
                console.log(error);
            }
        }

}


I have one question.

When we are sending parameter to getPicklistValues as per field, Then we are importing the field by schema and sending that as a parameter. we are not using directly the field API name.

Like - import ACCOUNT_SOURCE from '@salesforce/schema/Account.AccountSource';

using here - @wire(getPicklistValues, { recordTypeId : '012000000000000AAA', fieldApiName : ACCOUNT_SOURCE })

But when we are fetching a particular field's value from "getPicklistValuesByRecordType", We are using the API name of the field.

We are not importing the field by the schema.

Like this - this.pickListvaluesByRecordType = data.picklistFieldValues.Industry.values;

Here we are using the direct API name of the "Industry" field. We are not importing this field and use it.

 

Why SO??????

 

Thanks in Advance,

Hi Team,
 
I am using Google Maps in one object. But suddenly it's not working. Getting error "initMap is not a function", name: "InvalidValueError", stack: "Error↵".
Do you guys know about this error?
 
Thanks,
Hi Team,
 
I have created a Tab in my community. Then Added Report object in that tab.
But now the user can see every report in that tab.
I need to populate only some reports to users, not every report.
Is there any workaround?
 
Thanks in Advance,

Hi Team,

 

I have created a Button on a Lightning page. 

In that button added standard logic to create a budget Item object record.

Code

this[NavigationMixin.Navigate]({
            type: "standard__objectPage",
            attributes: {
                objectApiName: "Budget_Item__c",
                actionName: "new"
            },
            state: {
                nooverride: '1',
                defaultFieldValues: fieldValues
            }
        });


Its creating records perfectly. But the Issue is after the creation of record, It's navigating to a newly created record's detail page.

I want to stay on the previous page only(where I have added the button), No need to navigate the newly created record's detail page.

Is there any workaround? Urgently needed.

 

Thanks in advance,

Hi Team,

 

I have created a Tab in my community. Then Added Report object in that tab.

But now the user can see every report in that tab.

I need to populate only some reports to users, not every report.

Is there any workaround?

 

Thanks in Advance,

Hi Team,

 

I am using Google Maps in one object. But suddenly it's not working. Getting error "initMap is not a function", name: "InvalidValueError", stack: "Error↵".

Do you guys know about this error?

 

Thanks,

Hi Team,

When a user is trying to approve an approval request, He is getting error.

I have attached the screenshot of the error also.

It's working in Classic. 

There is an email alert in the approval process as Final Approval Actions.

The used email template in that email alert is classic. 

The subject of the email template ->

{!Opportunity.Name} [{!Opportunity.Opportunity_Number__c}] approved

 

So please check it and let me know is this the issue with the classic email template or what?User-added image

Thanks a lot,

Page Code  --->
<apex:page controller="messageController" lightningStylesheets="true">
<apex:slds />
    <style>
        .headerRow .TableTitle {
            color: #CC0000 !important; 
        }
        .mymsg {
            text-align: right;
            color: blue;
        }
        .othermsg {
            color: green;
        }
    </style>
    <apex:form id="form">
        <apex:pageBlock id="messages" title="{!Friend_Name}" rendered="{!showMessageBox}">
            <apex:pageBlockSection >
            
            <apex:outputPanel layout="block" style="overflow:auto;width:500px;height:200px" >
                <apex:pageBlockTable value="{!messages}" var="msg">
                    <apex:column >
                    
                    <apex:outputText rendered="{!msg.fromId == recordId}">
                        <!--<h1 style ="color: blue;" >{!msg.fromName}</h1><br/>
                        <h5>{!msg.msg}</h5><br/>
                        <h5>{!msg.dateValue}</h5><br/>-->
                        <p class="mymsg">
                        {!msg.fromName}<br/>
                        {!msg.msg}<br/>
                        {!msg.dateValue}
                        </p>
                    </apex:outputText>
                    <apex:outputText rendered="{!msg.fromId != recordId}" >
                        <!--<h2 style ="color: green; text-align:right">{!msg.fromName}</h2><br/>
                        <h5>{!msg.msg}</h5><br/>
                        <h5>{!msg.dateValue}</h5><br/>-->
                        <p class="othermsg">
                        {!msg.fromName}<br/>
                        {!msg.msg}<br/>
                        {!msg.dateValue}
                        </p>
                    </apex:outputText>                                   
                    </apex:column>
                </apex:pageBlockTable>
                </apex:OutputPanel><br/>            
                <apex:inputTextarea value="{!currentMsg}"/>
                <apex:commandButton value="Send" action="{!sendmessage}" reRender="messages"/>               
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Component
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="ShowContactForAccount">
    <aura:attribute name="newContact" Type="Contact" default="{
                                                              sobjectName : 'Contact',
                                                              FirstName : '',
                                                              LastName : '',
                                                              Email : '',
                                                              Phone : ''
                                                              }"></aura:attribute>
    <aura:handler name="init" value="{!this}" action="{!c.showCOntactOnAccountPage}"/>
    <!--Create Contact-->
    <lightning:input type="text" label="First Name" value="{!v.newContact.FirstName}"/>
    <lightning:input type="text" label="Last Name" value="{!v.newContact.LastName}"/>
    <lightning:input type="email" label="Email" value="{!v.newContact.Email}"/>
    <lightning:input name="phone" label="Phone" value="{!v.newContact.Phone}"/>
    <lightning:button variant="success" label="Create Contact" title="Brand" onclick="{! c.createRecord }"/>
</aura:component>

Controller
    createRecord : function(component, event, helper) {
        alert(component.get('v.newContact'));
        var contact = component.get("v.newContact");
        var callMethod = component.get('v.createContact');
        callMethod.setParams({
            "accId" : component.get('v.recordId'),
            "con" : contact
        });
        callMethod.setCallback(this, function(response) {
            //var recs = response.getReturnValue();
            //component.set('v.contactList', recs);
        }, 'SUCCESS');
        $A.enqueueAction(callMethod);
    }
    
Apex Controller
public with sharing class ShowContactForAccount{

    @auraEnabled
    public Static Void createContact(String accId, Contact con){
    system.debug(con);
        con.AccountId = accId;
        Insert con;
    }
}

Error - Uncaught Action failed: c:MyShowRecordsComponentOnAccount$controller$createRecord [Cannot read property 'setParams' of undefined]
 
Why CurrencyIsoCode field is not showing in matching rule?
Hi Team,
 
I have created a Tab in my community. Then Added Report object in that tab.
But now the user can see every report in that tab.
I need to populate only some reports to users, not every report.
Is there any workaround?
 
Thanks in Advance,
I have this error when I try to execute this code Line: 1, Column: 16 Unexpected token '('.
I checked all the parentheses all of the in the code is correct.
 
public class MyId {   
    
	
    public static void show(){ 
        String url='https://drive.google.com/...../';
        system.debug(getId(url)); 
        }
    
    public static String getId(String gdriveUrl){
        String Id = gdriveUrl.remove('https://drive.google.com/.....');
        return Id;
	}

    
 }

 

Hi Team,

 

I have created a Button on a Lightning page. 

In that button added standard logic to create a budget Item object record.

Code

this[NavigationMixin.Navigate]({
            type: "standard__objectPage",
            attributes: {
                objectApiName: "Budget_Item__c",
                actionName: "new"
            },
            state: {
                nooverride: '1',
                defaultFieldValues: fieldValues
            }
        });


Its creating records perfectly. But the Issue is after the creation of record, It's navigating to a newly created record's detail page.

I want to stay on the previous page only(where I have added the button), No need to navigate the newly created record's detail page.

Is there any workaround? Urgently needed.

 

Thanks in advance,

Hi All,
How to calculate total revenue with all child records sum and display in parent account VF page.
Suppose I'm having Parent Account 'Top-level' with 2 child Accounts 'A' & 'B'.
Account  -- Revenue Field
A -- 100$
B -- 100$
Top Level --- A+B ie 200$

I have Tried Aggregate result but it is showing a list of accounts with the amount but not the total amount. 

In VF I need to show in this format  Top Level Account -- 200$
Please help me I'm new to development.

How can  I do like all accounts in one List or Map and add them? and assign to variable and display the variable.I'm not getting how to put this in Code.
I am new to apex and wondering if someone help me to do... 

update picklist from lookup value..

Example:- If i select india in lookup the picklist has to get updated as india.

whatever the value is selected in lookup needs to get updated in picklist.
I have 248 values needs to be updated.
Pick list using select option from apex.  VFpage + controller code
Write a program to display array of account object record - VFpage + controller code
My SOQL: [SELECT ID,Name, Status FROM Lead WHERE CreatedDateNotEqualToLastModified__c = TRUE AND LastModifiedDate >= LAST_N_DAYS:2];

Can anyone help with this URGENT?????

I am trying to write a trigger on Account that is essentially a rollup of related records on the Contact level. Not the most confident with apex so just looking for some guidance.. 

I have created it from the Event Reg object and have a for soql loop to get all Event Reg records, including the Contact and Contacts AccountId, but am stuck at what to do now. 

Any help would be much appreciated! 

Hello friends, I've been having an issue comparing a set of records across different objects. I need to retrieve a list of Lead Records where Lead.Email is the exact value as the email for a corresponding Person Account. 

I've tried doing this in Excel via a VLOOKUP, but the dataset is too large and will not work in Excel. I'm new to SOQL, so I'm wondering if this is possible. 

I'd need to retrieve a List of all Person Accounts where the email = Lead.Email with the following fields selected: Account ID, Account Name, Account Owner, Person_ID__pc. 
Hello,

I have a wrapper extension class that's intended to bring back grandchild records for a pageblock table within a Visualforce page. However, I keep getting errors when trying to save the Visualforce page referencing the extension controller. I'm not sure if there's a problem with the extension controller or the Visualforce page? Please see code below, any help is greatly appreciated!

VF Page:

<apex:page standardController="Consolidated_Invoicing__c" extensions="WrapperSarah"  renderas="pdf">

Extension Controller:

public class WrapperSarah{ 
private final Consolidated_Invoicing__c consinvs;
    public WrapperSarah(ApexPages.StandardController stdController) {
this.consinvs = (Consolidated_Invoicing__c)stdController.getRecord();
    }

Can provide the full code if needed but only getting errors after this has been added in following a salesforce guide.

Thanks!
I have created an Email Templete using object fields in the body of the email.

I have a trigger which occurs after the insert of a single record to a custom object I created. After the insert, I would like to send an email to a list of user. 

I found examples of how to do this but. . .how do you send the id of the record you would like to use when using the template with assigned object fields.

This is my code:

trigger WriteNotifications on CustomTable__c (After insert) {

  //This is not the actual select but gives an idea of how I am getting my data
//Declare variable
ID custom_ID;

for (CustomTable__c C_master : Trigger.new) {
        custom_id = C_master.Id;
    }

//Get the list of user ids
    List<User> lstUsed = [select id, name FROM USER where name =: 'Smith'];
   
  List<String> sendTo = new List<String>();

  for (User uses : lstUsed ){
       sendTo.add(uses.Id);
    }

 EmailTemplate et = [Select id from EmailTemplate where name = 'My Template' limit 1];

    Messaging.MassEmailMessage mail = new Messaging.MassEmail Message();
    mail.setTargetObjectIds(sendTo);
    mail.setSenderDisplayName('Sending Person');
    mail.setTemplateId(et.id);
    Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
}
How can pass the custom_ID value to the  Email Temple to reference the record from my custom table?