As we all know activities can be created from Notes section or new Timeline control in UCI. Creating activity from Timeline control does auto populate Required Attendees field with parent entity reference. However same does not happen when activity is created from sub-grid added on parent entity form. This is because when sub-grid is configured it only shows relationship with Regarding field and not with Required Attendees which is party list. Therefore, creating activity from sub-grid only populates Regarding field value.
Let’s see it in action:
- Creating appointment from Timeline on Account entity
- As you can see below, Family which is Required Attendees field here and Regarding both are populated with Test Account.
- Let’s now add appointment sub-grid on account form and as you can see below, it gives only Appointment (Regarding) option under Entity to select which is why only Regarding gets populated when created from sub-grid
- Creating appointment from sub-grid on Account entity
- As you can see below, Family is not populated this time but Regarding does
So, to populate Family (party list) when appointment is created from sub-grid, we can write below JavaScript code which would validate if Family value is null and Regarding value exists and populate Family from Regarding.
function onLoad(executionContext) { var formContext = executionContext.getFormContext(); var requiredAttendees = formContext.getAttribute(“requiredattendees”).getValue(); var regardingObjectId = formContext.getAttribute(“regardingObjectId”).getValue(); if (formContext.getFormType() === FormTypes.Create && requiredAttendees === null) { if (regardingObjectId !== null && regardingObjectId.length > 0 && regardingObjectId[0] !== null && regardingObjectId[0].entityType === “account”) { var partylist = []; partylist[0] = {}; partylist[0].id = regardingObjectId[0].id; partylist[0].name = regardingObjectId[0].name; partylist[0].entityType = regardingObjectId[0].entityType; formContext.getAttribute(“requiredattendees”).setValue(partylist); } } } |
*This post is locked for comments