1

I have a unique use case related to managed packages. One of our client has installed our managed package from AppExchange. It is working great for internal users. There is an automation/trigger that calls the managed package class.

We would like to replicate the same behavior for external user, but it does not make sense to buy a license for each external user as they are not as regular as internal users and most of them are using the system just once in their lifetime.

The question - is there a way for the community user to trigger a flow as System Admin that will update a flag on the record that will eventually call the managed package class. The system admin will have a license to the package.

== Edit based on Phil's suggestion ==

Create a Platform Event (PE). Created a new Flow to insert a record in the PE when Opportunity.Type = 'New Business; Then created below trigger on the PE

trigger OpportunityEventTriggerConfig on TestEvent__e (after insert) {

List<Opportunity> opportunitiesToUpdate = new List<Opportunity>();
Set<Id> oppIds = new Set<Id>();

for(TestEvent__e e : trigger.new) {
    oppIds.add(e.Record_Id__c);
}

for(Opportunity opp : [SELECT StageName FROM Opportunity WHERE Id IN :oppIds]) {
    opp.StageName = 'Proposal/Price Quote';
    opp.Description ='Updated from OpportunityEventTriggerConfig ' + System.now();
    opportunitiesToUpdate.add(opp);
}

update opportunitiesToUpdate;
}

Finally updated the UserId for PlatformEventSubscriberConfig using workbench

   {
    "BatchSize": "200",
    "DeveloperName":"OpportunityEventTriggerConfig",
    "MasterLabel":"OpportunityEventTriggerConfig",
    "PlatformEventConsumerId": "01qGB000001Aymj",
    "UserId": "00590000006TjF4"
}

So now the Type field is updating the StageName based on the above trigger, but LastModifiedBy still shows "Automated User" instead of "00590000006TjF4" mentioned above. What am I missing?

enter image description here

1

2 Answers 2

1

Platform Events that are processed by an Apex trigger-based event subscriber are run as a specific user; either the Automated Process user or one that has been explicitly configured using a PlatformEventSubscriberConfig.

Thus, my suggestion is to define a platform event and have the external user initiated processing publish one of these. You create a trigger-based subscriber that invokes the managed package flow and, if required, set up the config to change the user this runs as.

Obviously, this will not work if the flow is a screen flow since the platform event processing is async.

1
  • thanks @Phil, we are looking into this. Commented Apr 11 at 2:36
0

We had a similar scenario where we wanted a external user to be able to trigger a process, but it required them to have the correct licenses. Similar to your use case, buying a license for a once in a life time action did not make sense.

Our workaround was:

  1. Enable an external user to submit a case with a specific record type
  2. Built a scheduled flow that runs nightly that picks up these cases and runs the necessary logic

External users already had permissions to create case records, we just added to that functionality. The scheduled flow runs in system context with the necessary permissions, so we were able to process all the case records without having to buy any additional licenses

I am sure you should be able to follow a similar route to get around the restriction of licenses.

Good luck!

1
  • Thanks @Adriaan, but in this case we are sending an email with the PDF with necessary contract terms, so it must happen near-real time. Batch job may not work here. Commented Apr 11 at 2:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .