function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Hithesh SaicharanHithesh Saicharan 

Load data into custom object after Unlocked package installation


I want to load some into into an object after a package got installed. I tried post install script but seems post install script will work only for 2GP Managed packages and not for Unlocked Packages. Is there a way I can load data into an object once my unlocked package got installed?
SwethaSwetha (Salesforce Developers) 
HI Hithesh,
I have come across related posts like this https://salesforce.stackexchange.com/questions/184674/can-we-have-a-post-install-script-for-unmanaged-package?rq=1 wherein it confirms that post-install script is only available for managed packages.

You might want to try the workaround mentioned :
add a class with a static method to the unmanaged package and then run the method anonymously in the developer console post install...
 
public class MyUnmanagedPackagePostInstallScript {

    public static void doSomething() {

        //I do things like create records and dml

    }
}
Install the package with the class included and then open the execute anonymous apex window and run:

MyUnmanagedPackagePostInstallScript.doSomething();

If this information helps, please mark the answer as best.Thank you