Skip to main content

Highlight/Visualize Form BPF Required Fields -JS

This was a nifty function I used to highlight required fields for the current BPF stage as a business recommended so the user did not need to expand the BPF but instead the fields would be highlighted with the blue asterisks

HighlightStageRequiredFields = function (executionContext) {
    var formContext = executionContext.getFormContext();
    var activeStage = formContext.data.process.getActiveStage();
    var steps = activeStage.getSteps();
    steps.forEach(function (step) {
        var attribute = formContext.getAttribute(step.getAttribute());
        if (step.isRequired() && (attribute.getValue() === null ||  attribute.getValue() === false)  ) {
            if (attribute.getRequiredLevel() !== "required") {
                attribute.setRequiredLevel("recommended");
            }
        }
    });
};

Register this on load and on process change to highlight the fields as the BPF moves stages. Pair this with a field or custom PCF control to move stages and you never have to expand the BPF.

Watch out for the ands when copying in line 7.

PowerApps CDS Uploading and Viewing Images

Code Function snippets used

Concatenate("data:" ,ThisItem.mimetype,";base64, ",ThisItem.documentbody)

"<div> <img src=’data:image/png;base64, {b64 here}}’ /> <h1>John Doe</h1> <p class=’title’>CEO & Founder, Example</p>

</div>"

"<div> <img src=’data:image/png;base64, "& vFirstImage.Document &"’ /> <h1>" & Text( Concatenate(gRegs.Selected.Firstname," ",gRegs.Selected.Lastname) &"</h1> <p class=’title’>"& Concatenate("Job ",gRegs.Selected.Jobtitle)& "</p>

</div>"