Custom function not automatic updating

I try to create a custom function for checking cell background color.

Function ColorCheck()
Dim v
oActiveSheet = ThisComponent.getCurrentController().getActiveSheet()
v=oActiveSheet.getCellByPosition( 0, 0)
if vartype(v) = 9 then
  ColorCheck = v.CellBackColor
else
if v.CellBackColor = 2302940 then
  ColorCheck = "TRUE"
endif
End Function

It basically works when I use “=ColorCheck()”, but if I update the background of the referenced cell the value does not change until I recreate my function entry. I tried recalculating function but I does not work too.

How can I get this to auto update the value if I change the Color ?

Try this

=ColorCheck() + INT(RAND())

Functions such as RAND(), NOW(), TODAY() are calculated when the data changes on the sheet and it will lead to a recalculation each of formulas in which they are included.
INT(RAND()) always equal zero. So, you can add this zero to result of your function

(But you will have TRUE0 for color 2302940!)

An ugly hack but works, thanks. MS Office has a proper way to do this, but sadly LO appears to lack it.