Overview: I am running into an issue where I am creating a Collection when a user clicks on a List Item. The issue is that whenever a user clicks on a List Item, the collection is being populated with the previous selected item's data.
My setup: In the SharePointIntegration: OnView property
Clear(colVendorContacts);
Set(
varNewContact,
false
);
ForAll(
Split(
SharePointIntegration.Selected.VendorContact,
"; "
),
Collect(
colVendorContacts,
{
Name: First(
Split(
Result,
"-"
)
).Result,
ContactType: Last(
FirstN(
Split(
Result,
"-"
),
2
)
).Result,
State: Last(
FirstN(
Split(
Result,
"-"
),
3
)
).Result,
Email: Last(
FirstN(
Split(
Result,
"-"
),
4
)
).Result,
PhoneNumberCell: Last(
FirstN(
Split(
Result,
"-"
),
5
)
).Result,
PhoneNumberDesk: Last(
FirstN(
Split(
Result,
"-"
),
6
)
).Result
}
)
);
ViewForm(SharePointForm1)
What is happening:
(When opening list and the first time you select a item)
I am absolutely willing to provide more detail where needed. Any help would be great!
Solved! Go to Solution.
Your ForAll is backward...ForAll produces a table. Are you adding or removing or altering records of the collection you are bringing in? If so, a collection is fine, otherwise it is overhead.
Your formula should be as follows to use the ForAll as intended. Note: there were a couple of syntax issues with the first suggestion (sorry, we type these things by hand in the forum without the formula editor):
Set(varNewContact, false );
With({_record: LookUp(ProductServices,ID=SharePointIntegration.SelectedListItemID)},
ClearCollect(colVendorContacts,
ForAll(
Filter(Split(_record.VendorContact, "; "), !IsBlank(Result)) As _item,
With({_row: Split(_item.Result, "-")},
{Name: Last(FirstN(_row.Result, 1)).Result,
ContactType: Last(FirstN(_row.Result, 2)).Result,
State: Last(FirstN(_row.Result, 3)).Result,
Email: Last(FirstN(_row.Result, 4)).Result,
PhoneNumberCell: Last(FirstN(_row.Result, 5)).Result,
PhoneNumberDesk: Last(FirstN(_row.Result, 6)).Result
}
)
)
)
);
ViewForm(SharePointForm1)
When I take that formula and test it out with this:
With({VendorContact:"abc-def-ghi-jkl-mno-pqr; pqr-mno-jkl-ghi-def-abc"},
ClearCollect(colVendorContacts,
ForAll(
Filter(Split(VendorContact, "; "), !IsBlank(Result)) As _item,
With({_row: Split(_item.Result, "-")},
{Name: Last(FirstN(_row.Result, 1)).Result,
ContactType: Last(FirstN(_row.Result, 2)).Result,
State: Last(FirstN(_row.Result, 3)).Result,
Email: Last(FirstN(_row.Result, 4)).Result,
PhoneNumberCell: Last(FirstN(_row.Result, 5)).Result,
PhoneNumberDesk: Last(FirstN(_row.Result, 6)).Result
}
)
)
)
);
It results in :
Please consider changing your Formula to the following:
Set(varNewContact, false);
With(LookUp(yourDataSource, ID=SharePointIntegration.SelectedListItemID)
Set(colVendorContacts,
ForAll(
Filter(Split(VendorContact, "; "), !IsBlank(Result)),
With(Split(Result, "-"),
{Name: Last(FirstN(Result, 1)).Result
ContactType: Last(FirstN(Result, 2)).Result
State: Last(FirstN(Result, 3)).Result,
Email: Last(FirstN(Result, 4)).Result,
PhoneNumberCell: Last(FirstN(Result, 5)).Result,
PhoneNumberDesk: Last(FirstN(Result, 6)).Result
}
)
)
);
ViewForm(SharePointForm1)
In the above (beside a little more streamlined and not consuming the overhead for a collection), the reliance is on the SelectedListItemID instead of the selectedItem.
I tend to find that property a little more reliable.
See if that makes any difference.
Thanks for the reply! Using the With() function did help and maybe I wasn't detailed enough in my post, but I did need to still use the collect to get all of the data from the Split(VendorContacts).
Clear(colVendorContacts);
Set(varNewContact, false );
With(LookUp(ProductServices,ID=SharePointIntegration.SelectedListItemID),
ForAll(
Split(VendorContact,"; "),
Collect(colVendorContacts,
{
Name: First(Split(Result,"-")).Result,
ContactType: Last(FirstN(Split(Result,"-"),2)).Result,
State: Last(FirstN(Split(Result,"-"),3)).Result,
Email: Last(FirstN(Split(Result,"-"),4)).Result,
PhoneNumberCell: Last(FirstN(Split(Result,"-"),5)).Result,
PhoneNumberDesk: Last(FirstN(Split(Result,"-"),6)).Result
}
)
)
);
ViewForm(SharePointForm1)
Anyway, my first column in my collect, "Name", is not working correctly. Instead it is saving the data in a "{Name}" column in the collection. Any thoughts?
Thanks!
Your ForAll is backward...ForAll produces a table. Are you adding or removing or altering records of the collection you are bringing in? If so, a collection is fine, otherwise it is overhead.
Your formula should be as follows to use the ForAll as intended. Note: there were a couple of syntax issues with the first suggestion (sorry, we type these things by hand in the forum without the formula editor):
Set(varNewContact, false );
With({_record: LookUp(ProductServices,ID=SharePointIntegration.SelectedListItemID)},
ClearCollect(colVendorContacts,
ForAll(
Filter(Split(_record.VendorContact, "; "), !IsBlank(Result)) As _item,
With({_row: Split(_item.Result, "-")},
{Name: Last(FirstN(_row.Result, 1)).Result,
ContactType: Last(FirstN(_row.Result, 2)).Result,
State: Last(FirstN(_row.Result, 3)).Result,
Email: Last(FirstN(_row.Result, 4)).Result,
PhoneNumberCell: Last(FirstN(_row.Result, 5)).Result,
PhoneNumberDesk: Last(FirstN(_row.Result, 6)).Result
}
)
)
)
);
ViewForm(SharePointForm1)
When I take that formula and test it out with this:
With({VendorContact:"abc-def-ghi-jkl-mno-pqr; pqr-mno-jkl-ghi-def-abc"},
ClearCollect(colVendorContacts,
ForAll(
Filter(Split(VendorContact, "; "), !IsBlank(Result)) As _item,
With({_row: Split(_item.Result, "-")},
{Name: Last(FirstN(_row.Result, 1)).Result,
ContactType: Last(FirstN(_row.Result, 2)).Result,
State: Last(FirstN(_row.Result, 3)).Result,
Email: Last(FirstN(_row.Result, 4)).Result,
PhoneNumberCell: Last(FirstN(_row.Result, 5)).Result,
PhoneNumberDesk: Last(FirstN(_row.Result, 6)).Result
}
)
)
)
);
It results in :
Yes that is working for me. I am still getting the "{Name}" column within my collection - it is blank. But the data is correctly being placed within the "Name" column.
To answer your question, yes. I am adding, removing, modifying the collection. Thanks for helping me get to a much more efficient application.
Your {Name} column is a ghost. If you save, exit and load again, it will be gone. If not, I would be concerned that something else in your app is impacting that, and you WOULD want to determine what it is as it is a schema mismatch issue.
You are correct. That column is no longer showing. Thanks Randy
User | Count |
---|---|
256 | |
106 | |
92 | |
47 | |
37 |