Obtener la lista de todos los atributos de un formulario con JavaScript
1 min de lectura
Charles Llamas
La siguiente función muestra la lista de todos los atributos de un formulario de Dynamics 365:
function getAttributes(executionContext){ var attributes = {}; var formContext = executionContext.getFormContext(); formContext.data.entity.attributes.forEach( function(attribute,index){ var logicalName = attribute.getName(); attributes[logicalName] = { 'DisplayName':formContext.getControl(logicalName).getLabel(), 'Type':attribute.getAttributeType(), 'Value': attribute.getValue(), 'IsDirty': attribute.getIsDirty(), 'RequiredLevel': attribute.getRequiredLevel(), 'IsDisabled' : formContext.getControl(logicalName).getDisabled(), 'IsVisible' : formContext.getControl(logicalName).getVisible(), }; } ); console.table(attributes); }
Nota: La función no tiene en cuenta los campos del flujo de proceso de negocio (BPF); solo toma los campos presentes en el formulario.
Abre la consola del navegador para ver el resultado.
