Hi partner,
In Dynamics 365, we could add js code to form with different events.

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/events-forms-grids
I'm not sure about your requirement from your description so I would like to provide 2 ways for your reference.
1.Onload event
If you want to trigger your js code when loading the form, you could add your js function to "Onload" event.

2.Onchange
If you want to trigger your js code when finish updating one field, you could add the function to the field "Onchange" event.

BTW, if my understanding is not correct, please show us more information about your requirement so that we could help you better.
Hope it helps.
Best Regards,
Leo