Posts

Showing posts with the label UserTerritory2Association

Salesforce Fact #919 | Remove selected UT2A records using screen action

Image
In continuation of the last post related to screen action, we can extend the logic to remove a user from selected territories.  The subflow returns the UserTerritory2Association records for the input userId and in the main flow, the result is shown in datatable allowing the user to select a record and then proceed with the deletion. Attached are the screenshots. Note: For demonstration purpose, used the Territory2Id field for storing the territory label but it is not advised to follow.

Salesforce Fact #916 | Adding validation on UserTerritory2Association

Image
Suppose we would like to add validations while adding users to the territory. For example, The user should be active and the user should not be assigned to multiple territories. We can write the logic in an after insert trigger on UserTerritory2Association object. Attached are the sample code snippets.