Reputation: 383
I have a form, that could have Contact
lookup field, or User
lookup field, depending on the type of the person User wants to add. Only one of the fields is visible.
There is also Name
text field, which I want to populate using name from lookup.
I want to add onChange
function on lookup field to get the name and insert it in the Name
field.
I know i can get field value like this:
Xrm.Page.getAttribute("ad_user").getValue();
But this way I would need to make separate functions for each field.
Is there a way for field with onChange
event to get its own value without quoting that fields name? Something like this:
this.getValue();
That way I could use the same function for both fields.
Upvotes: 2
Views: 783
Reputation: 2980
When registering the onChange event handler pass ExecutionContext as the first parameter. You can then get the input value like so:
Event handler registration:
Handler:
function foo_onChange(executionContext) {
var inputValue = executionContext.getEventSource().getValue();
}
Upvotes: 4