Get name of standard action overriden in Visualforce contorller Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election Resultsapex:actionFunction action doesn't seem to work the same as apex:commandButton actionVisualforce page(table) doesn't rerenderShowing visualforce pages to Communities users, but standard Salesforce pages to all other users, without writing a dozen controller extensions!How to detect button action in controller that is associated with overriden Visualforce page?standard delete button on a custom vf pageOverride Standard View Button and Inline Editing DisabledCan a single VF page override both a standard action and a list action?Issue with StandardController addFields() on WorkOrder sObjectVisualforce - infinite redirection loopStandard controller and extension method with same name

How does a Death Domain cleric's Touch of Death feature work with Touch-range spells delivered by familiars?

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

What is a Meta algorithm?

How to find all the available tools in macOS terminal?

Is there a "higher Segal conjecture"?

When is phishing education going too far?

I need to find the potential function of a vector field.

List *all* the tuples!

If 'B is more likely given A', then 'A is more likely given B'

Proof involving the spectral radius and the Jordan canonical form

If a contract sometimes uses the wrong name, is it still valid?

What is this single-engine low-wing propeller plane?

I am not a queen, who am I?

Why did the IBM 650 use bi-quinary?

What would be the ideal power source for a cybernetic eye?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

What causes the vertical darker bands in my photo?

Single word antonym of "flightless"

do i need a schengen visa for a direct flight to amsterdam?

Diagram with tikz

Why is black pepper both grey and black?

iPhone Wallpaper?

Letter Boxed validator

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]



Get name of standard action overriden in Visualforce contorller



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election Resultsapex:actionFunction action doesn't seem to work the same as apex:commandButton actionVisualforce page(table) doesn't rerenderShowing visualforce pages to Communities users, but standard Salesforce pages to all other users, without writing a dozen controller extensions!How to detect button action in controller that is associated with overriden Visualforce page?standard delete button on a custom vf pageOverride Standard View Button and Inline Editing DisabledCan a single VF page override both a standard action and a list action?Issue with StandardController addFields() on WorkOrder sObjectVisualforce - infinite redirection loopStandard controller and extension method with same name



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have a visualforce page that overrides both the 'New' and 'Edit' Buttons of a custom object. In my controller extension how can I get the name of the action that called this page ? I don't see anything in the StandardController, there are methods to redirect to the standard edit and view pages but nothing that will return the button clicked.










share|improve this question






























    2















    I have a visualforce page that overrides both the 'New' and 'Edit' Buttons of a custom object. In my controller extension how can I get the name of the action that called this page ? I don't see anything in the StandardController, there are methods to redirect to the standard edit and view pages but nothing that will return the button clicked.










    share|improve this question


























      2












      2








      2








      I have a visualforce page that overrides both the 'New' and 'Edit' Buttons of a custom object. In my controller extension how can I get the name of the action that called this page ? I don't see anything in the StandardController, there are methods to redirect to the standard edit and view pages but nothing that will return the button clicked.










      share|improve this question
















      I have a visualforce page that overrides both the 'New' and 'Edit' Buttons of a custom object. In my controller extension how can I get the name of the action that called this page ? I don't see anything in the StandardController, there are methods to redirect to the standard edit and view pages but nothing that will return the button clicked.







      apex visualforce controller-extension standardcontroller salesforce-classic






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 11 at 18:31









      Jayant Das

      18.4k21330




      18.4k21330










      asked Apr 11 at 16:35









      SallyRothroatSallyRothroat

      421317




      421317




















          1 Answer
          1






          active

          oldest

          votes


















          3














          I don't know if there's any standard way to do so, but you can utilize an approach here in your Extension's constructor to identify if the click was from New or Edit.



          When you click on New button, that signifies that you are creating a new record and that it won't have an Id yet, whereas for Edit there will be always one. So checking that in the Extension will help you to identify the flow.



          public class MyExtension 

          private MyObj__c abc;
          private String buttonClicked;

          public MyExtension(ApexPages.StandardController stdController)
          this.abc = (MyObj__c) stdController.getRecord();

          buttonClicked = (abc.Id == null ? 'New' : 'Edit');
          // do something now







          share|improve this answer

























          • +1 Strictly speaking, the parentheses around the ternary expression is not necessary, since there's no ambiguity in the syntax.

            – sfdcfox
            Apr 11 at 17:19











          • @sfdcfox I agree. I just keep it for a better readability just to not confuse between = and == in the same statement.

            – Jayant Das
            Apr 11 at 17:19












          • I'll test it out, thanks !

            – SallyRothroat
            Apr 11 at 18:29











          • I was already getting the record so perfect I'll just check if it's null. What's the abc for?

            – SallyRothroat
            Apr 11 at 18:32











          • @SallyRothroat Ah, I missed that part. It's just a variable of type of the object which is fetched in the constructor, I have updated my answer. If you are already getting your record, then you just need to verify the Id and done.

            – Jayant Das
            Apr 11 at 18:33












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "459"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f257521%2fget-name-of-standard-action-overriden-in-visualforce-contorller%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          I don't know if there's any standard way to do so, but you can utilize an approach here in your Extension's constructor to identify if the click was from New or Edit.



          When you click on New button, that signifies that you are creating a new record and that it won't have an Id yet, whereas for Edit there will be always one. So checking that in the Extension will help you to identify the flow.



          public class MyExtension 

          private MyObj__c abc;
          private String buttonClicked;

          public MyExtension(ApexPages.StandardController stdController)
          this.abc = (MyObj__c) stdController.getRecord();

          buttonClicked = (abc.Id == null ? 'New' : 'Edit');
          // do something now







          share|improve this answer

























          • +1 Strictly speaking, the parentheses around the ternary expression is not necessary, since there's no ambiguity in the syntax.

            – sfdcfox
            Apr 11 at 17:19











          • @sfdcfox I agree. I just keep it for a better readability just to not confuse between = and == in the same statement.

            – Jayant Das
            Apr 11 at 17:19












          • I'll test it out, thanks !

            – SallyRothroat
            Apr 11 at 18:29











          • I was already getting the record so perfect I'll just check if it's null. What's the abc for?

            – SallyRothroat
            Apr 11 at 18:32











          • @SallyRothroat Ah, I missed that part. It's just a variable of type of the object which is fetched in the constructor, I have updated my answer. If you are already getting your record, then you just need to verify the Id and done.

            – Jayant Das
            Apr 11 at 18:33
















          3














          I don't know if there's any standard way to do so, but you can utilize an approach here in your Extension's constructor to identify if the click was from New or Edit.



          When you click on New button, that signifies that you are creating a new record and that it won't have an Id yet, whereas for Edit there will be always one. So checking that in the Extension will help you to identify the flow.



          public class MyExtension 

          private MyObj__c abc;
          private String buttonClicked;

          public MyExtension(ApexPages.StandardController stdController)
          this.abc = (MyObj__c) stdController.getRecord();

          buttonClicked = (abc.Id == null ? 'New' : 'Edit');
          // do something now







          share|improve this answer

























          • +1 Strictly speaking, the parentheses around the ternary expression is not necessary, since there's no ambiguity in the syntax.

            – sfdcfox
            Apr 11 at 17:19











          • @sfdcfox I agree. I just keep it for a better readability just to not confuse between = and == in the same statement.

            – Jayant Das
            Apr 11 at 17:19












          • I'll test it out, thanks !

            – SallyRothroat
            Apr 11 at 18:29











          • I was already getting the record so perfect I'll just check if it's null. What's the abc for?

            – SallyRothroat
            Apr 11 at 18:32











          • @SallyRothroat Ah, I missed that part. It's just a variable of type of the object which is fetched in the constructor, I have updated my answer. If you are already getting your record, then you just need to verify the Id and done.

            – Jayant Das
            Apr 11 at 18:33














          3












          3








          3







          I don't know if there's any standard way to do so, but you can utilize an approach here in your Extension's constructor to identify if the click was from New or Edit.



          When you click on New button, that signifies that you are creating a new record and that it won't have an Id yet, whereas for Edit there will be always one. So checking that in the Extension will help you to identify the flow.



          public class MyExtension 

          private MyObj__c abc;
          private String buttonClicked;

          public MyExtension(ApexPages.StandardController stdController)
          this.abc = (MyObj__c) stdController.getRecord();

          buttonClicked = (abc.Id == null ? 'New' : 'Edit');
          // do something now







          share|improve this answer















          I don't know if there's any standard way to do so, but you can utilize an approach here in your Extension's constructor to identify if the click was from New or Edit.



          When you click on New button, that signifies that you are creating a new record and that it won't have an Id yet, whereas for Edit there will be always one. So checking that in the Extension will help you to identify the flow.



          public class MyExtension 

          private MyObj__c abc;
          private String buttonClicked;

          public MyExtension(ApexPages.StandardController stdController)
          this.abc = (MyObj__c) stdController.getRecord();

          buttonClicked = (abc.Id == null ? 'New' : 'Edit');
          // do something now








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 11 at 18:33

























          answered Apr 11 at 16:52









          Jayant DasJayant Das

          18.4k21330




          18.4k21330












          • +1 Strictly speaking, the parentheses around the ternary expression is not necessary, since there's no ambiguity in the syntax.

            – sfdcfox
            Apr 11 at 17:19











          • @sfdcfox I agree. I just keep it for a better readability just to not confuse between = and == in the same statement.

            – Jayant Das
            Apr 11 at 17:19












          • I'll test it out, thanks !

            – SallyRothroat
            Apr 11 at 18:29











          • I was already getting the record so perfect I'll just check if it's null. What's the abc for?

            – SallyRothroat
            Apr 11 at 18:32











          • @SallyRothroat Ah, I missed that part. It's just a variable of type of the object which is fetched in the constructor, I have updated my answer. If you are already getting your record, then you just need to verify the Id and done.

            – Jayant Das
            Apr 11 at 18:33


















          • +1 Strictly speaking, the parentheses around the ternary expression is not necessary, since there's no ambiguity in the syntax.

            – sfdcfox
            Apr 11 at 17:19











          • @sfdcfox I agree. I just keep it for a better readability just to not confuse between = and == in the same statement.

            – Jayant Das
            Apr 11 at 17:19












          • I'll test it out, thanks !

            – SallyRothroat
            Apr 11 at 18:29











          • I was already getting the record so perfect I'll just check if it's null. What's the abc for?

            – SallyRothroat
            Apr 11 at 18:32











          • @SallyRothroat Ah, I missed that part. It's just a variable of type of the object which is fetched in the constructor, I have updated my answer. If you are already getting your record, then you just need to verify the Id and done.

            – Jayant Das
            Apr 11 at 18:33

















          +1 Strictly speaking, the parentheses around the ternary expression is not necessary, since there's no ambiguity in the syntax.

          – sfdcfox
          Apr 11 at 17:19





          +1 Strictly speaking, the parentheses around the ternary expression is not necessary, since there's no ambiguity in the syntax.

          – sfdcfox
          Apr 11 at 17:19













          @sfdcfox I agree. I just keep it for a better readability just to not confuse between = and == in the same statement.

          – Jayant Das
          Apr 11 at 17:19






          @sfdcfox I agree. I just keep it for a better readability just to not confuse between = and == in the same statement.

          – Jayant Das
          Apr 11 at 17:19














          I'll test it out, thanks !

          – SallyRothroat
          Apr 11 at 18:29





          I'll test it out, thanks !

          – SallyRothroat
          Apr 11 at 18:29













          I was already getting the record so perfect I'll just check if it's null. What's the abc for?

          – SallyRothroat
          Apr 11 at 18:32





          I was already getting the record so perfect I'll just check if it's null. What's the abc for?

          – SallyRothroat
          Apr 11 at 18:32













          @SallyRothroat Ah, I missed that part. It's just a variable of type of the object which is fetched in the constructor, I have updated my answer. If you are already getting your record, then you just need to verify the Id and done.

          – Jayant Das
          Apr 11 at 18:33






          @SallyRothroat Ah, I missed that part. It's just a variable of type of the object which is fetched in the constructor, I have updated my answer. If you are already getting your record, then you just need to verify the Id and done.

          – Jayant Das
          Apr 11 at 18:33


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f257521%2fget-name-of-standard-action-overriden-in-visualforce-contorller%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

          Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

          NetworkManager fails with “Could not find source connection”Trouble connecting to VPN using network-manager, while command line worksHow can I be notified about state changes to a VPN adapterBacktrack 5 R3 - Refuses to connect to VPNFeed all traffic through OpenVPN for a specific network namespace onlyRun daemon on startup in Debian once openvpn connection establishedpfsense tcp connection between openvpn and lan is brokenInternet connection problem with web browsers onlyWhy does NetworkManager explicitly support tun/tap devices?Browser issues with VPNTwo IP addresses assigned to the same network card - OpenVPN issues?Cannot connect to WiFi with nmcli, although secrets are provided