title: Attribute value gets cleared after being set by custom script
body: <p>I'm getting this weird behaviour when updating an attribute after another one has been changed. The value in <code>new_manual_invoice_number</code> is somehow cleared:</p>
  
  <pre><code>function handleInvoiceNumber(context) {
  
      if (Xrm.Page.getAttribute('invoicenumber').getValue() != undefined) {
          if (Xrm.Page.getAttribute('tec_manual_invoice_number').getValue() == undefined) {
              var manualNumber = Xrm.Page.getAttribute('invoicenumber').getValue();
              manualNumber = manualNumber.split('-')[0] + '-' + manualNumber.split('-')[1];
              Xrm.Page.getAttribute('tec_manual_invoice_number').setValue(manualNumber);
          }
      }
  
  };
  </code></pre>
  
  <p>This is running when <code>invoicenumber</code> is changed (it's a read only field and changes when the invoice is saved).</p>
  
  <p>This works fine, I can see the value appearing in the form, but somehow, something clears it and I'm getting <code>--</code> in the text box. It's not any of my other code, there's only thing function refering to <code>new_manual_invoice_number</code>.</p>
  
  <p>I've tried running this code from on a save handler, form load, etc. same behaviour.</p>
  
  <p>I've put a breakpoint in the form load's event too to see if it was not reloading due to auto-save or something, doesn't seem to be the issue.</p>
  
  <p>Any ideas ? Quite frustating...</p>
  
  <p>PS: Using Microsoft CRM 2016.</p>
  
  <p>EDIT: I think this has to do with the invoice product grid triggering other events, but I'm not sure. For the moment the code runs only on the save event of the form and this works.</p>