Sometimes when you use Test.loadData() you might receive some confusing error message saying “Validation Errors While Saving Record(s)”, it is hard to understand what is wrong in data so it is possible to use the following code to debug the problem
StaticResource sr = [SELECT Id, Body FROM StaticResource WHERE Name = 'TestData' LIMIT 1];
String body = sr.Body.toString();
String[] fields = body.split('\r\n')[0].split(',');
SObject[] records = new List();
String[] lines = body.split('\r\n');
for ( Integer j = 1; j < lines.size(); j++ ) {
SObject r = new Custom_Object__c();
String[] data = lines[j].split(',');
for (Integer i = 0; i < fields.size(); i++ ) {
System.debug(LoggingLevel.ERROR, '@@@ fields[i]: ' + fields[i] + ' + data[i] ' + data[i] );
r.put( fields[i], data[i]);
}
records.add( r );
}
insert records;
So when you run a code like this you will find out the exact problem you face
I have several updates. First of all, I have finally registered for PBO and it is active since today.
Also recently I have published a first version of my package to manage second generation managed packages to AppExchange.
I called it 2GPM or Second Generation Package Manager.
This package contains four tabs that help to preview aggregated information about 2G packages, versions, push upgrades, subscribers.
Since this is not possible to make standard reports on object Package, PackageVersion, PackageSubscriber, PushUpgrades, PushJob, PushJobError, and this is not possible to create a custom report type including these objects, it is open opportunity to fulfill this niche by a custom package on AppExchange.
Also another package available on AppExchange called Package Visualizerdoesn’t provide this functionality. Actually it provides it partially: it is possible to see the list of subscribers for a particular package or package version but it is not possible to see the whole list of subscribers or the whole list of package versions or the whole list of push upgrades. Also it is not possible to export the list of subscribers as a CSV file.
Package Usage
Package contains a custom Lightning Application which consists of four tabs.
Packages tab
Packages tab contains on the top part of the page aggregated information about total number of installs of particular package id. It doesn’t display packages which do not have any package versions. The bottom part of the page contains detailed aggregated information about package installations number per Org Status and Org Type.
It is possible to filter out Org Status to see information about installs only on specific Org Status in the bottom part.
It is possible to search against all fields (including Id), search affects both top and bottom panes.
Top pane includes also addressable links to list of versions and list of subscribers of a particular package.
Versions tab
Versions tab contains on the top part of the page aggregated information about total number of installs of particular package version id. Not Installed Beta Versions are always hidden intentionally on the aggregated view. However, it is possible to display installed beta versions or released versions that are not installed yet by unchecking appropriate checkboxes. For a released package version, push upgrade action is available to create push upgrade request and redirect to the corresponding tab.
The bottom part of the page contains detailed aggregated information about the number of package versions installations per Org Status and Org Type. By default it displays Released versions only, however, it is possible to display beta versions by unchecking the relevant checkbox. There is an option to download CSV data displayed on the bottom pane.
It is possible to filter out Org Status to see information about installs only on specific Org Status in the bottom part.
It is possible to search against all fields (including Id), search affects both top and bottom panes.
Top pane includes also addressable links to list of push upgrades and list of subscribers of a particular package version.
Upgrades tab
Upgrades tab contains detailed information about planned, pending and performed push upgrades. The last view column contains a link to see push upgrade details.
It is possible to search against all fields (including Id).
When a particular upgrade is selected, information is displayed about push jobs and push errors.
When a particular upgrade is selected in Created status, an additional list of plausible subscribers for upgrade selection is displayed. The user can select subscribers for an upgrade. The user can update scheduled start date time or keep it blank. The user can schedule or start the push upgrade by clicking the appropriate button.
Subscribers tab
Subscribers tab contains detailed information about subscribers.
It is possible to search against all fields (including Id).
It is possible to filter out Org Status to see information about installs only on specific Org Status.
It is possible to download the selected list as a CSV file.
Security Considerations
The package includes three permission sets and one permission set group.
Permission Set Package Manager Basic contains custom permission Package Manager Basic and provides access to packages, versions, subscribers tabs.
Permission Set Package Manager Push Upgrades contains custom permission Package Manager Push Upgrades and provides access to upgrades tab and system permission to manage second-generation packages.
Permission Set Package Manager Extract contains CRUD permission to Document standard object and provides access to extract functionality (Download CSV file of versions or subscribers list).
User is not displayed the download CSV button when the user lacks access to Document standard object.
Permission Set Group Package Manager Full contains access to all of these three permission sets and provides access to full functionality of the package.
In the future version I am considering removing the Permission Set Groups since some of my orgs do not have this feature enabled and also beta package versions containing PSG are not installed correctly.
Also I am going to release in the new version an option to switch between orgs.
I am Ukrainian. I had to move out of my home city Lviv because I wasn’t able to work productively under air alarms sirens firing several times each day. I am now travelling over Europe to find some place where I can stay until the war in Ukraine is over. If you know some place in Europe where I can stay for some time please let me know. Also I encourage you to donate to Ukrainian national bank to support Ukrainian Armed Forces.
This listing includes LWC component Icon Picker which allows to select Icon from SLDS Icons Library
It can be used in the following use cases
1. Component can be placed in Lightning App Builder “App page” and used in Dynamic Interactions
2. Component can be placed in Screen Flows
3. Component can be reused in other LWC
Using IconPicker in App page
Create a new App page or place the component on an existing App Page.
Go to App Builder in Setup
Click a New button to create a new App Builder page or use Edit to edit existing App Page
If you create a new Page, select App Page and click Next button
Define a label for the new page, for example, Demo, and select any layout, for example, header and left sidebar. Find Icon Picker component in the “Custom – Managed” section and Drag and Drop that component to any place, like header or sidebar.
You can add other components, your custom unpackaged components or the same component in another section. You can read about creating custom unpackaged LWC components embedding Icon Picker in the section “Use IconPicker in Custom LWC Development”. In the Properties pane, you can set header label and field level help and mandatory indicator, for example, use `Icon Picker – Pick an Icon` like header and `Here you can pick an SLDS Icon` as field level help. If you check the required checkbox, the red asterisk will appear on the screen.
On the Interactions pane, it is possible to configure the dynamic interactions.
For example, let’s set source the IconPicker component in the header section and target the custom TestComp component in the left sidebar and the IconPicker component in the main section. To start, click Interaction pane and then click Add Interaction button.
While the source component is selected in the App Builder, in the component selector select target component IconPicker component from Main Region.
Then set {!Event.icon} in SLDS Icon fullname value attribute
and then click the Save button. If you created a new Page, Activate the page and set access to profiles and add it to application
Select if you want to add the page to all profiles or only System Administrator and add to some app like Sales and click Add page to app
and then click Save button
Then click Back button
And then click again Add Interaction to add another interaction to testComp component
Select TestComp or your custom component as target in Component selector
Set {!Event.icon} into destination attribute SLDS Icon fullname value
and then click the Save button again. Now let’s see in action. Click on nine dots in the top left corner and input the App page name in search box and click on Demo in the results list.
On the demo tab, pick the icon and see that the picked icon is sent into two other components through Dynamic Interactions, so the same icon is now selected in two bottom components
Notice that configured header is displayed above the icon picker, the red asterisk is displayed since Required attribute checkbox is checked and the help text is displayed when mouse is hover the information icon
Using IconPicker in Screen Flows
It is possible to add IconPicker to Screen Flows.
Before doing that, please enable Enable Lightning runtime for flows in Setup/Process Automation Settings
Find Flows in Setup and click the New Flow button to create a new flow or reuse the existing Screen Flow and click on it.
If you create a new Flow, select Screen Flow type and click Next
Select Free Form
Find Screen in list of Elements on the Elements sidebar panel and drag and drop it into canvas
Once you have added Screen to Canvas, scroll down to the last Custom section and select Icon Picker and drop it into Screen canvas.
In the sidebar pane, you can set header label and field level help and mandatory indicator, for example, use `Icon Picker – Pick an Icon` like header label and `Here you can pick an SLDS Icon` as field level help. Use GlobalConstant.true or GlobalConstant.false to show or hide the red asterisk to appear on the screen. Set IconPicker as API Name.
Select screen properties and set value of label to something like `Icon Picker Screen` and API name or keep the default API name. Then click the Done button.
Choose what to do with the value, for example, you can create an Account record, whose Name is icon fullname. For that, select Create Records and drag and drop it into Flow canvas
Set Label and API Name to Create, select Use separate resources, and literal values in How to Set the Record Fields
Select Account as Object
Select Account Name as Field name
and then in value select Icon Picker and then SLDS Icon Fullname Value
Click on Done once finished
Add another Screen element and set Label and API Name to Final
Add a Display Text component to the Final Screen
Set API name to Created and Set Created account into the Text Box and then click insert Resource and select AccountId from Create
Then add with name and click again Insert a resource and select Icon Picker and then select Value (SLDS Icon Fullname Value)
Click Done now
Then connect Start element to Screen element and then Screen Element to Create records component and Create records component to Final Screen element.
Now click Save, then Activate and then Run. When prompted, set label and API name of Flow to Demo and set Description to `Demonstrate how Icon Picker element can be used in Screen Flow` and click Save
Once saved, click Activate and Run
When you run the demo, pick some icon
and then click Next
Now you should be able to see the confirmation that a new Account with given name which is equal to Icon name was created and now you can click the Finish button.
Using IconPicker in Custom LWC Development
You can use this component in your Custom LWC Development. Before you start, go to Setup Session Setting and check checkbox Use Lightning Web Security (beta) for Lightning web components. and click the Save button.
If you don’t perform this step, you will not be able to use cross-namespaced LWC components in your development.
Then create a new LWC and put some code into html file like this
Global attributes and methods of Icon Picker component
Before you start using any of attributes or methods, make sure you have read the previous section and have enabled Use Lightning Web Security (beta) for Lightning web components in Setup\Session Settings.
Attributes
NAME
TYPE
ACCESS
REQUIRED
DEFAULT
DESCRIPTION
header
String
global
The header label for the icon picker input
mandatory
Boolean
global
false
The indicator for the red box requiredness option
fieldLevelHelp
String
global
The help tooltip displayed on hover over the information icon when set
value
String
global
The value of selected icon (input and output)
Methods
NAME
ARGUMENTS
ACCESS
DESCRIPTION
reportValidity
global
Displays the error messages and returns false if the input is invalid.If the input is valid, reportValidity() clears displayed error messages and returns true.
Custom Events
select
The event fires when an icon is picked in the component.
The select event returns the following parameters.
“label”: {
“type”: “string”,
“title”: “Id and route in parentheses”,
“description”: “Id and route in parentheses”
},
“icon”: {
“type”: “string”,
“title”: “Full icon name to use in lightning-icon”,
“description”: “Full icon name to use in lightning-icon like {!Event.icon} here or in LWC &lt;lightning-icon icon-name={!icon}”
}
PARAMETER
TYPE
DESCRIPTION
label
string
Id and route in parentheses
icon
string
Full icon name to use in Dynamic interaction like {!Event.icon} or in LWC custom development <lightning-icon icon-name={!icon}
The select event properties are as follows.
PROPERTY
VALUE
DESCRIPTION
bubbles
false
This event doesn’t bubble up through the DOM. May be changed in future releases to true if subscribers prefer such option
cancelable
false
This event has no default behavior that can be canceled. You can’t call preventDefault() on this event.
composed
false
This event doesn’t propagate outside of the component in which it was dispatched. May be changed in future releases to true if subscribers prefer such option
Localization support for Icon Picker component
Translations are not included in the package distribution. However, a custom override is available for the “Empty” label and “Complete the field.” label.
On 9/3/2021 3:26 PM I have opened Salesforce support ticket asking why lightning:unsavedChanges is not working when exposed through Lightning Out. We had very long conversation over last two months, they have requested to provide org access to reproduce the issue and I have provided them. On 11/1/2021 8:31 PM Salesforce support suggests to raise an idea to have this supported in future releases. Two months have passed and the only workaround that Salesforce support can provide, it to suggest Idea on Idea Exchange. I have opened an idea https://ideas.salesforce.com/s/idea/a0B8W00000H4BVBUA3/support-lighningunsavedchanges-in-lightning-out
My original case description
The component “lighning:unsavedChanges” doesn’t work when exposed through Lightning Out
If component lightning:unsavedChanges is used in Aura component that is exposed via Lightning Out to the Visualforce Page and this page is set as a tab in the Lightning Expience, calling unsaved.setUnsavedChanges(true, { label: ‘My component name’ }); has no effect. Is this a bug?
Salesforce Support response
We have tried checking with different teams on the workaround for this problem , however it is not working as expected in lightning.
The lighning:unsavedChanges is not supported in Lightning Out , and hence our team has mentioned that we do not usually provide workarounds for features that are not supported.
However, I still tried my best to search for ways to make the classic api solution work , but that does not seem to work in lightning context.
Please do raise an idea to have this supported in the future releases.
Please let us know if you have any queries / concerns.
During the conversation, they suggested to use window.postMessage or classic api, and they didn’t believe that this doesn’t work, now I feel a little bit relieved that they confirmed that such solution doesn’t work.
BOF Per Man: Bulk Object and Field Permission Manager
This package allows editing Field and Object Security per Profiles and Permission Sets in bulk. It is very useful by Administrators and Developers to mass edit profiles and permission sets if the same set of permissions needs to be applied to several profiles, permission sets, objects or fields.
Now the package is upgraded to the 2GMP version. The new version includes the existing feature from the classic package version and brings new features of bulk object creation and bulk text field creation.
I have some weird requirement to display placeholder in the datatable and I don’t want to implement a custom datatable component for this but to use standard lightning:datatable.
Is this possible to implement such placeholder so that if a cell has blank value, a placeholder in gray text color is displayed instead of the value using standard lightning:datatable?
0
Recently a new feature was released which allows to define custom data types in standard lightning:datatable component.
Create a LWC component customTable with the following JS
import LightningDatatable from 'lightning/datatable';
import placeHolder from './placeHolder.html';
export default class CustomTable extends LightningDatatable {
static customTypes = {
placeHolder: {
template: placeHolder,
standardCellLayout: true,
typeAttributes: ['placeHolder'],
}
}
}
Create in the customTable folder additional file placeHolder.html
There could be several ways to automate sobject creation, if we need to create multiple custom objects.
If you use SFDX, it is possible to use shane plugin to create custom object metadata file and then deploy those files or create a package from them and install the package.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Another option is to use Metadata API and create them in Apex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On enterprise projects Users tend to have a lot of Permission Set assigned.
So sometimes it is hard to determine what kind of access they have to a particular object, since verifying the profile settings and all the permission sets settings is a cumbersome task.
Instead, a simple apex script can do this job.
First, we need to find the DurableId of the object which access we need to check.
For this, we need a simple SOQL Query
SELECT DurableId FROM EntityDefinition where QualifiedApiName = ‘CustomObject__c’
Then we need to combine this with a user id and separate them by a dot and query the corresponding record from UserEntityAccess object.
SELECT Id, IsCreatable, IsReadable FROM UserEntityAccess where DurableId = ’01I0r0000005CqU.0051K000008xPfC’
And now we can see the actual permissions which User has to a particular field.
To find which permission set provides read access to a field, use the following SOQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters