Debug “Validation Errors While Saving Record(s)” error message when calling Test.loadData()

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

Posted in salesforce | Leave a comment

SOQL Query peculiarities in with sharing context

An interesting fact.
If there are objects A and B and object C has lookups to A and B, and user has access to records of C but doesn’t have access to records of B, user can receive B data by quering C, but not by querying directly B.
So, inside an apex class having with sharing context, the following queries

Select Id, ( SELECT Id, B__c, B__r.Name FROM C__r ) FROM A and

SELECT Id, Name FROM B__c WHERE ID IN ( SELECT B__c FROM C__C )
might return different results.
When user has access to 1 of 4 records of B, by the first query user receives data about all record of B, but in the second case about only one.

Posted in SOQL | Tagged , , | Leave a comment

BOF Per Man 1.0.3

Today I have released a new version 1.0.3 of Bof Per Man.
I will fix two internal errors preventing users from installing this package in some cases and organization settings.

#23 If Subscriber Admin has Email Administration set to “System Email”, install or upgrade fails Discovered in 1.0.2 Fixed in 1.0.3
#19 Push Upgrade Failure. Discovered in 1.0.2 Fixed in 1.0.3

The previous release notes:

 

Posted in bofperman | Leave a comment

Published a repo to get Trailhead Data

Earlier I have mentioned that I was using some trailhead api workaround to get Trailhead data and I was fascinated by the app created by others

Now I have decided to investigate more and publish some app to get trailhead data. It should be updated often but it works at March 2020.

I have also published to code https://github.com/Patlatus/Salesforce-Trailhead-Api-Hack

This is a hack implementation to get access to Trailhead API to get Trailhead user points and other attributes. Requests should be used in the form https://trailheadapi.herokuapp.com/?link=/id/userAlias

Posted in Git, salesforce, Uncategorized | Tagged , , , , , , | 2 Comments

Release notes for BofPerMan Version 1.0.2

The following items have been fixed in version 1.0.2

Install error in Group and Professional Edition.
Inability to select Authorization Form and Scorecards in object list in OLS.
Idea, Pricebook2, Product2 and PushTopic do not allow Modify All permission but this wasn’t reflected on OLS.
On search, previous selection is removed: objects, fields, profiles and permission sets.
No spinner on save in OLS and FLS shown
Fields Contract.EndDate and Individual.MasterRecord displayed as Writeable
CPU Time Error for 918 records update

For CPU Time Error, a quick fix was introduced.
The process takes too much CPU time on processing Upsert Save Results when there are more than 306 records to save. Proposed Quick Fix includes avoiding calculation of Upsert Save Results for more than 306 records saving and appropriate message is shown.

I could think of implementation of some generic Event Streaming API subscription as long term fix later.

Also I tried to implement some more features but wasn’t able because of platform limitations.
There is no way to set FLS for fields on ScorecardMetric in Apex, so I can’t expose this in my package.
I would like to add support of Custom Settings and Custom Metadata OLS to my package but this is not yet supported by Apex as well.

Posted in bofperman, Release Notes | 1 Comment

Thanks for the interest in Bof Per Man package

Thanks for submitting web to lead form.

I appreciate your interest in Bof Per Man package

Posted in bofperman | Leave a comment

Shot a promo video for my Package BofPerMan

Today I have shot a promo video describing capabilities of my package BofPerMan which is published on AppExchange.

Here I discuss a possible case of a content management application consisting of two custom objects Book and Movie and a task to set Modify All and Create permission to both of these objects to two custom profiles, Content Manager User and Media Administrator and to Content Manager custom permission set. While this might be nasty and complicated task to perform using standard UI, it can be achieved in few clicks using BofPerMan package! Watch and see this in action

Posted in bofperman, Uncategorized | Tagged , , , , , , , , , , , , , | Leave a comment

BofPerMan 1.0.1 and 1.1.1 Release Notes

Recently I was very happy that my first package has passed security review on AppExchange. I decided to shot a video but noticed one bug, so I decided to fix it and one more bug which I had noticed before. Now I am releasing patch version 1.1.1 which includes fixes to issues #2 and #3.

BofPerMan 1.0.1 and 1.1.1 Release Notes

Fixed bugs:

BofPerMan #2: Unable to set FLS for Standard Profiles

While OLS are not available for Standard Profiles, FLS are available and there should be an option to set FLS settings for the standard profiles and checkboxes should not be readonly

BofPerMan #3: Double click on Exclude standard profiles or Exclude managed packages doesn’t reverse selection

Double click on Exclude standard profiles or Exclude managed packages doesn’t reverse selection

Also I have noticed that the wrong version of package is attached to listing (1.0 instead of 1.1) so I will contact Salesforce support to fix it.

Posted in bofperman | Tagged , , , , , , , , , , | 1 Comment

My very first package published to AppExchange

Today is the Saint Nickolas day in Ukraine by Julian Calendar. I have received a very special gift from Saint Nickolas recently. A few days ago, namely, on the 16th of December 2019, the very first of my own package has been passed Security Review and approved by Salesforce team for publishing on AppExchange.

I designed this package on the 18th of February 2019 and implemented required Apex code on the 18th of March 2019. During April I was working on LWC UI components. On the 20th of June, Salesforce has approved my Business plan to share this package for free. On the 29th of June I have submitted this package for Security Review.

On the 26th of August I have received an email that my package hasn’t pass security review.  Then on the 11th of December I have submitted a new version of package and resubmitted it for security review and finally on the 16th of December 2019, I got a green light from Salesforce for publishing it to AppExchange.

 

This is the link to my package on AppExchange

https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000FtWcBUAV&preview=%222019-12-16T11%3A32%3A00.000Z%22

 

This package allows to bulk edit Field and Object Security per Profiles and Permission Sets. I think it would be 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.

 

I would like to receive a feedback from real users. Earlier I have exposed a demo version of this package to one person and this person has left their feedback at github page I created for this package feedback. I have partially implemented the request from that user in my package. Also I have listed another improvement I might implement later. This is the page where you can suggest an improvement or report a bug

https://github.com/Patlatus/BofPerMan/issues

I am looking forward to receive feedback.

Posted in Administration, bofperman, package, User Management | Tagged , , , , , , , , , , | 2 Comments

Salesforce Bug in Tests: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

I have finally reproduced the bug about “System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out ” error being raised when it should not be raised. It happens when there is a thrown and caught mixed DML Exception in the setup transaction inside a Queueable job, and a callout from queueable or batchable in the test transaction (but not in future method).

Code of dummy batchable class b can be located here: https://gist.github.com/bdovhan/76326745c347dde00717c0318e3bc15b

Code of Apex Test Class TRB reproducing the CalloutException bug referencing class b in one test method can be found here

In this class, there are three apex test methods. Methods testB and testQ, which make callout from Queueable or Batchable, fail, while method testF, which makes callout from Future method, doesn’t fail.

I have also created a repository which contains both apex classes and setup scripts to create a scratch org and push the script to the scratch org.

Currently working with Salesforce support to identify this as an issue and retrieve from them acknowledge of this issue.

 

 

 

Posted in Bugs, platform-bug, salesforce | Leave a comment

Migrating from PC to Mac

Today is my first day working on the Mac machine.

I feel very awkward since I don’t know how to perform basic operations on Mac (I used PC over 15-20 years I think).

So I need some cheatsheet to help myself.

Cmd-Ctrl-Q: Lock screen.

Cmd-W, Cmd-Q: Close window or tab

Shift-7, Shift-6: insert comma or dot on Ukrainian keyboard layout.

Shift-Cmd-5: invoke video screen capture tool. Cmd-Ctrl-Esc to finish video capturing.

Shift-Cmd-4: Printscreen selected region.

Shift-Cmd-3: Printscreen.

Cmd-Left: Move cursor to the beginning of the line.

Cmd-Right: Move cursor to the ending of the line.

 

open /: invoke finder window with root folder

which sfdx: display location of the executable file

 

Posted in Mac | Leave a comment