Skip to content

Error: removeOption function #35

@gabrieljunckes

Description

@gabrieljunckes

Hi.

In the code below, I am trying to remove an option from an option set field but when I call getOptions() the option still there.

Code

import { } from "mocha";
import { expect } from "chai";
import { XrmMockGenerator } from "xrm-mock";

describe("On Load Form", () => {
    beforeEach(() => {
        XrmMockGenerator.initialise();
        XrmMockGenerator.Attribute.createOptionSet("countries", 0, [
            { text: "Austria", value: 0 },
            { text: "France", value: 1 },
            { text: "Spain", value: 2 }
        ]);
    });

    it("Filter optionset", () => {
        let formContext = XrmMockGenerator.eventContext.getFormContext();
        let control = formContext.getControl<Xrm.Controls.OptionSetControl>("countries");

        control.removeOption(2);

        let length = formContext.getAttribute<Xrm.Attributes.OptionSetAttribute>("countries").getOptions().length;

        expect(length).to.equal(2);
    });
});

Result
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions