Set a Field Value on a Task or Appointment
After getting the response from getRecordByContext, set values of
the Task and Appointment objects using the SetFieldValue global
function.
After getting response from getRecordByContext, set values of the Task
and Appointment objects with the SetFieldValue global function.
const setFieldValue = await $modules.uiEventsFramework.setFieldValue('ObjectName.FieldName', 'Value to SET', callGetRecordByContext.response);
The following action chain listens for the OnChildRecordOpen event and
updates the Subject value from an Appointment child record in UI.
When a Task or Appointment create or edit page opens, the event provides the child
record’s objectId and objectType. The action chain
uses these values with getRecordByContext to obtain the child record’s
UEF context. It then uses that context to update the Task.Subject field
value.
define([
'vb/action/actionChain',
'vb/action/actions',
'vb/action/actionUtils',
], (
ActionChain,
Actions,
ActionUtils
) => {
'use strict';
class recordLevelEventListener extends ActionChain {
/**
* @param {Object} context
* @param {Object} params
* @param {{data:any,eventName:string,recordType:string}} params.event
*/
async run(context, { event }) {
const { $page, $flow, $application, $base, $extension, $constants, $variables, $modules } = context;
switch (event.eventName) {
case 'OnChildRecordOpen':
const callGetRecordByContext = await $modules.uiEventsFramework.getRecordByContext($variables.uefContext,
{ objectId: event.data.objectId, objectType: event.data.objectType });
const setFieldValue = await $modules.uiEventsFramework.setFieldValue('Task.Subject', 'Value to SET', callGetRecordByContext.response);
break;
}
}
}
return recordLevelEventListener;
});
| Parameter | Description |
|---|---|
event.eventName |
Identifies the received UEF event. The action chain handles
OnChildRecordOpen. |
event.data.objectId |
Unique ID of the opened Task or Appointment record. |
event.data.objectType |
Business object type of the opened child record. |
getRecordByContext |
Retrieves the UEF context for the opened child record. |
callGetRecordByContext.response |
The returned UEF context for the child record. |
setFieldValue |
Updates a field value using the child record’s UEF context. |
Task.Subject |
The field identifier for the Task Subject field. |
Example: Set the Task Subject
if (event.data.objectType === 'Task') {
await $modules.uiEventsFramework.setFieldValue(
'Task.Subject',
'Value to set',
childRecordContext.response
);
}
The function changes the value displayed on the open child-record page. Call
SaveRecord when the change must also be saved.