Search In This Blog

2020-03-02

ERROR: VS Code deploy source to salesfores return 1

The situation
  • First time install VSC and salesforce extension pack
  • Success in web login auth to sfdc
  • Success in download source from sfdc
  • Failed in deploy

Fix by:
Upgrade the version of salesforce extension pack.
Terminal command: sfdx update

2020-01-15

getElement is not working in Lightning tag

SFDC defines it as Invalid DOM Access.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/security_dom.htm
<lightning:card aura:id="map" title="Current Boat Location">
    <div style="{!'width: ' + v.width + '; height: ' + v.height}">
        Please make a selection
    </div>
</lightning:card>

Because c:domLocker, below will be error.
var mapElement = component.find("map").getElement();

Change Dom as:
<lightning:card title="Current Boat Location">
    <div aura:id="map" style="{!'width: ' + v.width + '; height: ' + v.height}">
        Please make a selection
    </div>
</lightning:card>

2018-01-19

Salesforce Credentials Exam Sample

A developer is creating unit tests for code that makes SOAP web service callouts. The developer needs to insert some test data as a part of the unit tests setup. How should the developer enable this functionality?

Choose 3 answers.

A:Surround the callout with Test.startTest(), Test.stopTest()
B:Surround the data insertion with Test.startTest(), Test.stopTest()
C:Implement the WebServiceMock interface
D:Update code to call Test.setMock()
E:Implement the HttpCalloutMock interface
The Answer is A,C,D.

2016-10-29

Output data in 3 columns by repeat in Visualforce


There're a lot way to output a list of strings in 3 columns, like 3*n.

Here are two ways.

First need to get the value of list before output, list should be able to public get. Here is an example.
// [sample] string[]
public String[] getSampleStrings() {
    return new String[]{'ONE','TWO','THREE','FOUR','FIVE','SIX','SEVEN','EIGHT','NINE'};
}
Way 1: Use first and rows in apex:outputPanel
// Repeat sample start (by first and rows)
<apex:outputpanel layout="block">
    <apex:repeat first="1" rows="3" value="{!sampleStrings}" var="sampStr">
        <apex:outputtext style="padding: 0 10px;" value="{!sampStr}">
    </apex:outputtext></apex:repeat>
</apex:outputpanel>
<apex:outputpanel layout="block">
    <apex:repeat first="4" rows="3" value="{!sampleStrings}" var="sampStr">
        <apex:outputtext style="padding: 0 10px;" value="{!sampStr}">
    </apex:outputtext></apex:repeat>
</apex:outputpanel>

2016-09-28

Changing a user's email address without confirmation.

When try to change user's email, Salesforce will send a confirmation mail to new email address and a notification mail to old email address in security purpose.But sometimes user don't want to get further notifications.

To avoid send notification mail to old email, try ways follow. (All ways are no working with owner)

Way 1. Set Setup | Manage | User Management | Users
When change the email address, "Generate new password and notify user immediately" checkbox (at the bottom of the edit screen) need to be checked. Then the email address will get committed right away, no more confirmation needed! But obviously the user then gets sent a new password.


Way 2. Change email through Develop console
1.Select user data [select id,email,username from user]
2.Change the target user's email and click [Save Rows]
3.Click [Refresh Grid] to check if email is been changed.
*(2016/09/28) Some license may not working, like "Company Communities".


Way 3. Change email by code
User user = [select id,email from user where id = 'target user id'];
user.email = 'new_email@exmple.com';
update user;
*If use upsert, it will have a error: "DML not allowed on User". No matter if the record already exists or updating or creating new
*(2016/09/28) Some lisence may not working, like "Company Communities"
*(2021/11/5 update) Looks like Salesforce had removed Way 3 completely.