Get the email address from SharePoint list and build Table inside Power Apps instead of hard-coding the values - sharepoint-online

We have the following Collection which contain a Type and Table of Email addresses inside Power App formula, with email addresses been hard coded, as follow:-
ClearCollect(
varUserForContracts,
{
Type: "Admin",
Emails: Table(
{UEmail: "app.admin#.org"},
{UEmail: "*****.org"},
{UEmail: ".org"},
{UEmail: "*****.org"},
{UEmail: "app.admin#.org"},
{UEmail: "*****.org"},
{UEmail: ".org"},
{UEmail: "*****.org"},
)
}
);
now instead i created a SharePoint list which include all the above emails:-
so how i can build the same Collection but to populate the table values from the values inside the SharePoint list?
Thanks

I'd recommend not using the Title column of the Sharepoint List.
Title isn't intuitive enough for code.
I'd also recommend the col prefix for Collections. Use var prefix for Variable, but don't mix them.
Add an EmailAddress and EmailType column to the List, populate their values.
Add the Sharepoint List to the PowerApp as a data source
View/Data Sources/Add data source
OnStart of the App control, add the following:
ClearCollect(colEmails,
Filter(
<YOUR_SHAREPOINT_LIST_NAME_HERE>,
EmailType = "Admin"
)
);
Beware.
IIRC the Filter() function is not Delegable to the Sharepoint server. This means that the heavy lifting is done by PowerApps itself. That means you can only Filter() Sharepoint Lists up to the number shown in File/Settings/Data row limit (500 by default, 2000 max.).
If the list exceeds that value, the Filter() only works on the first 500 up to 2000.
Obviously this won't be the case with an "Admin Email List", but when you start getting all gung ho, remember these words.
You can pull in large numbers of Sharepoint List records by using multiple ClearCollect()'s up to the 500-2000 limit, but at that point, ask yourself why do users need to peruse thousands of records in a mobile app!
Hint: They likely don't. Adding another filter to ALWAYS reduce the number below the Data row limit is the best option in terms of simplicity and performance.

Try using this formula:
ClearCollect(
varUserForContracts,
{
Type: "Admin",
Emails: ForAll(SharePointListSource, {UEmail: Title})
}
);
Where SharePointListSource is the name of your SharePoint list data source.
Documentation: ForAll function in Power Apps

Related

Using Power Apps to add a new value to a multiple-value choice column in SharePoint without overwriting existing values

I have a SharePoint list that contains a choice column with the 'multiple selection' option turned on. Each item in this list contains data related to preferences for a given user, and the choice column will store the IDs for each of the user's 'favorited' reports.
I would like to write a Patch formula in Power Apps that writes a new value to this column, but retains the existing values. Here is an extract from my current formula, triggered when a user selects the 'Add To Favorites' button, where 'Favorites' is the choice column that already contains values:
Patch(
'Platform User Preferences',
LookUp(
'Platform User Preferences',
UserEmail = User().Email
),
{Favorites: [ThisItem.ID]}
)
Current state, this formula overwrites the existing values in the choice column with the new single value, instead of adding it alongside the existing values.
One approach I have attempted (based on reading similar use cases online) is to create a collection from the Favorites column, add the new value to that collection, then patch the entire collection back to SP. However, I have had similar problems doing this as I do not fully understand the model of a collection that is based on a multi-value choice column. For example, the following also appears to completely wipe the data in the collection, rather than add to it:
ClearCollect(favslist,Filter('Platform User Preferences',UserEmail = User().Email).Favorites);
Collect(favslist, {Value: ThisItem.ID});
Any help with solving this problem would be most appreciated!
You'll need to create another collection that contains each selection of the existing favorites. Right now your 'favlist' collection contains one item that contains all the existing favorite selections, then youre adding you new item. This isn't formatted correctly this way.
Try updating your existing code before you patch, by using a ForAll and collect the existing items:
ClearCollect(existingfavslist,Filter('Platform User Preferences',UserEmail = User().Email).Favorites);
ForAll(existingfavlist, Collect(favslist, ThisRecord.Value));
Collect(favslist, {Value: ThisItem.ID});
Then just patch your collection 'favslist' to the list

MS-Access Automatically updating data based on another table (Email Blacklist)

I'm setting up a brand new database as a lot of the work we do is on multiple spreadsheets and a lot of the data is duplicated. I have a lot of knowledge with Excel, however, I feel that Access would much better suit the needs of the business and data management.
A large role for many in the business is to send emails/follow-up emails based on criteria, however, we use several services to do this and I need a new method of tracking people/businesses who have 'Opted-out' of email updates, we can export the people who opted out from the different applications and put into a spreadsheet.
I had a little play around with relationships to see if this would work, however, kept getting error along the lines of 'invalid for field type' and although I could do this with a simple countif function in Excel I was wondering if it's possible in Access without VBA.
One of the fields we have for our sponsors/delegates table is email address. I want to know if it is possible to create a new form & table or something to do the following:
User loads form, clicks a button and selects spreadsheet with emails in Column A
Data from column A is then imported into a blacklist table
Access removes duplicates and adds the rest to a blacklist table
Access updates sponsor/delegate table field 'opt-out' to yes for any email addresses added to the blacklist table
Edit: Here are 2 screenshots of the separate tables
What I need Access to do is basically tick the box 'opt-out' automatically for all records where the email matches to one in the blacklist
A query to update the opt-out field in your Sponsors table for all records which have a matching email address in the Blacklist table is relatively straightforward, with the matching operation performed by a single inner join, e.g.:
update Sponsors inner join Blacklist on Sponsors.[Email Address] = Blacklist.[Email Address]
set Sponsors.[Opt-Out] = -1

Table with variable number of rows in MS Office mail merge [duplicate]

I'm creating a compliance mailing for my organization, the mailing will include merge fields that identify the office location, physician, and SiteId. The mailing will also include a table of information that is dependent upon the particular SiteId.
I'd like to use the import table function of MS word and set up a query that references a merged field (SiteId) so that the inserted tables populate the appropriate data for the particular site. I'm unable to do this.
How can I set up this document so that I can import only records from my source (an ms access query) that match the SiteId merge field?
Word's mail merge does not support one-to-many relationships. There are ways to coerce it, but only one of them can yield a table as a result and over the years it has become less and less reliable as Microsoft has not regarded it as important enough to maintain...
What you need to do is set up a query that provides ONLY the information you want displayed in the table, plus the key (SiteId). It's best to sort it so that all the SiteId entries list together, and are in the order the data will come through in the mail merge data source.
On the Insert tab go to Text/Quick Parts/Insert Field and select the Database field from the list in the dialog box. Click "Insert Database" and follow the instructions in the dialog box to link in the data. Be sure to set the Query Options to filter on the first SiteId from the data source. When you "Insert Data" make sure to choose the option to "Insert as a field".
This inserts a DATABASE field in the document which you can see by toggling field codes (Alt+F9). The field code can be edited and what you need to do is substitute the literal SiteId value you entered for the query with its corresponding MergeField.
When you execute the merge to a new document that should generate a table for each data record corresponding to the SiteId for the record. But, as I said, Microsoft hasn't done a great job of maintaining this, so it may require quite a bit of tweaking and experimenting.
If the results are not satisfactory then you should give up the idea of mail merge and use automation code to generate and populate the documents.
You can find more (albeit somewhat out-dated) information on this topic at http://homepage.swissonline.ch/cindymeister/mergfaq1.htm

Infopath Form to submit data to two sharepoint lists

Novice in Sharepoint and looking for some advise.
we are trying to setup a infopath form with the below fields.
ReqID (Autogenerated with a workflow based on ID like Req-1 etc.),
Description,
User,
Date,
Testing,
Tester,
Date
when the user submits the form, we would like to save the information to two separate lists on sharepoint like...
List A - ReqID, Description, User, Date
List B - ReqID, Description, Testing, Tester, Date
Can someone please advise if this is doable without using any coding.
Thank you so much for all the help.
Several possible solutions:
One list:
If it is a matter of hiding clutter from selected users then: create one list for all of the fields and then create two views, one with your first set of columns and the other with the second set of columns. This has the advantage of no duplication of data, and if you need to update the Description column, it only has to be done in one place.
Two lists:
From the InfoPath form, post all of the fields to the first list and create a View that only displays what's needed for the "A" users. Create a workflow that adds a new item to list "B" with only the data needed.
Three lists:
From the InfoPath form, post all of the fields to a master list. Create a workflow that copies selected fields to List A and to List B. This has the advantage of the master list being an unchanged source of the original data for audit or tracking purposes.
Using Web Services
I believe InfoPath can call web services. This will be more like "coding", but you can write data directly to SharePoint lists using SharePoint's REST API.

Getting the greatest value for a field for all records

For our Employee records within NetSuite, we have a custom field called "Employee Number" with an ID of custentity1. I've created a workflow that will automatically create a new employee record and populate various fields but the one I'm having difficulty with is the Employee Number field. All I want to do is to grab the largest employee number there is out of all of the Employee records and add one to it for the new employee record.
The Employee Number field is a free-form text field so I know I'll have to use TO_NUMBER, but anytime I try and reference {custentity1} I keep getting an error saying that field is not found.
UPDATE: I've created a new custom field for our employee records called "Employee No." with an ID of custentity_employeenumber. I've also created a javascript file with the following:
function getMaxEmployeeNumber(){
var empNumber = nlobjSearchColumn('custentity_employeenumber', null, 'max');
return empNumber;
}
But how to do I get this to work with my records?
NetSuite does have an auto-numbering mechanism built in to its native functionality that most of our customers use for this exact purpose. Is there a special reason this functionality is not being leveraged? This functionality is accessible at Setup > Company > Auto-generated Numbers.
I do not work much with workflows, so I do not know if this same functionality is possible there, but here is how I would solve this in SuiteScript:
Create User Event script that is executed on Before Submit Create event for Customer records
Create a Customer search that has a Search Column for custentity1 with a summary type of max
new nlobjSearchColumn('custentity1', null, 'max');
Running this search should give you 1 result, which is the maximum customer number. You can then just add 1 to it.
You could create a similar Saved Search in the UI to see what the result set looks like.
This will only really work if the field is a Number, not Text. I would suggest changing the field to an Integer field if you know that it will always be a number. This may clear out existing data, so first you could export all customers and their number to Excel and then do a CSV import after changing the field.
How are you looking for the last employee in a workflow?
I know this can be done in js:
Search employees - returns max 1000
For number of employees give me the custentity1 of the last one - nlapiLookupfield('employee',employees[employees.length],'custentity1')
Add +1 and save on new record
If you use this search column
nlobjSearchColumn('custentity1', null, 'max');
You can also sort it in decreasing value so that the first result is always the max. Something like
nlobjSearchColumn('custentity1', null, 'max').setSort(true);

Resources