Issue
Symptoms
When the duration field is calculated from date type fields using g_form.setValue() in a client script, the value is not saved on saving the form.
Release
All
Cause
The probable cause of the issue is the existing problem - PRB1274011. According to the problem, using g_form.setValue() on a Duration field does not work correctly. However, after considering the priority and severity of the problem, it is closed as won't fix.
Resolution
In order to resolve, please use Before Update business rule that uses "gs.dateDiff", and this will work as a workaround. Refer the below link for a sample script.
https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_GS-dateDiff_S_S_B