cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

CDS Entitiy - Auto Update MailNickname for created by and Modified By

Is it possible to pull down the MailNickname into two fields I created in an entity called, Created By and Modified By when someone creates a row or updates a row from an app? In my organization, MailNickname is the employee ID.

 

If not, is there a way for the app to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: CDS Entitiy - Auto Update MailNickname for created by and Modified By

The issue here is that you have the Get User Profile inside an Apply To Each action but the Update Record is outside. But you shouldn’t have an Apply to each.

To get the CDS User record you’ve used a List Records action and the results out of that make the Apply to each appear around your Get User Profile action. This is because the output of List Records is an array, even if there is only one value in the array. You should instead use the Get Record action to get the CDS User instead.

You will need to remove the Apply to each action and re-do the Get User Profile action.

Hope that makes sense

View solution in original post

5 REPLIES 5
Highlighted

Re: CDS Entitiy - Auto Update MailNickname for created by and Modified By

Hi @TesDA 

 

You could use a Power Automate Flow to do this.  Get the MailNickname using the Office 365 Users connector and populate the fields in CDS each time the records are created / updated in CDS.  However, you would need to build a Flow for each entity you have these fields on and the Flow would also run very often that you would have to watch your Flow run usage.  I would not recommend this approach.

 

An alternative would be to create a MailNickname field on the User entity in CDS.  Populate this as a manual one-off task (if there are not too many users), or using a Flow if you have a lot of users.  Then on each entity form where you have the OOTB Created By and Modified By fields place a quick view form of the User entity that has the MailNickname field displayed.  For Views you can also show the Created By and Modified By User's MailNickname.

 

Hope that helps.

 

-----

 

If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

Highlighted
Helper V
Helper V

Re: CDS Entitiy - Auto Update MailNickname for created by and Modified By

@HSheild 

Im trying to implement your flow workaround. For some reason its throwing an error on the Created By in CDS. Do you know how to convert the Created By in CDS to what it would be looking for as the ID in Office 365 Users - Get User Profile? I tried Created By Type as well but that didn't work.

 

FLow Image.jpg

Highlighted

Re: CDS Entitiy - Auto Update MailNickname for created by and Modified By

Hi @TesDA ,

 

The Get User Profile action is looking for the users UPN which is essentially the email address that they log into Office 365 with.

 

To get the UPN from Created By you need to first add a Flow action to get the CDS User record using Created By as the input ID.  Then, from the CDS User record, put the User Name field (which is the login email address) into the Get User Profile action.

 

-----
 
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

Highlighted
Helper V
Helper V

Re: CDS Entitiy - Auto Update MailNickname for created by and Modified By

@HSheild Im so close!!

 

Everything in the flow is working fine except the last item, update a record. Im getting the following error:

 
InvalidTemplate. Unable to process template language expressions in action 'Update_a_record' inputs at line '1' and column '2781': 'The template language expression 'body('Get_user_profile_(V2)')?['mailNickname']' cannot be evaluated because property 'mailNickname' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.
 
Any idea how to fix that one?
 
FLow Image.jpgFTO App.jpg
Highlighted

Re: CDS Entitiy - Auto Update MailNickname for created by and Modified By

The issue here is that you have the Get User Profile inside an Apply To Each action but the Update Record is outside. But you shouldn’t have an Apply to each.

To get the CDS User record you’ve used a List Records action and the results out of that make the Apply to each appear around your Get User Profile action. This is because the output of List Records is an array, even if there is only one value in the array. You should instead use the Get Record action to get the CDS User instead.

You will need to remove the Apply to each action and re-do the Get User Profile action.

Hope that makes sense

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (8,336)