The onChange function should be called automatically when the associated Cloud variable is changed as long as that variable is Read/Write
Your posted code does not actually have such a function in it beyond its definition. Please post the full sketch