+ Start a Discussion
Nichole SmithNichole Smith 

Custom Button that Runs as a System Administrator

We have a use case were we need to have a custom button that would clone a custom object and all of its related records. I have created the button and it works great as the system administrator because that profile has access to the fields but when I log in as one of the other users I get an error because they dont have access to the fields. For security reasons we dont want to give them access to the fields but we want them to be able to clone the existing record. So what we would need is to have this button run as a system administrator. Is that possible? 

 
Best Answer chosen by Nichole Smith
Shikha AgashiShikha Agashi
If there are certain fields, that are not accessible to profile, I would suggest to create Clone URL based on each profile. You can acheive this by VF as well as Apex code. You can call this VF Page on custom button, and that will rediect URL based on profiles.

All Answers

Shikha AgashiShikha Agashi
Hi Nicole,

Clone works only if that field is visible on form. So, all your fields in clone url should also be available on form. Having said that, you can set FLS for those profile to read and write but make make those fields read only on pagelayout, that way you are not compromising with design. Clone is not going to work if they do not have field accessibilty.
Nichole SmithNichole Smith
thank you for your response shika. I do understand that clone wont work if they dont have field accessibility that is why I was wondering if there is a way to run the button as the system administrator upon creation of the records.
Shikha AgashiShikha Agashi
This is not posiible. There is no way you can run logic as System Admin for other profiles
Nichole SmithNichole Smith
Can you run the button as another profile at all? 
Shikha AgashiShikha Agashi
If there are certain fields, that are not accessible to profile, I would suggest to create Clone URL based on each profile. You can acheive this by VF as well as Apex code. You can call this VF Page on custom button, and that will rediect URL based on profiles.
This was selected as the best answer
Nichole SmithNichole Smith
Thank you. I will look into that area.