We recently had a requirement to show in header of one of the form, the value from its related entity. So we thought that we will create a new custom field, move it to the header and populate it’s value using JScript in the onload event.
However as we were writing the JScript we realized that the field that is in the header of the form is not accesible using Xrm.Page.data.entity.attribute.
So the next thought was to add that field in the body of the form as well.
So now we had that field in header as well as in the body. Now when we were setting the value of the field that was in the body, it was getting set properly as expected. But that value was not getting reflected in the same field in the header till we save the form.
We finally used document.getElementById to set the value for the field in the header.
Hope it helps.