public void FieldUsingTokensAreCorrectlyOrdered() { var template = new ProvisioningTemplate(); template.Parameters.Add("TestFieldPrefix", "PnP"); var contentType = new ContentType { Id = "0x010100503B9E20E5455344BFAC2292DC6FE805", Name = "Test Content Type", Group = "PnP", Description = "Test Description", Overwrite = true, Hidden = false }; var nonOobField = new Field { SchemaXml = "<Field ID=\"{dd6b7dae-1281-458d-a66c-01b0c7b7930b}\" Name=\"{parameter:TestFieldPrefix}TestField\" DisplayName=\"TestField\" Type=\"Note\" Group=\"PnP\" Description=\"\" />" }; template.SiteFields.Add(nonOobField); contentType.FieldRefs.Add(new FieldRef("{parameter:TestFieldPrefix}TestField") { Id = new Guid("{dd6b7dae-1281-458d-a66c-01b0c7b7930b}") }); contentType.FieldRefs.Add(new FieldRef("AssignedTo") { Id = BuiltInFieldId.AssignedTo }); template.ContentTypes.Add(contentType); using (var ctx = TestCommon.CreateClientContext()) { TokenParser parser = new TokenParser(ctx.Web, template); new ObjectField(FieldAndListProvisioningStepHelper.Step.ListAndStandardFields).ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation()); new ObjectContentType(FieldAndListProvisioningStepHelper.Step.ListAndStandardFields).ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation()); var ct = ctx.Web.GetContentTypeByName("Test Content Type"); ct.EnsureProperty(x => x.FieldLinks); Assert.AreEqual(ct.FieldLinks[0].Id, template.ContentTypes.First().FieldRefs[0].Id); Assert.AreEqual(ct.FieldLinks[1].Id, template.ContentTypes.First().FieldRefs[1].Id); } }
public void WorkflowTaskOutcomeFieldIsUnique() { var template = new ProvisioningTemplate(); var contentType = new ContentType { Id = "0x0108003365C4474CAE8C42BCE396314E88E51F008E5B850C364947248508D252250ED723", Name = "Test Custom Outcome Workflow Task", Group = "PnP", Description = "Ensure inherited workflow task displays correct custom OutcomeChoice", Overwrite = true, Hidden = false }; var nonOobField = new Field { SchemaXml = "<Field ID=\"{35e4bd1f-c1a3-4bf2-bf86-4470c2e8bcfd}\" Type=\"OutcomeChoice\" StaticName=\"AuthorReviewOutcome\" Name=\"AuthorReviewOutcome\" DisplayName=\"AuthorReviewOutcome\" Group=\"PnP\">" + "<Default>Approved</Default>" + "<CHOICES>" + "<CHOICE>Approved</CHOICE>" + "<CHOICE>Rejected</CHOICE>" + "<CHOICE>Reassign</CHOICE>" + "</CHOICES>" + "</Field>" }; template.SiteFields.Add(nonOobField); contentType.FieldRefs.Add(new FieldRef("AuthorReviewOutcome") { Id = new Guid("{35e4bd1f-c1a3-4bf2-bf86-4470c2e8bcfd}") }); template.ContentTypes.Add(contentType); using (var ctx = TestCommon.CreateClientContext()) { TokenParser parser = new TokenParser(ctx.Web, template); new ObjectField(FieldAndListProvisioningStepHelper.Step.ListAndStandardFields).ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation()); new ObjectContentType(FieldAndListProvisioningStepHelper.Step.ListAndStandardFields).ProvisionObjects(ctx.Web, template, parser, new ProvisioningTemplateApplyingInformation()); var ct = ctx.Web.GetContentTypeByName("Test Custom Outcome Workflow Task"); ct.EnsureProperty(x => x.Fields); Assert.AreEqual(ct.Fields.Count(f => f.FieldTypeKind == FieldType.OutcomeChoice), 1); } }