Blog, Development

Populate Regarding and Activity Party Fields in the UCI Interface

There are a few different approaches developers used to prepopulate the “Regarding” and “Activity Party” fields of activities:

  1. The “Microsoft” way – the way the Classic UI worked to prepopulate fields – usage of undocumented parameters passed through the url and different variations around it. From Microsoft’s perspective this approach is unsupported. I’ve published 2 posts about it on my blog:
  2. The “Supported” way that uses “Custom Parameters” that you can add to your forms. This post demonstrates the approach.

I will demonstrate the code you can use to prepopulate the Regarding and Activity Party fields in the UCI interface.

Scenario

When a user clicks the button located in contact’s command bar, he should be presented with new a Phonecall form with “to” and “regarding” fields populated with this contact.

Code

To populate the Regarding field I use “createFromEntity” parameter of entityFormOptions object. To pre-populate the “to” field, I pass an array that contains a reference to contact. So let me jump straight to the code:

function createPhoneCall(formContext){
	var recordRef = formContext.data.entity.getEntityReference();

	Xrm.Navigation.openForm({
		entityName: "phonecall",
		createFromEntity: recordRef,
		//openInNewWindow: true,//use it when you want to open new activity in the new form
		useQuickCreateForm: true//use it when you want to use "Quick Create" form
	}, {
		to: [ recordRef ]
	});
}

 

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.