cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rohitjadhav123
Advocate II
Advocate II

How to pass 'user profile v2 O365' data to Power Virtual agent?

Hello,

 

I am trying to see how can I access all the data mentioned here from 'get user profile v2' to my Power virtual agents.  Issue is my app 'apply for each' block, and I loop over each user and call 'get user profile v2' on it. Then I am not sure how to consolidate the data into single object or array or HTML table or CSV and then pass it as single object to PVA.

Please help.

 

 

Screen Shot 2020-02-27 at 8.51.25 PM.pngScreen Shot 2020-02-27 at 8.51.38 PM.pngScreen Shot 2020-02-27 at 8.31.28 PM.png

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi  rohitjadhav123 ,

OK, Let's go to convert O365 API response to String as follows, e.g. DisplayName - Mail - ID.

Test4 - Test4@domain.com - dbbbadce-6553-****-9ea5-d62a98dc8bec
Test3 - Test3@domain.com - daf3bbc5-739c-****-b7fa-50f51f1b4664
Test2 - Test2@domain.com - 1aae6224-506c-****-8f0e-afdcde38ccda

 

1. Add "Initialize variable" action before Search for Users action,  Name set to OriginalArray, Type set to Array

2. Then add another "Initialize variable 2" action, Name set to FinalString, Type set to String Snipaste_2020-03-02_11-11-33.png

3. Within "Apply to each" action, add a “Compose” action after "Get user profile (V2)" action, Inputs set to the following formula: concat(body('Get_user_profile_(V2)')?['displayName'],' - ',body('Get_user_profile_(V2)')?['mail'],' - ',body('Get_user_profile_(V2)')?['id'])4. Add a “Compose 2” action, type Output dynamic content of “Compose” action in the first line, then type variable FinalString in the second line (type “Enter” key in your keyboard).

5. Add a “Set variable” action, Name choose FinalString and Value set to output of “Compose 2” action

6. Under "Apply to each" action, add "Compose 3" action, set Input to Variable FinalString.

6. Within "Return value(s) to Power Virtual Agents" action, add Text output, set Input to Outputs of "Compose3".Snipaste_2020-03-02_11-10-47.png

 Test Result:

Snipaste_2020-03-02_11-15-15.png

Sik

 

View solution in original post

5 REPLIES 5
v-siky-msft
Community Support
Community Support

Hi @rohitjadhav123 ,

 

From the following article, we can know that it is only supported to pass Number/String/Boolean type data to Power Virtual agent, 

Reference: https://docs.microsoft.com/en-us/power-virtual-agents/advanced-flow#input-and-output-parameters 

So currently, it is not supported to consolidate all fields to an object and pass it to Power Virtual agent.

Snipaste_2020-02-28_13-55-53.png

If you want this feature, please submit an idea to PowerApps Ideas Forum.

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas 

Sik

Hi @v-siky-msft , It was more of a how to do in flow question and, not a feature request. If PVA can accept string there must be way to convert O365 API response to String, and pass it to next action which 'Send data to PVA'

 

My question was How do that I do ?

v-siky-msft
Community Support
Community Support

Hi  rohitjadhav123 ,

OK, Let's go to convert O365 API response to String as follows, e.g. DisplayName - Mail - ID.

Test4 - Test4@domain.com - dbbbadce-6553-****-9ea5-d62a98dc8bec
Test3 - Test3@domain.com - daf3bbc5-739c-****-b7fa-50f51f1b4664
Test2 - Test2@domain.com - 1aae6224-506c-****-8f0e-afdcde38ccda

 

1. Add "Initialize variable" action before Search for Users action,  Name set to OriginalArray, Type set to Array

2. Then add another "Initialize variable 2" action, Name set to FinalString, Type set to String Snipaste_2020-03-02_11-11-33.png

3. Within "Apply to each" action, add a “Compose” action after "Get user profile (V2)" action, Inputs set to the following formula: concat(body('Get_user_profile_(V2)')?['displayName'],' - ',body('Get_user_profile_(V2)')?['mail'],' - ',body('Get_user_profile_(V2)')?['id'])4. Add a “Compose 2” action, type Output dynamic content of “Compose” action in the first line, then type variable FinalString in the second line (type “Enter” key in your keyboard).

5. Add a “Set variable” action, Name choose FinalString and Value set to output of “Compose 2” action

6. Under "Apply to each" action, add "Compose 3" action, set Input to Variable FinalString.

6. Within "Return value(s) to Power Virtual Agents" action, add Text output, set Input to Outputs of "Compose3".Snipaste_2020-03-02_11-10-47.png

 Test Result:

Snipaste_2020-03-02_11-15-15.png

Sik

 

View solution in original post

Thanks. I am having 2 more issues after following your advice. 

1. I am not trying to select more fields on step 3. My concat looks like follows but it does print jobTitle,department, and country

concat(body('Get_user_profile_(V2)')?['displayName'],' - ',body('Get_user_profile_(V2)')?['mail'],' - ',body('Get_user_profile_(V2)')?['hireDate'],' - ',body('Get_user_profile_(V2)')?['jobTitle'],' - ',body('Get_user_profile_(V2)')?['department'],' - ',body('Get_user_profile_(V2)')?['country'],' - ',body('Get_user_profile_(V2)')?['birthday'])

 

How can I choose all the output values  available in action 'Get user Profile v2'


2.  I didnt understand the use of step 4 you mentioned where I need to append empty string ''FinalString at the end.

4. Add a “Compose 2” action, type Output dynamic content of “Compose” action in the first line, then type variable FinalString in the second line (type “Enter” key in your keyboard).

 

Hi @rohitjadhav123 

To your first question, If you want to print all fields to a string, the only way is to use Concat function. I just made a test with your expression, it works well.

Test4 - Test4@damain.com - 0001-01-01T00:00:00Z - department manager - Saledepartment - DE - 0001-01-01T00:00:00Z
Test3 - Test3@damain.com - 0001-01-01T00:00:00Z - Power BI Director -  -  - 0001-01-01T00:00:00Z
Test2 - Test2@damain.com - 0001-01-01T00:00:00Z - Reporter Engineer -  -  - 0001-01-01T00:00:00Z

Could you share some screenshots about the issue in Test result?

If some fields are not assigned, they will return a blank, please check if the users have been assigned all fields.

 

To your second question, this is to arrange the output of all users in rows. Since "Compose2" is within "Apply to each" action, the 'FinalString' will return the value of the last loop, and be appended at the end.

 

Hope this helps.

Sik

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (55,265)