Skip to content

Example: Workflow

Magnus Gether Sørensen edited this page Jun 30, 2017 · 3 revisions

Scenario

When an account is created, the name should be changed to the following format "name - name".

Creating the test

The following test ensures that the specification is met.

[TestMethod]
public void TestStringAdd() {
    using (var context = new Xrm(orgAdminUIService)) {
        var acc = new Account();
        acc.Name = "WapAdd";
        acc.Id = orgAdminUIService.Create(acc);

        var retrieved = orgAdminUIService.Retrieve(Account.EntityLogicalName, acc.Id, new ColumnSet(true)) as Account;
        Assert.AreEqual(acc.Name + " - " + acc.Name + " ", retrieved.Name);
    }
}

Creating the workflow

The logic is to be implemented by a workflow. The following workflow implements that logic.

Workflow used in test for XrmMockup

Then the MetadataGenerator is run, such that the new workflow is included in the metadata. Notice that the workflow is automatically run by XrmMockup when the account is created.