Hi Dojo,
I want to abort an automation script using:
ScriptControlMessage abortMessage = new ScriptControlMessage(DataMinerID)
{
ScriptID = scriptID, //this is the running automation script ID
Type = ScriptControlType.Detach // this aborts the script
};
How can I get the script ID when I only know the name?
IDmsAutomationScript only has Name, Description..
Thank you,
Ana
Hi Ana,
I don't think you can determine the ScriptID just from the script name and I don't believe using that SLNet message is the best way of going about canceling a running script.
The same script can be called more than once and the ScriptID is an identifier of each of those instances as you can see below.
I believe the best approach is for the script itself to have a mechanism to cancel its execution or leverage the engine.Timeout property to ensure a script does not run indefinitely.
Hi Ana,
Unfortunately, I do not think it is possible to achieve what you are after.
Besides the fact that forcibly stopping a running piece of code can cause unexpected problems and data corruption depending on the operation currently executing, to my knowledge there is no straightforward way of retrieving and identifying which script execution has which ID unless you use the source from my screenshot.
I believe your best bet will be to create a new feature request here https://community.dataminer.services/feature-suggestions to be able to cancel a running script externally as it should be implemented in a safe way that allows the script to do some cleanup before exiting similar to what a CancellationToken allows.
Hi
In my use case, the end user really wants to abort the execution of the script from the “outside”. The end goal is to have a button for that. It shouldn’t be a situation that occurs often, but they still want to have that possibility.