Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

[BUG] Missing parser.ParseString in UpdateListItem for Lookup fields #2772

Open
SLTKA opened this issue Sep 24, 2020 · 3 comments
Open

[BUG] Missing parser.ParseString in UpdateListItem for Lookup fields #2772

SLTKA opened this issue Sep 24, 2020 · 3 comments

Comments

@SLTKA
Copy link
Contributor

SLTKA commented Sep 24, 2020

Category

[x] Bug
[ ] Enhancement
Environment

[x] Office 365 / SharePoint Online
[ ] SharePoint 2016
[ ] SharePoint 2013
Expected or Desired Behavior

Using any token in provisioning template should use the correct token/stringValue for Lookup value
Observed Behavior

When creating DataRows in a list, the code fails with error
Apply-PnPProvisioningTemplate : Input string was not in a correct format.

Explanation:
There is token parsing code on the line 295, but if parsed value converts to, for example, 2, the code on the line 433 returns false as 2 has no splitting characters. After that, code on the line 444 executes, but instead of using processed value (with replaced tokens) it is using raw tokenized value (valuesToSet[key]) and int.Parse fails.

Possible solution:
Use value instead of valuesToSet[key] on the line 444 in ListItemUtilities.cs
Potentially the line 435 needs a fix as well because value is used in the condition, but never used to build the lookup value (multiValue)
Just a suggestion to replace everything from 433 to 446 with something like

multiValue = value
    .Split(new [] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
    .Select(v => int.Parse(v)).ToArray();

and possibly check some logic to on the following code so if multiValue is empty this will unset existing value from the list record in Overwrite mode

Steps to Reproduce

Provision a list with data where a field is using a parameter value:
.....
pnp:Parameters
<pnp:Parameter Key="MyNumber" Required="true"/>
.....
<pnp:DataRows KeyColumn="Title" UpdateBehavior="Skip">
pnp:DataRow
<pnp:DataValue FieldName="ALookupColumn">{parameter:MyNumber}</pnp:DataValue>
</pnp:DataRow>
</pnp:DataRows>
</pnp:ListInstance>

Link to code

@ghost
Copy link

ghost commented Sep 24, 2020

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Sep 24, 2020
@SLTKA SLTKA changed the title [BUG] Missing parser.ParseString in UpdateListItem [BUG] Missing parser.ParseString in UpdateListItem for Lookup fields Sep 24, 2020
@jackpoz
Copy link
Contributor

jackpoz commented Sep 25, 2020

hey @SLTKA , as you seem to be on the good track to fix the issue, could you please test it and create a pull request ?

@SLTKA
Copy link
Contributor Author

SLTKA commented Sep 28, 2020

@jackpoz I will try in the next couple days

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

No branches or pull requests

2 participants