Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Custom Features not in AbpFeatures Table #5743


User avatar
0
davidharrison created

Hi Guys,

I've added a new feature into the application, as shown below:

    public static class AppFeatures
    {
        public const string SubmissionLimit = "App.SubmissionLimit";
        public const string StarterSubmissionLimit = "App.StarterSubmissionLimit";
    }
    
    public class AppFeatureProvider : FeatureProvider
    {
        public override void SetFeatures(IFeatureDefinitionContext context)
        {
            var submissionLimit = context.Create(
                AppFeatures.SubmissionLimit,
                defaultValue: "true",
                displayName: L("SubmissionLimit"),
                inputType: new CheckboxInputType()
                );

            submissionLimit.CreateChildFeature(
                AppFeatures.StarterSubmissionLimit,
                defaultValue: "100",
                displayName: L("StarterSubmissionLimit"),
                inputType: new SingleLineStringInputType(new NumericValueValidator(0, 100))
                );
        } 
    }

I am able to see these new features in the edit edition modal and I am able to select them, however the new features don't appear in the AbpFeatures table as having been assigned to the edition - is there something that I am missing here?


5 Answer(s)
  • User Avatar
    0
    davidharrison created

    Update: So my current understanding that the features will only show up in the AbpFeatures table when a non-default value is specified. Using the FeatureChecker.GetValueAsync functionality will return either the default value (presumably from the feature definition) or the non-default value from the database.

  • User Avatar
    0
    davidharrison created

    Hi Maliming

    Here is the data in my AbpFeatures table:

    Id	CreationTime	CreatorUserId	Discriminator	Name	Value	EditionId	TenantId
    1	2018-03-16 14:38:16.4764368	NULL	EditionFeatureSetting	App.ChatFeature	true	1	NULL
    2	2018-03-16 14:38:16.5210188	NULL	EditionFeatureSetting	App.ChatFeature.TenantToTenant	true	1	NULL
    3	2018-03-16 14:38:16.5225230	NULL	EditionFeatureSetting	App.ChatFeature.TenantToHost	true	1	NULL
    4	2018-10-10 12:14:40.9736974	1	EditionFeatureSetting	App.ChatFeature	true	2	NULL
    5	2018-10-10 12:14:40.9881633	1	EditionFeatureSetting	App.ChatFeature.TenantToHost	true	2	NULL
    6	2018-10-10 12:14:40.9917917	1	EditionFeatureSetting	App.ChatFeature.TenantToTenant	true	2	NULL
    7	2018-10-10 12:14:40.9993621	1	EditionFeatureSetting	App.TestCheckFeature2	false	2	NULL
    9	2018-10-10 13:03:44.7374498	1	EditionFeatureSetting	App.SubmissionLimitAmount	500	2	NULL
    

    The new custom feature, SubmissionLimitAmount, only shows up for Edition 2, but not for Edition 1, even though they both now have that feature. Edition 2 has a non-default value set for its SubmissionLimitAmount, while Edition 1 has the default value, and this would be why one shows up and the other doesn't?

  • User Avatar
    0
    maliming created
    Support Team
  • User Avatar
    0
    davidharrison created

    Hi Maliming,

    Thank you for your response and help.

    As noted by Hikalkan in the Git Link:

    Only default values are not saved (because they are default and hard-coded in your code) and when you get a feature's value, this default value is returned.

    It would be good if this was stated in the documention for features: Feature Management

  • User Avatar
    0
    maliming created
    Support Team

    I think it would be helpful to explain it in the documentation.