Freedom UI Detail List inline adding record - set Lookup column default value
Hello,
when adding a record inline of detail list, is it possible in code to set default value for Lookup column?
Thanks.
Like
Here is a code sample on how I solved it, maybe it helps somebody:
handlers: /**SCHEMA_HANDLERS*/[
{
request: "crt.HandleViewModelAttributeChangeRequest",
/* The custom implementation of the system request handler. */
handler: async (request, next) => {
if (request.attributeName === 'GridDetail_u6gv7vy_ActiveRow') {
const activeRowId = await request.$context.GridDetail_u6gv7vy_ActiveRow;
const gridDetail = await request.$context.GridDetail_u6gv7vy;
const defaultType = await request.$context.SWGLookupFileType;
gridDetail.forEach((item) => {
if (item.attributes.GridDetail_u6gv7vyDS_Id == activeRowId
&& !item.attributes.GridDetail_u6gv7vyDS_Type
)
{
item.attributes.GridDetail_u6gv7vyDS_Type = defaultType;
}
});
}
return next?.handle(request);
}
}
]/**SCHEMA_HANDLERS*/
Please change "GridDetail_u6gv7vy" name to your list name and also attribute names ("item.attributes.GridDetail_u6gv7vyDS_Id" or "GridDetail_u6gv7vyDS_Type").