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

Adding code to support multiple default values at folder level. #850

Merged
merged 1 commit into from
Mar 16, 2023

Conversation

roberAlb
Copy link

Multiple default values for folder were not supported. We have added code to support them for the provisioning.

jansenbe added a commit that referenced this pull request Mar 16, 2023
@jansenbe jansenbe merged commit 0d08c46 into pnp:dev Mar 16, 2023
@PedroMordeP
Copy link
Contributor

PedroMordeP commented Jun 28, 2023

Hi, I'm getting an error on line var splitData = terms[q + 1].Split(new char[] { '|' });

It gives an "Index was outside the bounds of the array" (IndexOutOfRangeException )

The scenario is when you have only one value

<pnp:Folders>
    <pnp:Folder Name="Contoso Construction">
          <pnp:DefaultColumnValues>
              <pnp:DefaultColumnValue Key="Industry" Value="Construction" />
          </pnp:DefaultColumnValues>
    </pnp:Folder>
<pnp:Folders>

What I did at this moment was to check like this

        private static List<string> TermIdsToProcess(string value)
        {
            var termDefaultValuesParsed = new List<string>();

            // FIX - Support only one item - to fix the issue on line 'terms[q + 1].Split(new char[] { '|' });' - gives OutOfRange exception
            if (!value.Contains(";#"))
            {
                termDefaultValuesParsed.Add(value);
                return termDefaultValuesParsed;
            }
            // -----

            var terms = value.Split(new[] { ";#" }, StringSplitOptions.None);
            for (int q = 0; q < terms.Length; q += 2)
            {
                var splitData = terms[q + 1].Split(new char[] { '|' });
                var termIdString = splitData[1];
                termDefaultValuesParsed.Add(termIdString);
            }

            return termDefaultValuesParsed;
        }

Hope this can help to review/update the code to support this scenario

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 this pull request may close these issues.

None yet

3 participants