There are a few different approaches developers used to prepopulate the “Regarding” and “Activity Party” fields of activities:
- 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:
- 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