Get name of standard action overriden in Visualforce contorller The 2019 Stack Overflow Developer Survey Results Are Inapex: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

Deal with toxic manager when you can't quit

Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?

Match Roman Numerals

Pokemon Turn Based battle (Python)

Output the Arecibo Message

Currents/voltages graph for an electrical circuit

Is it okay to consider publishing in my first year of PhD?

Keeping a retro style to sci-fi spaceships?

Is bread bad for ducks?

Ubuntu Server install with full GUI

I am an eight letter word. What am I?

ODD NUMBER in Cognitive Linguistics of WILLIAM CROFT and D. ALAN CRUSE

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

"as much details as you can remember"

Dropping list elements from nested list after evaluation

How do PCB vias affect signal quality?

Why isn't the black hole white?

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

Why doesn't UInt have a toDouble()?

What information about me do stores get via my credit card?

Falsification in Math vs Science

How come people say “Would of”?

How do I free up internal storage if I don't have any apps downloaded?

What is the meaning of Triage in Cybersec world?



Get name of standard action overriden in Visualforce contorller



The 2019 Stack Overflow Developer Survey Results Are Inapex: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 5 hours ago









      Jayant Das

      18.2k21330




      18.2k21330










      asked 7 hours ago









      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
            6 hours ago











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

            – Jayant Das
            6 hours ago












          • I'll test it out, thanks !

            – SallyRothroat
            5 hours ago











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

            – SallyRothroat
            5 hours ago











          • @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
            5 hours ago












          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
            6 hours ago











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

            – Jayant Das
            6 hours ago












          • I'll test it out, thanks !

            – SallyRothroat
            5 hours ago











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

            – SallyRothroat
            5 hours ago











          • @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
            5 hours ago
















          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
            6 hours ago











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

            – Jayant Das
            6 hours ago












          • I'll test it out, thanks !

            – SallyRothroat
            5 hours ago











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

            – SallyRothroat
            5 hours ago











          • @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
            5 hours ago














          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 5 hours ago

























          answered 6 hours ago









          Jayant DasJayant Das

          18.2k21330




          18.2k21330












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

            – sfdcfox
            6 hours ago











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

            – Jayant Das
            6 hours ago












          • I'll test it out, thanks !

            – SallyRothroat
            5 hours ago











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

            – SallyRothroat
            5 hours ago











          • @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
            5 hours ago


















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

            – sfdcfox
            6 hours ago











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

            – Jayant Das
            6 hours ago












          • I'll test it out, thanks !

            – SallyRothroat
            5 hours ago











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

            – SallyRothroat
            5 hours ago











          • @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
            5 hours ago

















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

          – sfdcfox
          6 hours ago





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

          – sfdcfox
          6 hours ago













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

          – Jayant Das
          6 hours ago






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

          – Jayant Das
          6 hours ago














          I'll test it out, thanks !

          – SallyRothroat
          5 hours ago





          I'll test it out, thanks !

          – SallyRothroat
          5 hours ago













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

          – SallyRothroat
          5 hours ago





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

          – SallyRothroat
          5 hours ago













          @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
          5 hours ago






          @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
          5 hours ago


















          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

          名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

          Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

          Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar