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
sailaja majji 5sailaja majji 5 

changing the profile urgent

Team ,

I have a requirement  .If a system admin is giving system admin access to another user ,then after 24 hours automaticaly it should be reverted back to original profile .

Can you give different approaches to achieve this  .

Here is my analysis .

I am thinking trigger best suits here ,not a workflow since we need previous profile value to revert it back with time based workflows ,we cant get the prior value of profile

In trigger i was thinking how to revert the profile after 24 hrs .How can  we schedule the time for the profile to revert the change (do we need to write apex class and schedule it thorugh scheduler .)

Please let me know your thoughts 

Thanks,
Best Answer chosen by sailaja majji 5
sailaja majji 5sailaja majji 5
Just in case if somebody is facing the same scenario .
The below solutions worked for me and successfully went to production'.

I have created 2 fields on object and written  a trigger and time trigger workflow to reste the profile after 24 hrs .
 

All Answers

Himanshu ParasharHimanshu Parashar
Hi,

Writing a Batch will be an option in this case because you can't run trigger here. but instead of reverting back to orignal profile you can assign a permission set to that user and delete permission set after 24 hours via apex.

will that work for you ?

Thanks,
Himanshu
sailaja majji 5sailaja majji 5

Thanks Himanshu .

I couldnt get why we cant accomplish this using trigger .I am planning to call the scheduled apex class from trigger .
Let me know if this doesnt work .

And moreover permission set can be an option but i am not aware on how to write apex for it .
If you can give me sample code and if you could explain how permission set works in this case it woudl be great 
sailaja majji 5sailaja majji 5
Just in case if somebody is facing the same scenario .
The below solutions worked for me and successfully went to production'.

I have created 2 fields on object and written  a trigger and time trigger workflow to reste the profile after 24 hrs .
 
This was selected as the best answer