Thursday, November 17, 2022

PowerAutomate : How to send email from someone else using Sharepoint REST API

In this post I will explain how to send email as someone else and the reply to those email goes to this "someone".

Business Scenario which we had to use this:

We build an app for our Organization and we want the email to come from the APP instead of the person who has logged into the App. We wanted to use PowerAutomate to send emails instead of sending email from PowerApps. The reason was PowerAutomate gives you the history of every execution which helps for auditing and troubleshooting. We could achieve this using the Mail connector "Send an mail from a Shared mailbox (V2)". But inorder to use this one, everyone who uses the app need to have access to the shared mailbox to send email using that. This was very hard to achieve without someone keep granting the access manually to any new employees who join the organization.

The approach we took is 

1. Create a shared mailbox

2. Make a REST API Call to sharepoint online to send the email from sharepoint as if it is from this newly created shared mailbox. This is achieved using the connector "Send an htttp request to SharePoint"

This is how it looks in Power Automate



 Method : POST  
 Uri    : _api/SP.Utilities.Utility.SendEmail  
 Body   : {  
    'properties':  
    {  
      'From' : 'noreply_ajapp@xxxx.com.au',  
      'To': ["aj@xxxx.com.au"],  
      'CC': [''],  
      'Subject': ' Test Email ',  
      'Body': '<html>Hi,<br><br>  
            This is a TEST email. <br>  
            Thank you  
            </html>'  
    }  
 }   


There are few things which you need to be aware of before using this

1. It only works if the sender(the person using the app) has access to the Sharepoint site.

2. It cannot send emails to external users

3. It only works if the To and CC addresses are there in the user table of the sharpoint site. The users has to either access the sharepoint once or added to the sharepoint directly (not through a group) to the sharepoint site.

Check the below link to see how to add a user directly to the sharepoint

PowerAutomate: Grant access to a user to sharepoint using PowerAutomate


4. The to and cc can be a comma separate email addresses enclosed in single quote or double quote.

The email will look like this


The display name will be what is set for the shared mailbox. If you look closely, you can see the email address will be "no-reply@sharepointonline.com". But if you try to do a reply, it will go to the sharemailbox you have created.


Reference :

Power Apps and Power Automate: Send emails from anyone






Feel free to point out if anything is wrong/missing in this post.

Wednesday, July 20, 2022

Powerapps : How to Set the Visible Property Dynamically

 This post is to show how to set the visible property dynamically

Set the Visible Property of the button to a Boolean variable as below 




Set the dynamic value using the UpdateContext.

UpdateContext({buttonVisible:!buttonVisible})

or use can use one of the below:

UpdateContext({buttonVisible:true})
UpdateContext({buttonVisible:false})



Reference: UpdateContext function in Power Apps




Feel free to point out if anything is wrong/missing in this post.



Powerapps : How to Set the Color of a Button/Label Dynamically

This post is to show how to change the color of a Text / Label / Button etc.. dynamically

We can set the text color by specifying the color in the color attribute, if we want to set the color with a static value.

ex:- 


But if you want to set the value dynamically, we can use a variable. But in this case we will have to use the ColorValue() function to achieve the expected result.

In the below example, on the button click, I am setting the dynamic variable to the value from the text box

Set(labelColor,TextInput1.Text)



Set the Color attribute on the label to 

ColorValue(labelColor)





Result



Reference: Color enumeration and ColorFade, ColorValue, and RGBA functions in Power Apps




Feel free to point out if anything is wrong/missing in this post.




Sunday, June 27, 2021

Power Apps: Searching and Sorting on Gallery with Choice column

This post is to show how to do the search and sort on a power apps gallery using a Choice Field.

In this example I am using  Microsoft/Sharepoint List as the data source. I have added one Choice Column into the list  'ChoiceCol', with the values as shown below.


Create a Power App using the default Integration.


Once the apps is created, to use the Choice column as the Search field and sort field, we need to modify the Items property of the Gallery.


The default value is as below. This will do the Search and Sort based on the Title field.
SortByColumns(Filter([@AJList]
                      ,StartsWith(Title, TextSearchBox1.Text)
                    )
              , "Title", If(SortDescending1, Descending, Ascending)
             )


To make the Search based on the Choice column, we can modify the value as below.

Change Title to ChoiceCol.Value

SortByColumns(Filter([@AJList]
                     ,StartsWith(ChoiceCol.Value, TextSearchBox1.Text)
                    )
              , "Title", If(SortDescending1, Descending, Ascending)
             )





To make the Sort based on the Choice column, we can modify the value as below. Basically add a new column to the table (using AddColumns) with a new name and the values from the Choice field and then specify the newly added column as the column for sorting.
SortByColumns(AddColumns(Filter([@AJList]
                                 , StartsWith(ChoiceCol.Value, TextSearchBox1.Text))
                         ,"SortChoiceCol",ChoiceCol.Value)
              ,"SortChoiceCol", If(SortDescending1, Descending, Ascending)
             )
I have added one more record to show that the Sorting is working based on the Choice Column.




Feel free to point out if anything is wrong/missing in this post.

Wednesday, September 16, 2020

Power Automate: How to create a Flow to Auto Approve Open Shifts in Microsoft Teams

My First Post on Microsoft Products!!!!

This post to give a step by step instructions on how to create a Flow to Auto Approve Open Shifts in Microsoft Teams.

This flow helps the Team Manager to automatically Approve Open Shifts in the team.

Since there is no triggers available in Shifts connector at the moment, we are using the Actions from Shifts connector and creating a scheduled flow.


Pre Req:

1. You need to create a Team in Microsoft Teams

2. Create a Schedule in Shifts App for the Team


Steps to Create the flow:

1. Open Power Automate in app or going to https://flow.microsoft.com

2. Click on My Flows --> New --> Scheduled -- from blank


3. Enter the details as below and click on Create.


4. Click on 'New Step'


5. Select  on 'List all Open Shift requests (preview)'


6. Enter Team name and Request State as 'Pending'


7. Add an 'Apply to Each' Control


8. Choose 'Open Shift Change Request' as the output


9. Add a Condition Control and select 'Open Shift Change Request Assigned To'

10. Enter the value as 'manager' and click on 'Add Action' in the Yes block.

11. Select 'Approve an Open Shift request (preview)'


12. Enter the Team Name and select 'Open Shift Change Request ID'


13. The final flow looks like below. Save the flow



Now your flow is ready for testing. Enjoy :)



Reference :


Feel free to point out if anything is wrong/missing in this post

PowerAutomate : How to send email from someone else using Sharepoint REST API

In this post I will explain how to send email as someone else and the reply to those email goes to this "someone". Business Scenar...