Switching Connections in Anon Window Doesn't Save Anon Apex
When switching environment connections in the Anonymous Apex tool window, it appears that previous anonymous apex is being run instead of what is actually present in the script window.
For example, using the following code:
System.debug('!!! ' + Url.getSalesforceBaseUrl().getHost());
I get the correct output in my sandbox:
Executing:
============================================================
System.debug('!!! ' + Url.getSalesforceBaseUrl().getHost());
============================================================
Success.
17:36:39.4 (6180934)|USER_DEBUG|[1]|DEBUG|!!! cs24.salesforce.com
However, in my production org:
Executing:
============================================================
System.debug('!!! ' + Url.getSalesforceBaseUrl().getHost());
============================================================
Success.
18:40:35.8 (8961037)|USER_DEBUG|[4]|DEBUG|!!! 2016-05-17 00:00:00
18:40:35.8 (8979561)|USER_DEBUG|[5]|DEBUG|!!! 2016-05-16 00:00:00
18:40:35.8 (41124359)|USER_DEBUG|[16]|DEBUG|!!! 6
18:40:35.8 (41443066)|USER_DEBUG|[17]|DEBUG|!!! (ProcessInstance:{Id=04g400000060EowAAE, Status=Approved, TargetObjectId=a0P4000000TcUGHEA3, CompletedDate=2016-05-16 02:01:00}, ProcessInstance:{Id=04g400000060F3IAAU, Status=Approved, TargetObjectId=a0P4000000Td6mYEAR, CompletedDate=2016-05-16 02:17:51}, ProcessInstance:{Id=04g400000060KKxAAM, Status=Approved, TargetObjectId=a0P4000000TrHqqEAF, CompletedDate=2016-05-16 14:46:46}, ProcessInstance:{Id=04g400000060KL7AAM, Status=Approved, TargetObjectId=a0P4000000TrISjEAN, CompletedDate=2016-05-16 14:47:12}, ProcessInstance:{Id=04g400000060LtUAAU, Status=Approved, TargetObjectId=a0P4000000TbSdPEAV, CompletedDate=2016-05-16 16:45:20}, ProcessInstance:{Id=04g400000060Mx8AAE, Status=Approved, TargetObjectId=a0P4000000TiXqiEAF, CompletedDate=2016-05-16 21:57:54})
That was some anonymous apex I had written a few days ago. Perhaps a session is persisting?
Comments (9)
-
-
Account Deactivated Happening with me as well. Only recently started occurring after one of the recent updates, I believe.
Tried rebuilding caches and indices from project settings, and restarting, and still seems to run the cached call from some time ago. Unsure how to actually force it to work.
Extra info; Two modules configured in the one project. One module for Sandbox, one module for Production.
-
repo owner -
assigned issue to
- changed version to 1.7.2.7
-
assigned issue to
-
repo owner Matthew and Rick, I've tried to reproduce this unsuccessfully. Let me describe my steps to reproduce and perhaps you can tell me what you're doing differently that leads to the issue:
- Create a project with connections to two different orgs.
- In the Anonymous Apex tool window, choose the first connection and execute a script, e.g.,
System.debug('connection 1');
. To output showsconnection 1
. - Switch to the second connection.
- Change the script to something different, e.g.,
System.debug('connection 2');
. - Execute again. For me the output shows
connection 2
. It sounds like for you guys it would have shownconnection 1
, correct?
Please let me know if I'm missing a key step, need to configure the project and connections differently, etc. I definitely want to address this since it would be terrible for someone to run anonymous Apex that modifies org contents in the wrong org!
-
It's more like the logs are showing from the previous run, and I don't get the logs for the current run. If I run a simple debug of a User from connection 1, I get an old output from connection 1, rather than what I'm expecting:
User test = [SELECT Id FROM User LIMIT 1]; System.debug(test);
Displays this:
Executing: ========================================== User test = [SELECT Id FROM User LIMIT 1]; System.debug(test); ========================================== Success. 36.0 APEX_CODE,DEBUG 13:20:27.14 (14816311)|EXECUTION_STARTED 13:20:27.14 (14824813)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex 13:20:27.14 (18860879)|USER_DEBUG|[11]|DEBUG|found JAPA 13:20:27.14 (18913949)|CODE_UNIT_FINISHED|execute_anonymous_apex 13:20:27.14 (20348677)|EXECUTION_FINISHED
That was a previous output I had from about a week or so ago. Now if I switch to connection 2 and run the same thing, I get an old output from that connection as well, not the test User debug I'm expecting. It seems that the debug logs are getting stuck and only displaying the stuck logs, rather than returning the most recent log.
-
repo owner Ah, okay. So it looks like it's picking up the wrong log. I believe that may be related to another bug that I'm addressing right now. Thanks for the additional info!
-
No problem. I just confirmed, the anon apex IS running, just the logs aren't returning properly. Thanks Scott!
-
repo owner Hopefully this will be resolved by the work I've done on issue
#326today. I'll try to release that and a number of other fixes early this coming week. -
repo owner - changed status to resolved
Delivered in 1.7.2.7.
- Log in to comment
Can confirm, has happened to me as well.