I am relatively new to salesforce and administration. I am trying to create a custom cloning button that checks against the user profile name.

I am using URL as content source.

if({$Profile.Name}="System Administrator") {

You are nearly there. Try this:

if('{!$Profile.Name}'=='System Administrator') {
    window.location = '/{!Opportunity.Id}/e?clone=1';

Note the differences

  • I am using the salesforce token evaluation syntax {!} around the !Profile.Name var. If you don't do this, it won't be evaluated by Salesforce.
  • Also, I have enclosed that whole expression in quotes - we are comparing strings.
  • Finally, I am using Javascript to redirect, so you need to use the window.location command to redirect.

This is tested and works for an onclick Javascript button.

  • If this worked for you, you can mark as accepted. – Caspar Harmer Apr 22 '15 at 22:13
  • @casper I tried the above but the button is taking me to e/?clone=1 – C0DEPirate Nov 5 '15 at 12:05
  • Check that you are in the opportunity context. Also check that you have correctly quoted the string. You can paste code snippet in a comment here if you like. – Caspar Harmer Nov 5 '15 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.