Embedding javascript into a Calculated column works well, such as in this case
Using HTML to recalculate calculated column
However, where the following code
="function setTaskID(TR){"
&" var CTX=new SP.ClientContext.get_current();"
&" var list=CTX.get_web().get_lists().getById( SP.ListOperation.Selection.getSelectedList());"
&" var ID=TR.id.split(String.fromCharCode(44))[1];"
.
.
.
is initiated automatically by a timeout
IF(INT(TaskID),"","<img src=""/_layouts/images/blank.gif"" onload=""{"
&setTaskIDfunction
&"var TR=this.parentNode.parentNode.parentNode;"
&"setTimeout(setTaskID(TR),1000);"
AND
a CEWP has been added to the page containing CSS
<style type="text/css">
</style>
Then the function SP.ClientContext.get_current fails with
Unable to get property 'get_current' of undefined or null reference
I have used the following code in the CEWP as well
<style type="text/css">
</style>
<script src="https://oursites.../jquery.SPServices-2014.02.js"></script>
and this won't work either.
Remove the CEWP and the code works fine.
What can I add to the CEWP to overcome the error?