Page 1 of 1

Problem with retrieving correct Task ID

Posted: Wed Apr 30, 2025 1:44 pm
by nurv
Hello,

I’m having trouble retrieving the correct Task ID. For example, I have a task with the External Name “Task 9”, and its Task ID is 303E887B. However, when I display the {TaskID} variable, it shows 809404539, which is incorrect. {TaskExtName} correctly returns “Task 9”, but {GetTaskIdByExtName({TaskExtName})} also returns the wrong value: 809404539.

In another task, {TaskID} even returns a negative number.

How can I reliably get the correct Task ID (the one that looks like 303E887B)? This is very important for my project.

Thank you very much for your help!

Re: Problem with retrieving correct Task ID

Posted: Fri May 02, 2025 7:46 am
by Oleg
Task ID is an integer value
809404539 - in decimal format
303E887B - in HEX format

809404539 (dec) equals to 303E887B (hex). You can check it in system calculator.

To convert decimal value to hex format use hex() function of VB script

Also look at the example below.

To convert the HEX format to decimal, just place the "&H" characters in front of the HEX value. (see step #4 of example)

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|307868550
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1573"
Hide=INTEGER|0
ID=INTEGER|-741371817
LogOnAsUser=INTEGER|1
Name=STRING|"Task ID example (v2)"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""_dec"" with value ""{TaskID}"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"_dec"
expand=STRING|"1"
linecount=STRING|"1"
varname=STRING|"_dec"
varvalue=STRING|"{TaskID}"

[Actions\Action2]
ActionID=STRING|"A_SCRIPT_VBEVALUATE"
Enabled=INTEGER|-1
Name=STRING|"VB Evaluate"
Params=FOLDER

[Actions\Action2\Params]
_rt_variables_produced=STRING|"_hex"
expression=STRING|"hex({_dec})"
linecount=STRING|"0"
loadfromfile=STRING|"1"
variable=STRING|"_hex"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""decimal = {_dec}"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"decimal = {_dec}"
msg1=STRING|"hex = {_hex}"
msg2=STRING|"ext name(1) = {GetTaskExtNameById({_dec})}"
msg3=STRING|"ext name(2) = {GetTaskExtNameById(${_hex})}"
msg5=STRING|"GetTaskExtNameById = {GetTaskExtNameById({TaskId})}"
msgcount=STRING|"6"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_SCRIPT_VBEVALUATE"
Enabled=INTEGER|-1
Name=STRING|"VB Evaluate"
Params=FOLDER

[Actions\Action4\Params]
_rt_variables_produced=STRING|"_dec2"
expression=STRING|"&H{_hex}"
linecount=STRING|"0"
loadfromfile=STRING|"1"
variable=STRING|"_dec2"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""decimal from hex = {_dec2}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"decimal from hex = {_dec2}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

Re: Problem with retrieving correct Task ID

Posted: Wed Jun 25, 2025 4:44 pm
by mromer5129
There's still part of the OP that isn't addressed, and it's a problem for me, too. I'm working on a task to loop through the task log files and copy them to an archive location. In the process, I want to rename the files based on the Task External Name and a Date. I've made the external name on each task identical to the task name. So, for example, C:\ProgramData\RoboTask\Logs\EB591181.log gets copied to E:\Archive\CertificateCheck.20250620.log.

This works fine for some of the jobs. I can take the log filename, convert it to decimal, put that value in a new variable {DecOfLogFileName}, and use {GetTaskExtNameById({DecOfLogFileName})} to get the external name.

However, the task that logs at C:\ProgramData\RoboTask\Logs\EB591181.log does not work for this. EB591181 converts to 3948482945, and GetTaskExtNameById with that value gives me nothing. Within that task, if I display {TaskId}, I get -346484351 instead of 3948482945.

Why do I get a negative number for {TaskID} for this task, and why does {TaskID} not match the decimal conversion of the log file name? Other tasks have positive {TaskID}s, and everything works.

Re: Problem with retrieving correct Task ID

Posted: Mon Jun 30, 2025 5:54 pm
by Oleg
However, the task that logs at C:\ProgramData\RoboTask\Logs\EB591181.log does not work for this. EB591181 converts to 3948482945, and GetTaskExtNameById with that value gives me nothing. Within that task, if I display {TaskId}, I get -346484351 instead of 3948482945.
Look at the task below.
It converts the value EB591181 to -346484351 as signed 32-bit integer
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|307868550
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1582"
Hide=INTEGER|0
ID=INTEGER|-691885458
LogOnAsUser=INTEGER|1
Name=STRING|"Value format (Hexdecimal->Decimal)..."
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VALUEFORMAT"
Enabled=INTEGER|-1
Name=STRING|"Value format (Hexdecimal->Decimal)"
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"FormatResult"
format=STRING|"Hexdecimal"
fromvalue=STRING|"EB591181"
group=STRING|"Integer value"
resultvar=STRING|"FormatResult"
reverse=STRING|"1"
value=STRING|"Decimal"

[Actions\Action2]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action2\Params]
expression=STRING|"3"
message=STRING|"{FormatResult}"
mode=STRING|"0"
type=STRING|"3"


Re: Problem with retrieving correct Task ID

Posted: Mon Jun 30, 2025 6:00 pm
by Oleg
Also see how to convert HEX to DEC by using VB

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|307868550
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1584"
Hide=INTEGER|0
ID=INTEGER|120643874
LogOnAsUser=INTEGER|1
Name=STRING|"convert HEX as DEC using VB"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""_hex"" with value ""EB591181"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"_hex"
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"_hex"
varvalue=STRING|"EB591181"

[Actions\Action2]
ActionID=STRING|"A_SCRIPT_VBEVALUATE"
Enabled=INTEGER|-1
Name=STRING|"VB Evaluate"
Params=FOLDER

[Actions\Action2\Params]
_rt_variables_produced=STRING|"_dec"
expression=STRING|"&H{_hex}"
linecount=STRING|"0"
loadfromfile=STRING|"1"
variable=STRING|"_dec"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""HEX = {_hex}"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"HEX = {_hex}"
msg1=STRING|"DEC = {_dec}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"