Gorav Seth

Salesforce MVP (HOF) | Permaculture designer
Me on Mastodon

Page 3

Embedding a PDF on a formassembly form

Some folks needed a form that had an embedded pdf for review. I was hoping to find something that works on desktop, and works or is at least not a total disaster on mobile.

Found the pdfobject js library : https://pdfobject.com/ which seemed to know a bit about the subject. Tried all the ‘static’ / pure html approaches, and discovered the formassembly blocks the tag which otherwise worked perfectly well. Note - you can actually save a form w the object tag, but it will disappear the next time you open it. Support says they will work on blocking it better soon

So tried out the js approach, and it worked out well. Works great on desktop and displays the ‘fallback’ option to download the pdf on mobile devices that do not support embedded pdfs.

Here is how to do it

To start, create a form with two sections, and one text area in each section. Make the second section a hidden...

Continue reading →

Evaluating max/min of multiple date fields in flow

I have 3 date fields on an object and i need the MIN of the 3. But the MIN formula function does not allow dates, just numbers

IF could work for up to 3, and there are some solutions out there using formulas, but seemed fragile / complex.

So, solved via flow

  1. create a variable, type = date; name it vaMinimumDate

  2. use an assignment element to add all the date fields from the object to a collection variable (doesnt matter if the dates are null or not)

  3. loop over the collection variable

  4. in the loop, use a decision to evaluate if the current loop variable is less than vaMinimumDate



To test if the date field is blank/null, create a formula field, type = date, value = NULL, and then in the decision you can test equals/not equals formulaField.


The outcomes in the decision need to be in this order
a) is loop variable null - if so, pass on this iteration
b) is...

Continue reading →

Removing null value from collection

I managed to add a null value to a text collection, and found a way to remove it.

How did I end up with this mess?
I have a loop that splits a comma separated string, and adds each item to a text collection. This string is normally a bunch of external IDs, but I ended up with

Result{!vaCSTextToSplit} = "70140000000cokEAAQ,, master_AshokaUpdates,news_USA,"

see that extra comma in there before ‘master’ - when that ran through the split-o-matic it created a collection that had a null / blank value in it. i use blank/null intentionally here, as i really was not sure which one it was.

{!collCampaignIDs} = "[70140000000cokEAAQ,,master_AshokaUpdates,news_USA,MASTER]"

and that was causing some (silent) havoc downstream when we looped over the collection to get a campaign record filtering against that external ID. the flow would pull a random campaign that had a blank external ID...

Continue reading →

Checking for blank in Flow

A few days ago I asked

am i the only person who is still confused about equals globalconstant.emptystring vs isnull = true in flows? i swear i used to use equals gces all the time and it was fine or was i delusional. seems like isnull = true works most everywhere now. is there any clarity on where one might use equals globalconstant.emptystring?

It seems like a pretty simple question - how do I tell if my (X) is blank / populated.

the X could be

  • evaluate flow screen element in assignment
  • evaluate flow screen element in a conditional visibility rule
  • evaluate flow screen element in a flow field validation rule
  • evaluate get records element in decision
  • evaluate a field in process builder
  • filter criteria on get records element

It seems like the answer is to use isNull, but seems like its not clearly stated as such. And a few folks agreed that this seems to have changed over...

Continue reading →

Protecting fields used in integrations from deletion

h/t to a number of folks on this one, esp Luke Cushanick who shared the idea for this.

Marking fields used in integrations in some way, to prevent them from being deleted, might be useful. Even more useful might be to document which integrations use them, and how.

After some discussion, this can be done using a custom metadata type fairly easily. No code!

Create custom metadata type, lets name it “Integration Field”

Then add 2 fields to the metadata type to track where this is used

Integration name : type = text
Description : type = text area

Now and the magic : create two metadata relationship fields, in order

Object Name : type = metadata relationship, related to entity definition
Field Name : type = metadata relationship, related to field definition


  • the ‘field name’ option will only appear after you create the first relationship field to entity definition
  • when...

Continue reading →

scheduled flow + vf email template demo

I have built out a demo scheduled flow that sends an email to each opportunity owner with a list of open opportunities, using a visualforce email template. This flow is much like a report subscription, but with more context, and without nearly as much work of scheduling subscriptions to N users. And - no 5 subscription limit!

The basic approach is covered in this article - which was built on custom objects in our HR system.

In order to avoid hitting the flow iteration limit from building a unique collection of owner Ids (which I can do using this hackish but inefficient approach), I built an invocable apex class that takes a sobject collection and a field, and returns a unique collection of values. This could have some other interesting uses, and opens this flow up to run on up to about 1990 unique active owners, which is pretty robust by my standards…Above that value, you will...

Continue reading →

scheduled flows + visualforce email templates

Many options exist to notify folks about salesforce data. I classify them as ‘popcorn’ (email alerts / chatter posts / notifications via workflows/flows/processes) or ‘consolidated’ (report subscriptions, that random opportunity email thing, custom visualforce emails with summarized info).

HR needed to automatically notify managers when people who reported to them had a contract that would expire in 90 days. Report subscriptions dont scale for this. Popcorn is a pain to build, and makes for a fractured user experience, so I wanted to send the manage a single summary email w all the data, on the first of the month.

The full-code way would be a scheduled batch job that sends the email, which can be all code. Nothing crazy, but i would guess a hundred lines or so,

Instead, I used scheduled flows and a visualforce email template in a regular old email alert, which leaves most of the...

Continue reading →

giving automated process user access to apex class

this post is just to reference this brilliant url hack by Matt - as eventually this approach will disappear in the comments on the idea to make it unnecessary, as it should be.

the link

Matt’s approach

Try opening the Developer Console to query for the autoproc Profile ID…
SELECT ProfileId FROM User WHERE Alias = ‘autoproc’
…then doctor the URL to get at its setup and enable the relevant Apex Classes:


View →

Default outcome in decision elements

I don’t like using default outcome in decision elements. I want to expressly define which path should be taken, and dont want the flow to take a path because i did not anticipate something.

Then I ran into an issue where a flow was finishing early because there was no matching outcome, and i had not mapped the default outcome. This was skipping a final notification step that was critical to the process.

So now, I created a subflow that i can use to send an ‘error’ notification in any flow, and i pass in the flow name, running user name, and ‘error message’. I already have an object I use to log errors from my code, and just write to that object via flow.

This way I can provide a path for the default outcome that expressly triggers an error notification, but can also allow the flow to continue to the next step. Progress!

Continue reading →

soql to csv in cli

using the salesforce cli to export a soql query to a csv file is just magic.

sfdx force:data:soql:query -q “select id,parentId,parent.Name,createdDate from feeditem where createdById = ‘0051W0000065wTP’” -r csv > yourfilename.csv

that is it

-q “insert query here”
-r csv


View →