Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdateSiteClassification: Settings parameter is ignored #1971

Closed
PowershellScripts opened this issue Jun 13, 2022 · 1 comment · Fixed by #1989
Closed

UpdateSiteClassification: Settings parameter is ignored #1971

PowershellScripts opened this issue Jun 13, 2022 · 1 comment · Fixed by #1989
Assignees

Comments

@PowershellScripts
Copy link
Contributor

public SiteClassificationsSettings Settings;

I might be completely wrong here, but is anything done with the value passed through Settings parameter?

Maybe something like this could be added on line 29. It's not tested, and the formatting is done using spaces, not tab (pls don't kill), but maybe you find it useful.

    protected override void ExecuteCmdlet()
    {
        try
        {
               var settings = PnP.Framework.Graph.SiteClassificationsUtility.GetSiteClassificationsSettings(AccessToken);

               if (Settings.HasValue)
               {
                    settings = Settings;
                }
                if (!Settings.HasValue)
                {
                    settings = SetSiteClassification(settings);
                }
        }
        
        if (settings.Classifications.Contains(settings.DefaultClassification))
                {
                    PnP.Framework.Graph.SiteClassificationsUtility.UpdateSiteClassificationsSettings(AccessToken, settings);
                }
                else
                {
                    WriteError(new ErrorRecord(new InvalidOperationException("You are trying to set the default classification to a value that is not available in the list of possible values."), "SITECLASSIFICATION_DEFAULTVALUE_INVALID", ErrorCategory.InvalidArgument, null));
                }
    }
    
    
    private SiteClassificationsSettings SetSiteClassification( SiteClassificationsSettings settings)
    {
            if (ParameterSpecified(nameof(Classifications)))
            {
                if (settings.Classifications != Classifications)
                {
                    settings.Classifications = Classifications;
                }
            }
            if (ParameterSpecified(nameof(DefaultClassification)))
            {
                if (settings.Classifications.Contains(DefaultClassification))
                {
                    if (settings.DefaultClassification != DefaultClassification)
                    {
                        settings.DefaultClassification = DefaultClassification;
                        changed = true;
                    }
                }
            }
            if (ParameterSpecified(nameof(UsageGuidelinesUrl)))
            {
                if (settings.UsageGuidelinesUrl != UsageGuidelinesUrl)
                {
                    settings.UsageGuidelinesUrl = UsageGuidelinesUrl;
                    changed = true;
                }
            }
           return settings;
     }
@gautamdsheth
Copy link
Collaborator

Thanks @PowershellScripts , have fixed the issue and it will be available in tomorrow's nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants