Hi Alexey,
You would be better doing this in the Anywhere configuration as opposed to an Automation script in core Maximo.
I have not tried to do this in our own demo system but looks like in the WorkExecution app the async_valLoccheckLocationFound method in the WODetailHandler.js is where you would need to implement this.
It already sets the location if an Asset is selected first so using a similar way you would need to put new code in to fetch the count of assets for the selected location and if equal to 1 then set the asset value.
Using this method would mean the user of the Anywhere application would be able to see the returned asset number.
I hope this helps, if you need more information then please let me know and will see if we can get this working in our system and send you the code.
------------------------------
Steve Lee
IBM AI Applications
Maximo Solution Engineer
Leeds
------------------------------