onChange field value does not keep new value when item is saved
Hi everyone,
I have an on change event that fires when one of my stock fields are changed, which should change the value of a stock message field.
The function I have is able to change the value of the stock message field, but when I save/click done, the value is not updated in the properties.
My code:
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:c1696a98-fd57-4cfc-a98f-2b8ea9cbbe99:type=text&text=var%20fMinStock%20%3D%20document.getElementsByName%28%22_minimum_stock%22%29%5B1%5D.value%3B%0D%0Avar%20fCurrStock%20%3D%20document.getElementsByName%28%22_current_stock%22%29%5B1%5D.value%3B%0D%0Avar%20iMinStock%20%3D%20parseInt%28fMinStock%29%3B%0D%0Avar%20iCurrStock%20%3D%20parseInt%28fCurrStock%29%3B%0D%0Avar%20fStockMessage%20%3D%20getFieldByName%28%22_stock_message%22%29.getElementsByTagName%28%22input%22%29%5B0%5D%3B%0D%0A%20%20%20%20%0D%0Avar%20stockMsg%20%3D%20%22%22%3B%0D%0Avar%20stockMsgColor%20%3D%20%22%22%3B%0D%0A%20%20%20%20%0D%0Aif%28iCurrStock%20%3C%20iMinStock%29%7B%0D%0A%20%20%20%20stockMsg%20%3D%20%22Insufficient%20Stock%22%3B%0D%0A%7Delse%7B%0D%0A%20%20%20%20stockMsg%20%3D%20%22Sufficient%20Stock%22%3B%0D%0A%7D%0D%0A%20%20%20%20%0D%0AfStockMessage.value%20%3D%20stockMsg%3B]
The onChange in action:
When save or done is clicked after onChange:
Any ideas on what I might be doing wrong?
Can you try using window.handleItemChange('_stock_message', stockMsg);