• BrianWX
  • NEWBIE
  • 15 Points
  • Member since 2009
  • Salesforce Technical Architect

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 18
    Replies
I am using Dataloader Windows version 53.0.3.  I use it to schedule to load data into Salesforce on a regular basis.
https://developer.salesforce.com/docs/atlas.en-us.dataLoader.meta/dataLoader/loader_batchmode_intro.htm
 
When I tried to load a csv file with 205K rows, it failed with error:
com.sforce.async.CSVReader$CSVParseException: Not expecting more text after end quote
 
The csv file was generated from SSIS (SQL Server Integration Services) that pulled data from a MSSQL.
 
The number of fields in my file was 6 columns.  The datatype was: number, text, text, number, text, number.
 
I have made sure the text columns were in double quotes to ensure proper char escape.  I used Notepad++ to check for weird hidden chars. I checked the last row for abnormality but could not anything unusual. 
 
Did anyone run into similar issue with data exporting from SSIS, and how did you resolve this?
 
Thanks,
Brian
 
PS: The Dataloader UI gave the error!
I have a schedule batch apex that execute this line of code:
 
Test.startTest();
String jobId = System.schedule('testSomeBatch', '0 0 13 * * ?', new ProcessScheduledBatch());
Test.stopTest();
From the cron expression, it'd run every day at 1:00 PM.

When I executed my test code and output the cron job, this is what I have:
ct: CronTrigger:{Id=08e2f00000MEbhJAAT, CronExpression=0 0 13 * * ?, TimesTriggered=0, State=WAITING, NextFireTime=2022-10-21 20:00:00}
I would expect it to have next run at 13:00:00 hour, not at 20:00:00 hour.

The cron expression I took directly from Apex Schedule documentation: https://developer.salesforce.com/docs/atlas.en-us.232.0.apexcode.meta/apexcode/apex_scheduler.htm

Did I miss anything?


 
I got this error when creating an LWC Action in a Custom Object.

Error: Invalid Data.
Review all error messages below to correct your data.
You can only create Quick Actions with actionSubtype matched with the Lightning Web Component you defined (Related field: Subtype)


dispatchIssue.html
<template>
   
</template>

dispatchIssue.js
import { LightningElement, api } from 'lwc';
export default class DispatchIssue extends LightningElement {
    @api invoke() {
        console.log("Hi, I'm an action.");
    }
}


dispatchIssue.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <masterLabel>Dispatch Issue</masterLabel>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordAction</target>
        <target>lightning__RecordPage</target>    
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordAction">
          <actionType>Action</actionType>        
        </targetConfig>
        <targetConfig targets="lightning__RecordPage">
            <supportedFormFactors>
                <supportedFormFactor type="Large" />
                <supportedFormFactor type="Small" />
            </supportedFormFactors>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

It was really odd.  I was able to create the Action, delete it completely, recompile, recreate the Action, but this time it threw this error....

Anything I missed here?
I created a simple LWC to be called from Actions and added to the "Salesforce Mobile and Lightning Experience Actions" section in the page layout.  The "Send Mail LWC" action displayed and worked properly when I logged in from a web browser, but not displaying in the Action list in Salesforce Mobile app.

Did I miss any configuration?

Page Layout Config
Page Layout Configuration

Browser Display
Browser


Mobile
User-added image

LWC Component
dispatchIssue.html

<template> </template>

dispatchIssue.js
import { LightningElement, api } from 'lwc';
export default class DispatchIssue extends LightningElement {
    @api invoke() {
        console.log("Hi, I'm an action.");
    }
}


dispatchIssue.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <masterLabel>Dispatch Issue</masterLabel>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordAction</target>
        <target>lightning__RecordPage</target>        
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordAction">
          <actionType>Action</actionType>        
        </targetConfig>
        <targetConfig targets="lightning__RecordPage">
            <supportedFormFactors>
                <supportedFormFactor type="Large" />
                <supportedFormFactor type="Small" />
            </supportedFormFactors>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>
Salesforce provided an example on how to do Data Table with Inline Editing (https://developer.salesforce.com/docs/component-library/documentation/lwc/data_table_inline_edit) capability.  When displaying a related field in the datatable column, it displays the ID instead of the relatedObject.Name.

For example, if I have a field Assignee__c that is related to the User object.  When displaying the Assignee__c field in the data table, it only displays the ID of the Assignee__c instead of the look up field that we can search and select a new user.

Does anyone know how to get around this?

Thanks,
Brianwx
I built a custom class and method to return the aggregate data to plot a chart using LWC.  For the purpose of example, I hardcode the AccountId for now.
public with sharing class lwcLifetimeSpendingController {
    @AuraEnabled (cacheable=true)
    public static List<AggregateResult> getAccountLifetimeSpending(){
        return [SELECT SUM(Service_Amount__c) Service, SUM(Subscription_Booking__c) Subscription  FROM Opportunity WHERE accountid = '0018000001G9dZUAAZ' and isclosed=true and iswon=true];
    }
}

Here's my JS file.  How do I retrieve the aggregate values from the custom apex controller and use in the JS?  I tried getSObjectValue, but that did not work as it worked only with field data from the return Object.
import { LightningElement,track,wire } from 'lwc';
import { getSObjectValue } from '@salesforce/apex';
import { loadScript } from 'lightning/platformResourceLoader';
import chartjs from '@salesforce/resourceUrl/chart';
import getAccountLifetimeSpending from '@salesforce/apex/lwcLifetimeSpendingController.getAccountLifetimeSpending';

const generateRandomNumber = () => {
    return Math.round(Math.random() * 100);
};

export default class LifetimeSpending extends LightningElement {    
    @wire(getAccountLifetimeSpending) lifetimeAggregateResult;
    @track error;
    
     //getSObjectValue does not work in this scenario
} //end export

Here's the sample of the HTML file
<template>
    <lightning-card title="Lifetime Spending" icon-name="custom:custom19">
        <div class="slds-m-around_medium">
            <canvas class="donut" lwc:dom="manual"></canvas>
        </div>
        <template if:true={error}>
            <c-error-panel errors={error}></c-error-panel>
        </template>    
    </lightning-card>
</template>


 

I have a report to track the bookings each week.  The summarized Amount gives me the total for each week.  What I am actually looking for is to calculate how much we have booked so far at the end of each week, or the rolling total.

Example:
Week1 = $WK1_Amount
Week2 = Week1 + $WK2_Amount
Week3 = Week1 + Week2 + $WK3_Amount
... and so on

 

It believe SFDC needs to develop a new summary formula for this, but I'd like to ask experts out there if you know how to calculate this on the report builder?

 

Please like this idea on the Idea Exchange: https://success.salesforce.com/ideaView?id=08730000000knonAAA

 

Thanks,

Brian

 

 

Hi,

 

I have a link that I include in an email template.  This link has opportunity name associated in the link.  Because the opportunity can contain spaces, I'd like to find out how I can url-enclode it.

 

For example:

This is the potential URL format I have: https://cs1.salesforce.com/a08/e?CF00N70000001ZiKE=NGFW+Replacement&CF00N70000001ZiKE_lkid=006S0000006A94f&retURL=%2F006S0000006A94f

 

The opportunity name is "NGFW Replacement".  If I don't enclode it will come out to email with a space, and the link will be broken.

 

Thanks,

Brian

I use AccountSource to identify the source of account coming from (manual, web, hoovers, website, google, etc).  I am working to use Data Loader to update existing accounts with general information, and want to populate value into AccountSource field.  I could not find AccountSource as an available option to map data from my spreadsheet.

 

Does anyone know why?  I have System Administrator profile.  I check security settings and I have both read and edit.

I have a custom object called Promotion__c.  It has the Owner refererence field to the User object.  In the User object I have custom field called "Theatre__c"

 

In my Visualforce email template, when I use {!relatedTo.Owner.Email} it works fine.  It errors out when I put in {!relatedTo.Owner.Theatre__c}.  The error is "Error: Invalid field Theatre__c for SObject Name"

 

Did I miss something?

 

 

Can we roll back to previous version of the Report module?

 

The new one is not user-friendly.  You have to do so many clicks to get to one reports.

 

Here are the frustrating parts:

1. You have several reports in a folder that need to modify.  You type in the folder name in the filter box. Great!  You click on the report folder.  It displays nothing because the view is default to "Recently View".  It took someone a while to figure out. Now you open a report to edit, then save it.  When exiting, it returns to the long list of report folders.  Now if you need to go back to that Report folder again, you have do the same all over again.  Imagine you have a lot of reports to do, this is frustrating.

 

2. This is on the end users part.  They are non-technical. When they open a Report folder, it displays nothing (because it defaults to "Recently View").  A lot my field users got confused with this because they thought all the reports were gone.  They have to submit helpdesk to ask why, and this is production lost.

 

3. A lot of time I don't want to view in "Recently View" by default but I have no way to change this.  If I go to a report folder, I don't want a couple more clicks to see all the reports.

 

Too many clicks for something simple to do is not so user-friendly.

 

Salesforce, can this be improved?

 

Thanks,

BrianSJ

Hi,

 

This should be a basic for getting values from a Visualforce page to a custom Controller,  but for some reason I can't get this to work.  I have a very basic form with one inputTextArea.  Once a user type something in and hit Submit, a customer Controller get this value and compose a singleEmailMessage to an email address.

 

Here is my Visualforce page codes:

 

 

<apex:page Controller="ApprovalController">
<apex:sectionHeader title="Request Approval" />

<apex:form >
<apex:message />
<apex:pageBlock >
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Lead Name: " for="Name" />
<apex:outputText id="Name" value="{!Name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Description" for="approvalDescription" />
<apex:inputTextarea id="approvalDescription" value="{!approvalDescription}" required="true" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:actionStatus id="status" startText="please wait..."/>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Submit" immediate="true" action="{!submit}" status="status" />
<apex:commandButton value="Cancel" immediate="true" action="{!cancel}" status="status" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Here is my custom controller codes:

 

public with sharing class ApprovalController {

String approvalDescription;


public String getApprovalDescription() {
return approvalDescription;
}

public void setApprovalDescription(String descr) {
this.approvalDescription = descr;
}

public void sendEmail() {
Messaging.Singleemailmessage mail = new Messaging.Singleemailmessage();
String[] toAddresses = new String[] {'mailqueue@email.com'};
String strSubject = 'Approval Request';

String strBody = '<p>Approver Team:</p>';
strBody = strBody + '<p>Please review and approve</p>';

strBody = strBody + 'Request Notes: ' + approvalDescription;

mail.setToAddresses(toAddresses);
mail.setReplyTo('no-reply@email.com');
mail.setSenderDisplayName('Request User');
mail.setSubject(strSubject);
mail.setUseSignature(false);
mail.setHtmlBody(strBody);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

} //sendEmail()

public PageReference cancel() {
PageReference pageRef = new PageReference('site.mycompany.com');
pageRef.setRedirect(true);
return pageRef;
}

public PageReference submit() {

sendEmail();

PageReference pageRef = new PageReference('site.mycompany.com');
pageRef.setRedirect(true);
return pageRef;


} //submit()
} //class

 

In my codes the setter is not able to pickup the value from the inputTextarea.  The approvalDescription is always null.  What did I do wrong?

 

Thank you for taking time and provide feedback.

 

Brian

Hi,

 

I have this situation.

 

I have a mapping table call SourceDetail__c.  It has RecordTypeId__c, LeadSubType__c, SourceDetailName__c.  I try to read the entire table into a Map.  Say it's a small table with 1000 rows.

 

Map<Id, SourceDetail__c> mSourceDetail = NEW Map<Id, SourceDetail__c>([SELECT RecordTypeId__c, LeadSubtype__c, SourceDetailName__c FROM SourceDetail__c]);

 

Will the Map key contain the RecordTypeId__c value from the SourceDetail__c table?

 

I try to use the following codes to see if it contains the RecordTypeId__c key from the table, but it returns null.

 

Boolean contains = mSourceDetail.containsKey('012V00000008U7h');

System.assertEquals(contains, True);

 

If I cannot do this, may you suggest a solution for my situation?

 

When I import leads, I need to update Lead Subtype field with value from the SourceDetail__c table base on the inserted lead RecordTypeId and Source Detail value.  In other word the SourceDetail__c table contains all the mapping values to Lead Subtype with RecordTypeId and SourceDetailName being the matching keys.

 

How do I address this in a bulkifiable manner?

 

I was thinking read all the SourceDetail__c into a Map<Id, SourceDetail__c> where Id is the RecordTypeId from this mapping table.

 

Then in the FOR(Lead l : TRIGGER.NEW), I match with the Map.  But the Map seems not contain the RecordTypeId as I wanted.  What can I do differently?

 

Thanks,

Brian

 

  • September 27, 2011
  • Like
  • 0

I have a trigger that, before insert, base on a value selected from a picklist on the Lead form, it will auto-populate another value to another field.  In order to do this, we maintain a mapping table where we select the mapping value from.

 

The issue I have is to write a test case.  When I do the System.assertEquals, becasue the Global_Lead_Subtype_New__c never formulated/populated from the lead object, it throws error when I try to compare two values: one inserted against one from lead object. 

 

I don't think I need to populate Lead_Subtype_New__c when formulate a lead in my test.  Would that defeat the purpose of the trigger?

 

Here are my codes.  What's the trick for doing this?

 

Trigger class:

 

trigger ETO_SourceDetail_LeadSubType on Lead (before insert) {
    // get current Lead.RecordTypeId   
    
    String strRecordTypeId = '';
    List<Id> recordTypeId = NEW List<Id>();
    List<Source_Detail__c> leadSubtype = NEW List<Source_Detail__c>();
    List<Integer> count = NEW List<Integer>();
    Integer i = 0;
    
    
    try {
        FOR (Lead l : TRIGGER.NEW) {
            try {    
                recordTypeId.add(l.recordTypeId);                      
                strRecordTypeId = recordTypeId.get(0);
                strRecordTypeId = strRecordTypeId.substring(0, 15);
                
                count.add([SELECT count() FROM Source_Detail__c WHERE Lead_Record_Type_Id__c = :strRecordTypeId AND Value_del__c = :l.Source_Details_New__c]);
                
                if (count.get(i) > 0) {
                    leadSubtype.add([SELECT Lead_Subtype__c FROM Source_Detail__c WHERE Lead_Record_Type_Id__c = :strRecordTypeId AND Value_del__c = :l.Source_Details_New__c LIMIT 1]);
                    l.Global_Lead_Subtype_New__c = leadSubtype.get(0).Lead_Subtype__c;
                }
                else {
                    l.Global_Lead_Subtype_New__c = 'Unknown';
                }
                
                System.debug('recordTypeId: ' + l.recordTypeId + ' - ' + 'Value_del__c: ' + l.Source_Details_New__c + ' - ' + 'strRecordTypeId: ' + strRecordTypeId );
                System.debug('Global_Lead_Subtype_New__c: ' + l.Global_Lead_Subtype_New__c);
                         
                i++;                                    
            } catch (Exception e) {
                l.addError('Error with Source Detail to Lead Subtype mapping. Please contact your administrator: ' + e);
            }
        } //for
    } catch(Exception e) {
        for(Lead l : Trigger.New){
            l.addError('Error with Source Detail to Lead Subtype mapping. Please contact your administrator: ' + e);
        }
    } //try        
        
    
} //class

Test method:

 

@isTest
private class testTrigger_ETO_SourceDetail_LeadSubType {
    static testMethod void myTestMethod() {
        Lead l = new Lead();
        
        l.recordTypeId = '01280000000Pxz2AAC';
        l.company = 'Test by Brian';
        l.firstName = 'Brian';
        l.lastName = 'Do';
        l.phone = '4087773456';
        l.email = 'briando@email.com';
        l.city = 'Chicago';
        l.state = 'IL';
        l.country = 'US';
        l.status = 'Open';
        l.Percent_to_Close__c = '0%';
        l.CurrencyIsoCode = 'USD';
        l.Sales_Rep_TMJ__c = 'Aaron Marks';
        l.OwnerId = '00580000003GON5';
        l.Source_Details_New__c = 'Austin eDM';       
        
        insert(l);
        
        Lead insertedLead = [SELECT Id, Global_Lead_Subtype_New__c FROM Lead WHERE Id = :l.Id LIMIT 1];
        
        
        System.assertEquals(insertedLead.Global_Lead_Subtype_New__c, l.Global_Lead_Subtype_New__c);
    }
} //end class



Thank you in advance.

 

Brian

  • September 20, 2011
  • Like
  • 0

I have this Batch Apex codes out Salesforce help page.  I tried it and I kept getting this error:

COMPILE ERROR: Variable is not visible: query
LINE: 3 COLUMN: 1

 

From the codes standpoint, I am not sure where the codes missed.

 

Here is the Apex class:

 

global class OwnerReassignment implements Database.Batchable<sObject>{
String query;
String email;
Id toId;
Id fromId;

global database.querylocator start(Database.BatchableContext BC){
            return Database.getQueryLocator(query);}

global void execute(Database.BatchableContext BC, List<sObject> scope){
    List<Account> accns = new List<Account>();

   for(sObject s : scope){Account a = (Account)s;
        if(a.Id==fromId){
            a.Rating = 'Warm';
            accns.add(a);
            }
        }

update accns;
   
}
global void finish(Database.BatchableContext BC){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

mail.setToAddresses(new String[] {email});
mail.setReplyTo('briandowx@yahoo.com');
mail.setSenderDisplayName('Batch Processing');
mail.setSubject('Batch Process Completed');
mail.setPlainTextBody('Batch Process has completed');

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}

 

Here is the Apex execute codes that I used to run in Workbench or System Log:

 

id u = '0017000000MHEYd';
OwnerReassignment reassign = new OwnerReassignment();
reassign.query = 'SELECT Id, Name, OwnerId FROM Account WHERE Id=\'' + u + '\'';
reassign.email = 'admin@acme.com';
reassign.fromId = '0017000000MHEYd';
reassign.toId = '0017000000MHEYd';
ID batchprocessid = Database.executeBatch(reassign);

 

Thank you in advance your help.

Brian


  • September 09, 2011
  • Like
  • 0
Salesforce provided an example on how to do Data Table with Inline Editing (https://developer.salesforce.com/docs/component-library/documentation/lwc/data_table_inline_edit) capability.  When displaying a related field in the datatable column, it displays the ID instead of the relatedObject.Name.

For example, if I have a field Assignee__c that is related to the User object.  When displaying the Assignee__c field in the data table, it only displays the ID of the Assignee__c instead of the look up field that we can search and select a new user.

Does anyone know how to get around this?

Thanks,
Brianwx
I am using Dataloader Windows version 53.0.3.  I use it to schedule to load data into Salesforce on a regular basis.
https://developer.salesforce.com/docs/atlas.en-us.dataLoader.meta/dataLoader/loader_batchmode_intro.htm
 
When I tried to load a csv file with 205K rows, it failed with error:
com.sforce.async.CSVReader$CSVParseException: Not expecting more text after end quote
 
The csv file was generated from SSIS (SQL Server Integration Services) that pulled data from a MSSQL.
 
The number of fields in my file was 6 columns.  The datatype was: number, text, text, number, text, number.
 
I have made sure the text columns were in double quotes to ensure proper char escape.  I used Notepad++ to check for weird hidden chars. I checked the last row for abnormality but could not anything unusual. 
 
Did anyone run into similar issue with data exporting from SSIS, and how did you resolve this?
 
Thanks,
Brian
 
PS: The Dataloader UI gave the error!
I got this error when creating an LWC Action in a Custom Object.

Error: Invalid Data.
Review all error messages below to correct your data.
You can only create Quick Actions with actionSubtype matched with the Lightning Web Component you defined (Related field: Subtype)


dispatchIssue.html
<template>
   
</template>

dispatchIssue.js
import { LightningElement, api } from 'lwc';
export default class DispatchIssue extends LightningElement {
    @api invoke() {
        console.log("Hi, I'm an action.");
    }
}


dispatchIssue.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <masterLabel>Dispatch Issue</masterLabel>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordAction</target>
        <target>lightning__RecordPage</target>    
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordAction">
          <actionType>Action</actionType>        
        </targetConfig>
        <targetConfig targets="lightning__RecordPage">
            <supportedFormFactors>
                <supportedFormFactor type="Large" />
                <supportedFormFactor type="Small" />
            </supportedFormFactors>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

It was really odd.  I was able to create the Action, delete it completely, recompile, recreate the Action, but this time it threw this error....

Anything I missed here?
I created a simple LWC to be called from Actions and added to the "Salesforce Mobile and Lightning Experience Actions" section in the page layout.  The "Send Mail LWC" action displayed and worked properly when I logged in from a web browser, but not displaying in the Action list in Salesforce Mobile app.

Did I miss any configuration?

Page Layout Config
Page Layout Configuration

Browser Display
Browser


Mobile
User-added image

LWC Component
dispatchIssue.html

<template> </template>

dispatchIssue.js
import { LightningElement, api } from 'lwc';
export default class DispatchIssue extends LightningElement {
    @api invoke() {
        console.log("Hi, I'm an action.");
    }
}


dispatchIssue.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <masterLabel>Dispatch Issue</masterLabel>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordAction</target>
        <target>lightning__RecordPage</target>        
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordAction">
          <actionType>Action</actionType>        
        </targetConfig>
        <targetConfig targets="lightning__RecordPage">
            <supportedFormFactors>
                <supportedFormFactor type="Large" />
                <supportedFormFactor type="Small" />
            </supportedFormFactors>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>
I am new to SFDC and would like to know how we can create multiple columns in quote page in lightening so that users can input their values in few of the cells.
Salesforce provided an example on how to do Data Table with Inline Editing (https://developer.salesforce.com/docs/component-library/documentation/lwc/data_table_inline_edit) capability.  When displaying a related field in the datatable column, it displays the ID instead of the relatedObject.Name.

For example, if I have a field Assignee__c that is related to the User object.  When displaying the Assignee__c field in the data table, it only displays the ID of the Assignee__c instead of the look up field that we can search and select a new user.

Does anyone know how to get around this?

Thanks,
Brianwx
I built a custom class and method to return the aggregate data to plot a chart using LWC.  For the purpose of example, I hardcode the AccountId for now.
public with sharing class lwcLifetimeSpendingController {
    @AuraEnabled (cacheable=true)
    public static List<AggregateResult> getAccountLifetimeSpending(){
        return [SELECT SUM(Service_Amount__c) Service, SUM(Subscription_Booking__c) Subscription  FROM Opportunity WHERE accountid = '0018000001G9dZUAAZ' and isclosed=true and iswon=true];
    }
}

Here's my JS file.  How do I retrieve the aggregate values from the custom apex controller and use in the JS?  I tried getSObjectValue, but that did not work as it worked only with field data from the return Object.
import { LightningElement,track,wire } from 'lwc';
import { getSObjectValue } from '@salesforce/apex';
import { loadScript } from 'lightning/platformResourceLoader';
import chartjs from '@salesforce/resourceUrl/chart';
import getAccountLifetimeSpending from '@salesforce/apex/lwcLifetimeSpendingController.getAccountLifetimeSpending';

const generateRandomNumber = () => {
    return Math.round(Math.random() * 100);
};

export default class LifetimeSpending extends LightningElement {    
    @wire(getAccountLifetimeSpending) lifetimeAggregateResult;
    @track error;
    
     //getSObjectValue does not work in this scenario
} //end export

Here's the sample of the HTML file
<template>
    <lightning-card title="Lifetime Spending" icon-name="custom:custom19">
        <div class="slds-m-around_medium">
            <canvas class="donut" lwc:dom="manual"></canvas>
        </div>
        <template if:true={error}>
            <c-error-panel errors={error}></c-error-panel>
        </template>    
    </lightning-card>
</template>


 

Hi,

 

I have a link that I include in an email template.  This link has opportunity name associated in the link.  Because the opportunity can contain spaces, I'd like to find out how I can url-enclode it.

 

For example:

This is the potential URL format I have: https://cs1.salesforce.com/a08/e?CF00N70000001ZiKE=NGFW+Replacement&CF00N70000001ZiKE_lkid=006S0000006A94f&retURL=%2F006S0000006A94f

 

The opportunity name is "NGFW Replacement".  If I don't enclode it will come out to email with a space, and the link will be broken.

 

Thanks,

Brian

I have a custom object called Promotion__c.  It has the Owner refererence field to the User object.  In the User object I have custom field called "Theatre__c"

 

In my Visualforce email template, when I use {!relatedTo.Owner.Email} it works fine.  It errors out when I put in {!relatedTo.Owner.Theatre__c}.  The error is "Error: Invalid field Theatre__c for SObject Name"

 

Did I miss something?

 

 

How to create input forms  using siteforce and where do we capture that data?

Hi,

 

This should be a basic for getting values from a Visualforce page to a custom Controller,  but for some reason I can't get this to work.  I have a very basic form with one inputTextArea.  Once a user type something in and hit Submit, a customer Controller get this value and compose a singleEmailMessage to an email address.

 

Here is my Visualforce page codes:

 

 

<apex:page Controller="ApprovalController">
<apex:sectionHeader title="Request Approval" />

<apex:form >
<apex:message />
<apex:pageBlock >
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Lead Name: " for="Name" />
<apex:outputText id="Name" value="{!Name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Description" for="approvalDescription" />
<apex:inputTextarea id="approvalDescription" value="{!approvalDescription}" required="true" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:actionStatus id="status" startText="please wait..."/>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Submit" immediate="true" action="{!submit}" status="status" />
<apex:commandButton value="Cancel" immediate="true" action="{!cancel}" status="status" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Here is my custom controller codes:

 

public with sharing class ApprovalController {

String approvalDescription;


public String getApprovalDescription() {
return approvalDescription;
}

public void setApprovalDescription(String descr) {
this.approvalDescription = descr;
}

public void sendEmail() {
Messaging.Singleemailmessage mail = new Messaging.Singleemailmessage();
String[] toAddresses = new String[] {'mailqueue@email.com'};
String strSubject = 'Approval Request';

String strBody = '<p>Approver Team:</p>';
strBody = strBody + '<p>Please review and approve</p>';

strBody = strBody + 'Request Notes: ' + approvalDescription;

mail.setToAddresses(toAddresses);
mail.setReplyTo('no-reply@email.com');
mail.setSenderDisplayName('Request User');
mail.setSubject(strSubject);
mail.setUseSignature(false);
mail.setHtmlBody(strBody);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

} //sendEmail()

public PageReference cancel() {
PageReference pageRef = new PageReference('site.mycompany.com');
pageRef.setRedirect(true);
return pageRef;
}

public PageReference submit() {

sendEmail();

PageReference pageRef = new PageReference('site.mycompany.com');
pageRef.setRedirect(true);
return pageRef;


} //submit()
} //class

 

In my codes the setter is not able to pickup the value from the inputTextarea.  The approvalDescription is always null.  What did I do wrong?

 

Thank you for taking time and provide feedback.

 

Brian

Hi,

 

I have this situation.

 

I have a mapping table call SourceDetail__c.  It has RecordTypeId__c, LeadSubType__c, SourceDetailName__c.  I try to read the entire table into a Map.  Say it's a small table with 1000 rows.

 

Map<Id, SourceDetail__c> mSourceDetail = NEW Map<Id, SourceDetail__c>([SELECT RecordTypeId__c, LeadSubtype__c, SourceDetailName__c FROM SourceDetail__c]);

 

Will the Map key contain the RecordTypeId__c value from the SourceDetail__c table?

 

I try to use the following codes to see if it contains the RecordTypeId__c key from the table, but it returns null.

 

Boolean contains = mSourceDetail.containsKey('012V00000008U7h');

System.assertEquals(contains, True);

 

If I cannot do this, may you suggest a solution for my situation?

 

When I import leads, I need to update Lead Subtype field with value from the SourceDetail__c table base on the inserted lead RecordTypeId and Source Detail value.  In other word the SourceDetail__c table contains all the mapping values to Lead Subtype with RecordTypeId and SourceDetailName being the matching keys.

 

How do I address this in a bulkifiable manner?

 

I was thinking read all the SourceDetail__c into a Map<Id, SourceDetail__c> where Id is the RecordTypeId from this mapping table.

 

Then in the FOR(Lead l : TRIGGER.NEW), I match with the Map.  But the Map seems not contain the RecordTypeId as I wanted.  What can I do differently?

 

Thanks,

Brian

 

  • September 27, 2011
  • Like
  • 0

I have a trigger that, before insert, base on a value selected from a picklist on the Lead form, it will auto-populate another value to another field.  In order to do this, we maintain a mapping table where we select the mapping value from.

 

The issue I have is to write a test case.  When I do the System.assertEquals, becasue the Global_Lead_Subtype_New__c never formulated/populated from the lead object, it throws error when I try to compare two values: one inserted against one from lead object. 

 

I don't think I need to populate Lead_Subtype_New__c when formulate a lead in my test.  Would that defeat the purpose of the trigger?

 

Here are my codes.  What's the trick for doing this?

 

Trigger class:

 

trigger ETO_SourceDetail_LeadSubType on Lead (before insert) {
    // get current Lead.RecordTypeId   
    
    String strRecordTypeId = '';
    List<Id> recordTypeId = NEW List<Id>();
    List<Source_Detail__c> leadSubtype = NEW List<Source_Detail__c>();
    List<Integer> count = NEW List<Integer>();
    Integer i = 0;
    
    
    try {
        FOR (Lead l : TRIGGER.NEW) {
            try {    
                recordTypeId.add(l.recordTypeId);                      
                strRecordTypeId = recordTypeId.get(0);
                strRecordTypeId = strRecordTypeId.substring(0, 15);
                
                count.add([SELECT count() FROM Source_Detail__c WHERE Lead_Record_Type_Id__c = :strRecordTypeId AND Value_del__c = :l.Source_Details_New__c]);
                
                if (count.get(i) > 0) {
                    leadSubtype.add([SELECT Lead_Subtype__c FROM Source_Detail__c WHERE Lead_Record_Type_Id__c = :strRecordTypeId AND Value_del__c = :l.Source_Details_New__c LIMIT 1]);
                    l.Global_Lead_Subtype_New__c = leadSubtype.get(0).Lead_Subtype__c;
                }
                else {
                    l.Global_Lead_Subtype_New__c = 'Unknown';
                }
                
                System.debug('recordTypeId: ' + l.recordTypeId + ' - ' + 'Value_del__c: ' + l.Source_Details_New__c + ' - ' + 'strRecordTypeId: ' + strRecordTypeId );
                System.debug('Global_Lead_Subtype_New__c: ' + l.Global_Lead_Subtype_New__c);
                         
                i++;                                    
            } catch (Exception e) {
                l.addError('Error with Source Detail to Lead Subtype mapping. Please contact your administrator: ' + e);
            }
        } //for
    } catch(Exception e) {
        for(Lead l : Trigger.New){
            l.addError('Error with Source Detail to Lead Subtype mapping. Please contact your administrator: ' + e);
        }
    } //try        
        
    
} //class

Test method:

 

@isTest
private class testTrigger_ETO_SourceDetail_LeadSubType {
    static testMethod void myTestMethod() {
        Lead l = new Lead();
        
        l.recordTypeId = '01280000000Pxz2AAC';
        l.company = 'Test by Brian';
        l.firstName = 'Brian';
        l.lastName = 'Do';
        l.phone = '4087773456';
        l.email = 'briando@email.com';
        l.city = 'Chicago';
        l.state = 'IL';
        l.country = 'US';
        l.status = 'Open';
        l.Percent_to_Close__c = '0%';
        l.CurrencyIsoCode = 'USD';
        l.Sales_Rep_TMJ__c = 'Aaron Marks';
        l.OwnerId = '00580000003GON5';
        l.Source_Details_New__c = 'Austin eDM';       
        
        insert(l);
        
        Lead insertedLead = [SELECT Id, Global_Lead_Subtype_New__c FROM Lead WHERE Id = :l.Id LIMIT 1];
        
        
        System.assertEquals(insertedLead.Global_Lead_Subtype_New__c, l.Global_Lead_Subtype_New__c);
    }
} //end class



Thank you in advance.

 

Brian

  • September 20, 2011
  • Like
  • 0
Hi,
 
Is there way to create the validation rule on the particula custom field Name(Text(255) under Opportunity object.
There should be a restriction in that particular field that it should only allow western characters. Is it possible?
 
please respond.
regards
pannar 
  • December 05, 2008
  • Like
  • 0