PowerApps set global variable - sharepoint

I'm having an issue with a global Variable in MS PowerApps.
I built an App and now want to have two groups of people. Admins(who can do everything) and normal Users(who can read every post and edit theire own ones but not everything of it).
Therefor I made up a Sharepoint list(cause the posts are stored in a Sharepoint list aswell) to save the users name that are Admins. All other users are standard users.
Set(
Admin,If(
IsEmpty(
Filter(
'Prototype App Admin',Username=User().FullName
)
), false, true
)
);
OnStart of the App I initialize the variable Admin on true if the Users name is included in the list(it does not give me any error here).
If(
User().FullName=ThisItem.'Author', true, false
) ||
If(
Admin=true, true, false
)
(I put in this code in the visibility field of my gallery where the posts are shown of)
Now I check if the User, who is using the App right know is the author of the post or if it is an admin who is watching.
The column Author includes the FullName of the Author.
PowerApps gives me a "Name isn't valid" back but I also have imported the Sharpoint list. I don't get any Error massage on the Admin-function but I also can't see the posts.
Can you tell me what I'm doing wrong?

If someone has the same issue, I've solved mine.
You just have to work in the "Items" field of your gallery and combine the two tasks within a SortByColumns statement.
SortByColumns(
Filter(
'Prototype App',If(
Admin=true,true,User().FullName=Author
)
),"Author"
)

Related

AzureAD Graph API - Getting the delta of users in a group

We are using the MS Graph API and would like to check the changes of users in a certain group. Currently we get the users via this query:
https://graph.microsoft.com/v1.0/groups/group-id/members
This is how we retrieved the delta of the group:
https://graph.microsoft.com/v1.0/groups/delta?$filter=id eq 'GroupId'&$select=members
Now my question would be if there is a way to relate this delta only to users in this group.
I can see a result when I add or delete a user from the group, but I need a result, even if the name, street or something else getting changed.
I would be very grateful for any feedback.
Kind regards
There are limited supported-resources to query delta , which includes groups, Users etc but not particularly for member and its properties of one such group.
I tried to query for members this way and got unsupported error
https://graph.microsoft.com/v1.0/groups/xxxxxxxx/members/delta?$select=displayName,jobTitle,mobilePhone
But you may retrieve members of all groups whose membership changes, such as when users are added or removed /( updated ) as you knew .
I’ve tried this way with prefer: return=minimal 'header' to return only the object properties that have changed since the last round. and got removed and updated users but their properties that changed are not listed .We may need to copy the user Id that changed and query for that using user-delta
https://graph.microsoft.com/beta/groups/delta?$filter=id+eq+'xxxx-xxxxa-xxxxx52eb'&$select=members+&$select=displayName
(or)
https://graph.microsoft.com/beta/groups/delta?$filter=id+eq+'xxxx2-xxxxxxxxeb'&$expand=members
To filter separately for other properties like jobTitle ,its not valid .
https://graph.microsoft.com/beta/groups/delta?$filter=id+eq+'xxxxxxxxxxxx2-xxx'&$expand=members+&$select=displayName,jobTitle,mobilePhone
You can raise a Support request for the same.
References :
delta-query-groups | Microsoft Docssupported-resources
microsoft-graph-issues

Using Graph API to query SharePoint list items and expand user field

I'm trying to query for some SP list items, all is working fine except I can't seem to expand a custom column of type Person.
I can see the createdBy and lastModifiedBy expanded and even includes the AAD user id, which is great and also leads me to think what I want is possible!
But mine is a custom column.
I'm running this and can only seem to get the SP user list id and the user's display name...neither of which are much use.
/items?expand=fields(select=UserLookupId,User)
Ideally I'd like to get the AAD user id as per createdBy and modifiedBy field, but the email would suffice.
Otherwise the only way I can see is to query the User Information List (using the UserLookupId) to get the email?
Thanks
This appears to be correct assumption:
Otherwise the only way I can see is to query the User Information List
(using the UserLookupId) to get the email?
for non-system user fields, it is indeed a way to go, but there are some distinctions whether user field is multi-valued or single-valued.
If Approvers is a multi-valued user field, then the following query:
https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields($select=Approvers)
returns email and id properties along with displayName property for user field value.
While for single-valued user field only id (available via {userfield}LookupId property) and displayName properties could be requested via items endpoint, for example:
https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields($select=Approver,ApproverLookupId)
So, indeed User Information List needs to be utilized to request additional user properties, for example:
https://graph.microsoft.com/v1.0/sites/root/lists('User Information List')/items/{item-id}/?$expand=fields($select=Email)
where item-id corresponds to user field lookup id
This was my experience modifying the
Build Angular single-page apps with Microsoft Graph. In the examples below, I changed my id's out with the default text.
Here is
The Finished Project on thier github
In Graph Explorer, this worked. You can verify it at the Microsoft Graph Explorer.
https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?expand=fields($select=id,Title)
In the app/graph.service.ts in the app, this did not work. Even though you would expect it to based on the graph explorer.
.api('/sites/{site-id}/lists/{list-id}/items?fields($select=id,Title)')
Changing the app/graph.service.ts api call worked.
.api('/sites/{site-id}/lists/{list-id}/items?')
.expand('fields($select=id,Title)')
The result looked like this:
fields: {
#odata.etag: ""d6f5b6ea-9f90-452d-98ba-e838f58d3359,1"",
Title: "IT SPECIALIST (MID)",
id: "20"
}
Here's an example site id:
some.sharepoint.com,9dk062b-2e54-4e4f-b71a-cdb74f42cc44,c6cf6b0a-cc7c-41fd-a76a-ef8f97e8a22f
Here's an example list id.
8eg8c29a-5555-4cfc-bfa4-0e907488f781
The end url won't have any {} in it.

MS PowerApps Deep Linking

I'm passing a parameter to a PowerApp through the calling URL called ID, i.e.
https://web.powerapps.com/apps/powerappid?ID=32
When the app launches I want it to jump from BrowseScreen1 which lists all the Business Cases and go straight to the Business Case with the matching ID (a field from a SharePoint list).
I'm brand new to PowerApps but pretty sure what I need to do is called Deep Linking and I found this tutorial https://powerapps.microsoft.com/en-us/blog/powerapps-deep-linking/ and having read the comments to the article I'm trying to apply it to the OnStart property of BrowseScreen1. I don't really understand how the navigation link in the tutorial is constructed so I'm sure I'm using the wrong Navigation parameters as it always launches the first record in the list ignoring anything to do with the ID. I'm using:
If(Not(IsBlank(Param("ID"))),Navigate(DetailScreen1,
None,{ID:LookUp('Full Business Case For Review'.ID, ID =
Value(Param("ID")))}))
'Full Business Case For Review' is the name of the Sharepoint list and ID is a unique field that gets assigned to each list item.
The tutorial doesn't mention having to change anything on the detail screen but I've also wondered if I need to perhaps change the item properties there as they are currently:
BrowseGallery1.Selected
I'm feeling out of my depth and would really appreciate some help on this!
Thanks,
John
Yes, you need to change the Item property in the detail screen. This is because there is currently no way to select an item in a gallery programmatically in PowerApps.
I normally get around this by using a global variable to store the current item, so you can set BrowseSreen1.OnStart to this
If(Not(IsBlank(Param("ID"))),
Set(CurrentItem, LookUp('Full Business Case For Review'.ID, ID = Value(Param("ID"))));
Navigate(DetailScreen1, None)
)
This will store the item with ID equal to your parameter as a record type variable.
You also need to change the OnSelect property of your BrowseGallery1's template or whichever control is used to navigate to the detail screen. It will need to be something like this
Set(CurrentItem, ThisItem); Navigate(DetailScreen1, None)
Finally set the Item property in the detail screen simply to this
CurrentItem

Sharepoint List Filter by Profile Property

How would you filter a list in Sharepoint (WSS 3.0) by a current user's profile property. For example, I have a list with a Department column and I want to filter the list based on the current user's department (which would be a user profile's property).
Any idea's on how to do this?
I believe this is a repeated question filter a sharepoint list.
Anyway here you have mijn twee centen.
Try adding a tasks web part in your page and add a column "Department" to this tasks web part and enter some value, say 'IT'. Then add a UserContextFilter web part to same page. Configure it so that it sends "Department" user profile value to Tasks web part. At this point, when you try to connect usercontextfilter wp to tasks wp, you won't be able to see "Department" in drop down list. Beacuse this drop down list values are populated based on of tasks web part.
What you'll need to do is first get the user's profile, look up the property, and then use that in your CAML, like so:
UserProfile userProfile = ProfileLoader.GetProfileLoader().GetUserProfile();
string dept = userProfile["department"];
// SPQuery CAML stuff here

does sharepoint have itemwise permissions , just like it has list wise permissions

( Regarding Moss 2007 )
i have created a sharepoint list in which one column is called user assigned - this is a lookup column of type - people and group.
i select the users from active directory to enter this field of the list.
So different items in this list have different users assigned
I have create permissions for this list to be read and write to the users in active directory .
so that when a particular user logs in to the sharepoint website with his credentials. he has read and write access to the list.
Now is there any way available in sharepoint by which the user do not see the whole list when they login to the website . He only sees the items of the list which the user assigned field is him only.
If the permissions are indeed setup right, you only have to go to List Settings, Advanced Settings, Item-Level Permissions and on "Read access: Specify which items users can read" you define their own.
If the users are not the creators of the items, you need to go to List Settings, Views (at the far bottom), modify the All Items View (or w/e you have as default), go to the filter section and add a filter like: "Show items only when the following is true", "Show the items when column" Assigned To is equal to [me]
I've been implementing such solutions for some while. It is possible, but
it takes much work to be done
if used in long term and/or the amount of data is large, this will hit performance
If none of these is a problem for you, then you can:
create code which performs BreakRoleInheritance() on the item, then adds ViewListitems permission for the user in "user assigned" column. You can find example code, for instance, here: http://social.msdn.microsoft.com/Forums/en/sharepointecm/thread/581e456c-db3c-44f1-b958-a824d95a2536 (or search in Google for "SPPrincipal" and "SPRoleAssignment" for more info)
make this code be called whenever the item is added or updated (you have to wait for the "-ed" events, because in the synchronous version of these events you can't change the permissions yet, for instance in "ItemAdding" there is no item created yet). You can achieve this by adding an event handler to the list.

Resources