Gorav Seth

Salesforce MVP (HOF) | Permaculture designer Me on Mastodon

Page 2


truncating case description in case assignment email

sure its 2022 and we have force lightning powers that emperor palpatine himself could only dream of, but if you want a good case assignment email, you need visualforce.

i rolled up a nice visualforce email template years ago that includes the case commments - sorted by date!

but the template includes case description, and sometimes people initiate a case via a gigantic email, and all of that email thread would come through on the visualforce assignment email

so i just need to truncate the length of the description.

the original
<apex:outputField value="{!relatedTo.Description}"></apex:outputField>

tried inserting a left in there, could not get anything to save
examples
/apex:outputField

apex:outputText would lose the formatting, regardless of how I tried to work with it, like


/apex:outputText

I even tried abbreviating the string in a vf component, but outputText would lose the...

Continue reading →


Marking fields used in Integrations

Another way to mark fields used in Integrations.

2 years back I conjured up this approach to prevent deletion of fields used in integrations.

I still needed a better way to flag these fields. Description field is pretty good, but wanted to add the picklist value “Integrated” to the field usage picklist.

Turns out that you can only do this via the metadata api, so this is how to do it

  • create a file named package.xml with the following content
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>FieldBusinessStatus</members>
<name>StandardValueSet</name>
</types>
<version>54.0</version>
</Package>
  • login to workbench.developerforce.com and go to migration - retrieve
  • upload that package.xml file
  • click ‘download zip file’

this downloads the existing values for Field Usage picklist, in case someone has customized it before you!

  • Unzip the file
  • Edit the file...

Continue reading →


Single Sign On from Production to Sandbox

Make it oh-so-easy for users to test changes in a sandbox by seamlessly logging in from production!

Summary:
With this approach, your users can login to a sandbox directly from the app launcher in production. This requires no code, just clicks, and you can control exactly which users can use this option via profiles or permission sets.

Here is a gif to show how simple this is for users, in case you have never clicked on an app in the app launcher before.

ssodemo.gif

The Technical Details:
This approach uses production as the identity provider and a sandbox as a service provider. Authentication is managed using an identity-provider initiated oauth flow.

This implementation is a variation on the approach described in this H&T article. The approach in the article requires users to navigate to the sandbox my domain in their browser, where they can click on a button that authenticates against...

Continue reading →


custom links that work in both classic and lex

if you want a single custom link that works in classic or lightning, you need to create the links in a very simple visualforce page and embed the page in the page layout, which will show in classic and lex and looks pretty fine. you can make it look better if you really want.

note : you must set target = blank or target = top for the lightning portion of the link. if you do not specify target, or use self or parent, then opening the link in a new window will open the home page in lex.

if you try to use IF logic to evaluate UITheme on a custom link, it almost works, but it only works if you open in the same window. if you open in a new window, it will always evaluate to classic, and the known issue for this is marked as ‘no fix’. because of course…and you cannot prevent users from opening in new window.

the suggested workaround on the KI is to use a formula field. a formula...

Continue reading →


enabling email on records in lex

enabling email on records in lex is not what i imagined spending much time on in our migration…but here we are.

if you are in a sandbox, deliverability must be set to all email, else the action wont show up on any records period.

you need to add the sendemail action to the global publisher layouts, or override the specific page layouts to include it. makes sense.

per this doc, the send email action only works in lex but must be in the classic actions section also. some mumbo jumbo about inheritance. just tested and indeed it is the way. just dont ask.

once you finally get it to show up on the page, you may get a big red error message when you try to actually use it. has happened to me more than once! try disabling and re-enabling enhanced email per this thread on success. again, just dont ask.

you can indeed customize the layout for the email action. I removed...

Continue reading →


create record with pre-populated values in lex

the documentation on this spring20 feature is so bad its almost like the feature doesn’t exist at all.

this is all you get - one example and 2 notes

Screenshot from 2021-10-05 10-02-26.png

some missing ‘details’

a) date fields need to be converted to string using the TEXT formula

b) you can pass RecordTypeId (case sensitive) via a separate url parameter, but not in the default field values. the docs just say its not supported yet and strange things may happen. what is the point of having this feature without supporting record types? insert snide remark about confetti here.

example

/lightning/o/Opportunity/new?recordTypeId=012400000009dr3&defaultFieldValues=...\

c) the nooverride=1 parameter works in lex. if you have overridden the ‘new’ button on the object with say a visualforce page for example so people can only create opps from contacts or accounts, you can pass nooveride=1 and it will let you bypass that...

Continue reading →


Expresiv application in Salesforce user login history

cleaning up our integration user, and found a large number of logins from a mysterious application named “Expresiv” with an AWS IP address.

exprsiv.png

a few posts on salesforce forums over the years, mostly very old

i had a hunch, that turned out to be correct, that in my case these came from old formassembly forms that were connected via basic auth (un / pwd / token) instead of the new (c 2014) oauth option.

so now i gotta track these down and update them bc basic auth is no bueno.

View →


checking for record access in visual workflow

the UserRecordAccess object “Represents a user’s access to a set of records”.

in apex, you can query this object to determine if a user can view, edit, delete, share, or transfer a record.

SELECT RecordId, HasReadAccess, HasTransferAccess, MaxAccessLevel
FROM UserRecordAccess
WHERE UserId = [single ID]
AND RecordId = [single ID]

in flow, you can query this object to test for edit before updates, in theory, but its got some quirks because it has very specific requirements around how the query is structured, and the standard flow “get records” element does not meet them.

the docs specify these requirements for the query. the 2nd and 3rd ones come into play here.

SOQL restrictions:

  • When the running user is querying a user’s access to a set of records, records that the running user does not have read access to are filtered out of the results.
  • When filtering by UserId...

Continue reading →


tracking number of simultaneous users in salesforce

in setup - session management, you can filter to see session where
SessionType = UI
ParentSessionId = null

and those are your currently logged in users.

i needed to track that over time, to see what our numbers look like for internal purposes.

i wanted to track this every 30 mins, to capture spikes. we have session length set to 2 hours, so that clears out inactive sessions reasonably fast.

so via flow i could get records of the authSession object, but scheduled flows are max 1x/day, without hackery. didnt want to write any code for this, so went to power automate.

was very easy to setup a get records to query salesforce, and then write the number of simultaneously logged in users to an excel online file. and power automate lets you schedule to run very frequently, even in seconds. so every 30 mins is no issue.

flow.png

and…voila

excel.png

Continue reading →


using flows in system mode allows for alternative approaches to changing ownership

The standard sharing button and change owner button are great for hierarchical organizations, as the ‘power’ magically flows up the role hierarchy - so bigger fish higher up the role hierarchy can change owner / share records of all the little fish underneath them.

this is not so great when there is a high degree of collaboration within roles. in my case, each role represents a country office and country offices are collaborative entities. anyone in the country office should be empowered to change the owner of a contact owned by anyone else in the office, without asking the current owner.

while the standard ‘change owner’ functionality is carved in stone cannot be overridden, you can add a custom button and a flow in system mode that allows for alternative models like this.

its quite simple. the flow runs in system mode. it checks if $user.role = owner.role, and if so, lets them...

Continue reading →