Skip to content
Charles Llamas

Get the list of all attributes in a form using JavaScript

1 min read

This post is only available in English.

The below function show the list of all attributes in a dynamics 365 form:

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);
}

Note: The function not consider the fields in BPF, just take the fields presents in the form.

Open the browser console in order to see the result.

Related posts

Comments

No comments yet

No comments yet. Yours would be the first.

Leave a comment

Never published. Only used if I need to reply to you.

← All posts