Skip to main content
13 votes
Accepted

Get currently installed package version from Apex Class

You can use System.requestVersion, which returns the version of your package. See Version for more details, but I'll also include the snippet from there here: if (System.requestVersion() == new ...
sfdcfox's user avatar
  • 502k
11 votes

How to give date and time values in request body using postman

Use Pre-request script tab to save the date into a variable: var current_timestamp = new Date(); postman.setEnvironmentVariable("current_timestamp", current_timestamp.toISOString()); and then use it ...
Lucie Lavickova's user avatar
11 votes
Accepted

Using Metadata API from managed package post-install script

The postinstall context for a managed package is fairly weird. It comes with a laundry list of restrictions: It can initiate batch, scheduled, and future jobs. It can’t access Session IDs. It can ...
David Reed's user avatar
  • 93.7k
9 votes

How to write post installer script apex class for package?

This is the pattern we use: global class YourInstallHandler implements InstallHandler { private Version previousVersion; global void onInstall(InstallContext context) { if (context....
Keith C's user avatar
  • 137k
6 votes

How to write post installer script apex class for package?

Well you have to implement the InstallHandler interface so that after installation the methods defined would work. https://developer.salesforce.com/docs/atlas.en-us.packagingGuide.meta/...
Pranay Jaiswal's user avatar
6 votes

Can a 2GP package include a post install page?

I raised this on the Partner Forums too. I got the following from two of the guys at Salesforce. Firstly Dileep Burki: The postInstallURL supports the specification of a URL to which the installer is ...
Phil W's user avatar
  • 38.2k
4 votes

Get currently installed package version from Apex Class

Because System.requestVersion (see @sfdcfox's answer) throws an uncatchable exception on a scratch org for package development, you cannot use this code on that scratch org and any unit tests covering ...
Phil W's user avatar
  • 38.2k
4 votes

How to give date and time values in request body using postman

I tried this in the workbench. It successfully created an event record. I suspect salesforce is expecting a date in a standard format instead of the date(value) format. { "Type":"contact call", ...
abhi's user avatar
  • 1,830
4 votes

Updating page layout when package installed

Page layouts in a managed package can only be created, not updated. The rationale, is that your subscribers have their own custom fields and may want make adjustments that won't get overwritten by ...
greenstork's user avatar
  • 14.5k
4 votes
Accepted

Restore Post Install Script setting on managed package patch

I found a solution for this by manually editing the package.xml in the metadata folder to add the missing settings before running sfdx force:mdapi:deploy More precisely: Run sfdx force:source:...
Jelle van Geuns's user avatar
4 votes
Accepted

Best way to detect that code is running in InstallHandler context?

Just for the record, consensus is an Apex static variable that the InstallHandler implementation sets and other code tests i.e.: /** * Referenced by triggers. */ public inherited sharing class ...
Keith C's user avatar
  • 137k
3 votes
Accepted

Future method is not invoked from PostInstall script

Sending Apex Email doesn't instantaneously sends the email. It actually locks the database, and the email will be sent at the end of the transaction. As email has locked the database it actually an ...
Pranay Jaiswal's user avatar
3 votes
Accepted

Managed Package Post Install Script - how to identify special package user?

Simply checking if getUserType = LicenseManager should be sufficient; there's no way for a real user to log in to a LicenseManager type, nor can you create users that have this user type.
sfdcfox's user avatar
  • 502k
3 votes
Accepted

Is there a way to deploy a Lightning App in a managed package that would be visible to all users by default?

This isn't currently possible, as of the Winter '24 release. Salesforce.com has stated that they would like to make this possible in the future by allowing packages to have something similar to a ...
sfdcfox's user avatar
  • 502k
2 votes

Field permission in post install script

I hit the same issue regarding packaging permission sets and standard objects. I use a script that is similar to the answer above, but rather than run it via the post install script, I created a ...
BritishBoyinDC's user avatar
2 votes

Get currently installed package version from Apex Class

We maintain the package version as a constant in some apex class and update that line with CI on every package version creation step. Also, if you have access to Session Id and Tooling API, it is ...
Patlatus's user avatar
  • 17.8k
2 votes

Push VS Upgrade packages

In case of push upgrades there is no way to choose for which users package would be installed, it would trigger 'Admin Only' mode and that's it. But when upgrading package by directly typing url on ...
wesaw's user avatar
  • 3,150
2 votes
Accepted

Page Reference getContent method in a batch within a package

Agreed with @sfdcfox about the "x-y problem". Please explain your use case more? But if the CustomObject ID is what you really need though, there are better ways to do it than screen-scraping. For ...
Charles T's user avatar
  • 11.1k
2 votes

post install class access modifier

Salesforce docs tends to write examples that use global despite not needing to. From time to time, I've seen this on scheduled classes, batchable classes, queueable classes, etc. You should not ...
sfdcfox's user avatar
  • 502k
2 votes

Trialforce Org derived new instance does not run after Insert triggers?

TrialForce literally clones the data without running all the business logic that may be present. This is done to minimize the amount of time it takes to set up a new trial (and also why there are ...
sfdcfox's user avatar
  • 502k
2 votes
Accepted

Can my app auto-update an installee's security settings to allow them access to my API?

The ideal way for you to package your settings is inside a "Permission Set". That way the end user has the freedom to add the permission set to as many (or as few) users as they prefer. While you ...
Sebastian Kessel's user avatar
2 votes
Accepted

How to make an External Id field unique in a managed package?

Below is quoted from Salesforce support reply. As per checking, if you are trying to modify a field added to a managed package, then you may need us to revert the package to beta in order to ...
Pasan Eeriyagama's user avatar
2 votes

Create canvas app using Apex

I think instead of making your users to change Canvas App Url manually, why don't you make a visualforce page that will intake canvas app url from user and create the canvas app on click of a button. ...
Nilang Pandey's user avatar
2 votes

Create remote site setting on post install script

MetadataService under the hood uses SOAP API and make a callout which needs a remote site settings because it is trying to make a callout from apex. Salesforce released Native APEX metadata API last ...
balinder singh's user avatar
2 votes
Accepted

Can a Post Install Script be removed from a managed package after being set?

I'll answer in reverse order: Regarding #2, You can certainly change and/or remove your PostInstallScript from release to release. However, as you know, PostInstallScript classes must be declared ...
Sebastian Kessel's user avatar
2 votes
Accepted

upsert failed, pushtopic with this name already exists

The issue is that the PushTopic name must be unique. Could you please try to generate the random name and then set that as a name in test class context. Sample code to generate random string. Integer ...
Kalpana's user avatar
  • 191
2 votes

Postinstallation Action in Unlocked Package

We had few post deployment steps like yours. Adding data, use its Id as lookup and add another objects data. With the advent of SFDX CLI, it got easier. You can use force:apex:execute if it's a simple ...
Ysr Shk's user avatar
  • 3,175
2 votes

Visualfoce pages in profile are not added to profile after installation

Packaging Profiles is ... really weird. I think this is what MIX DML was alluding to in their question in the comments. There's two ways you'll see this behavior on package install, provided you ...
David Reed's user avatar
  • 93.7k
2 votes
Accepted

Clean data From deprecated field in Managed package

If I was doing this I would create two separate releases of the package: The first: Removes usages of the field from the package. Relabels the field as "Deprecated". Includes a batch or ...
Phil W's user avatar
  • 38.2k
1 vote

Can custom metadata type records be deployed from post-install script?

You should be able to do it and in order to achieve it, there are 2 ways - Include that code in the post-install class Run that code through a script in each org's developer console You can have a ...
Naval Sharma's user avatar
  • 1,737

Only top scored, non community-wiki answers of a minimum length are eligible