I am trying to join a layer in an ArcGIS Pro map to a table using a scripting tool. The layer is called 'Heights', and is being joined to a table called 'Names'. The Python code below is working when run from the Python window within ArcGIS Pro. However, when I try to run it as a script from the Catalog Pane then the join does not happen, even though the geoprocessing detail does not throw up any error messages. Am I missing a step or does this just not work in ArcGIS Pro?
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="comment token">#Reference map document from within ArcGIS Pro</SPAN>
aprx <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mp<SPAN class="punctuation token">.</SPAN>ArcGISProject<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'CURRENT'</SPAN><SPAN class="punctuation token">)</SPAN>
map <SPAN class="operator token">=</SPAN> aprx<SPAN class="punctuation token">.</SPAN>activeMap
<SPAN class="comment token"># Local variables:</SPAN>
Heights <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Heights"</SPAN>
toTable <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\#workspace\Names"</SPAN>
<SPAN class="comment token"># Process: Add Join</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddJoin_management<SPAN class="punctuation token">(</SPAN>Heights<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'LINK_ID'</SPAN><SPAN class="punctuation token">,</SPAN> toTable<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'AI_LINK_ID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'KEEP_ALL'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>