1
votes

I have a question about a lookup field that gets auto populated, which I don't want. I don't really understand why it is auto populated and I would like to know if there is some way to prevent this from happening.

After clicking the + icon, a new create form appears. The 'Case' field is filled (as expected, since it is the lookup to the record I came from) and the 'Payment Type' field is empty (as expected). The 'Payment Type' field has multiple values I can select.

But when the lookup field 'Payment Type' only contains one value, it is auto populated when the create form is loaded. I can clear the field and re-fill it with the only selectable option.

enter image description here

The problem is that some javascript functionality fires on the on-change event of the 'Payment Type' field, but this does not fire when the 'Payment Field' is auto populated.

I want to know why this field is auto populated when only one record is found in the lookup and if I can turn this functionality off for this specific field, can anybody help me?

Extra info:
There is no plugin, workflow or business rule connected to this field, just the javascript functionality, which works exactly as intended when the user changes the field 'Payment Type' by hand.

2
The question is too big to comprehend, Can you please try to cut down the problem statement to what exactly is where you are stuck ??Om Sao

2 Answers

0
votes

You can add the following JavaScript on the New Payment form OnLoad event if you do not want any value for the Payment Type on new create form.

function clearPaymentTypeFieldValueOnCreate() {
var isCreateForm = (Xrm.Page.ui.getFormType() == 1);
if (isCreateForm === true) {
  var paymentTypeLookup= Xrm.Page.getAttribute("paymentTypeLookupFieldName"); //change this
  if (paymentTypeLookup!= null){
      paymentTypeLookup.setValue(null);
    }
}

enter image description here

0
votes

There is no such OOB behavior for lookup or any other fields in CRM form to set default value (auto populate). You may have some filtered lookup using addPreSearch and addCustomFilter which is setting this up.

This logic may be based on some other field. Verify this by digging in js library.