Power automate - JackHu88/Comm GitHub Wiki

Call SharePoint Office 365 REST API

https://www.sharepointpals.com/post/step-by-step-procedure-to-call-sharepoint-office-365-rest-api-from-microsoft-flow/

Calling Microsoft Flow from your application

https://flow.microsoft.com/fr-fr/blog/call-flow-restapi/

Send multiple attachments on a single email

https://flow.microsoft.com/en-us/blog/multiple-attachments-single-email/

Clear multi user fields in SharePoint Online

https://sharepains.com/2019/08/21/clear-a-multi-user-field-in-sharepoint-using-microsoft-flow-with-the-rest-api/

Using Rest API in PowerApps

https://powerapps.microsoft.com/en-us/blog/using-azure-functions-in-powerapps/

The remote server returned an error: (503) Server Unavailable.

https://sharepoint.stackexchange.com/questions/146499/sharepoint-2013-online-adding-a-user-to-a-group-using-a-workflow

https://xxx.sharepoint.com/_api/web/sitegroups/getbyname('Anti-Fake Dev Approver')/users

https://xxx.sharepoint.com/_api/web/lists/GetByTitle('Market Sweeps')/items?$filter=Step_x0020_Due_x0020_Date eq '2017-04-20'

$filter= (Start_Date ge datetime'2016-04-02T07:00:00.000Z') and (End__Date le datetime'2016-04-03T03:30:00.000Z')

http://www.ashokraja.me/articles/How-to-view-output-from-SharePoint-2013-REST-API-as-JSON-instead-of-Atom-XML

https://flow.microsoft.com/zh-cn https://flow.microsoft.com/zh-cn/guided-learning/learning-introducing-flow/ https://flow.microsoft.com/zh-cn/documentation/getting-started/

http://www.infoq.com/cn/news/2016/06/Microsoft-Cloud-Workflow

https://flow.microsoft.com/zh-cn/documentation/prevent-data-loss/

Basic Windows

If(
    IsEmpty('BSO List'), 
If(SearchInput.Text ="", 
Filter('Channel Partner', gtDocStatus=Dropdown1.Selected.Value And AppAuthorID=UserPin),
SortByColumns(
Filter('Channel Partner', StartsWith(gtDocSerialNo,SearchInput.Text) Or StartsWith(ContractNo,SearchInput.Text)),
     "gtSubmitDate",Ascending)),
If(SearchInput.Text ="", 
Filter('Channel Partner', gtDocStatus=Dropdown1.Selected.Value),
SortByColumns(
Filter('Channel Partner', StartsWith(gtDocSerialNo,SearchInput.Text) Or StartsWith(ContractNo,SearchInput.Text)), 
"gtSubmitDate",Ascending)))

MS Flow update "multiple people or group" field 

https://powerusers.microsoft.com/t5/Building-Flows/Flow-cannot-update-quot-multiple-people-or-group-quot-field/td-p/132466

  1. Initiate a variable of type "Array". Ex. 'arrEmails'
  2. Use Action 'Resolve Person'  I noticed a value, "SharePoint expanded user field".  Appending this value directly into an array simplified the whole Flow; 
  3. Now go to your action where you want Add/update Multiple User Field.
  4. Click on the the icon near the Text box(Your User Field) 'Switch to input entire array'. Once done you will see a multiline textbox for adding array.
  5. Add Array Variable to that input box.

Microsoft Flow Trigger Conditions

https://siddharthvaghasia.com/2019/08/06/trigger-ms-flow-on-condition-based-on-columns-value-with-sharepoint-list/

@equals(triggerBody()?['Business_x0020_Unit']?['Value'], 'Indiana')

Trigger A Microsoft Flow With A Button Click On SharePoint Online

https://www.c-sharpcorner.com/article/trigger-a-microsoft-flow-with-a-button-click-on-sharepoint-online/

$(document).ready(function () {  
    ExecuteOrDelayUntilScriptLoaded(AttachClickEventToButton, 'SP.js');  
});  
  
### This method attaches click event to input button.  
function AttachClickEventToButton() {  
    try {  
        $("#btnTriggerMicrosoftFlow").click(function () {  
            StartMicrosoftFlowTriggerOperations();  
        });  
    }  
    catch (e) {  
        console.log("Error occurred in AttachClickEventToButton " + e.message);  
    }  
}  
  
### This method triggers the microsoft flow  
function StartMicrosoftFlowTriggerOperations() {  
    try {  
        var dataTemplate = "{\r\n    \"emailaddress\":\"{0}\",\r\n    \"emailSubject\": \"{1}\",\r\n    \"emailBody\": \"{2}\"\r\n}";  
        var httpPostUrl = "<Supply with the HTTP POST Url>";  
        //Call FormatRow function and replace with the values supplied in input controls.  
        dataTemplate = dataTemplate.FormatRow($("#txtEmailAddress").val(), $("#txtEmailSubject").val(), $("#txtEmailBody").val());  
  
        var settings = {  
            "async": true,  
            "crossDomain": true,  
            "url": httpPostUrl,  
            "method": "POST",  
            "headers": {  
                "content-type": "application/json",  
                "cache-control": "no-cache"  
            },  
            "processData": false,  
            "data": dataTemplate  
        }  
  
        $.ajax(settings).done(function (response) {  
            console.log("Successfully triggered the Microsoft Flow. ");  
        });  
    }  
    catch (e) {  
        console.log("Error occurred in StartMicrosoftFlowTriggerOperations " + e.message);  
    }  
}  
  
### This method formats the rowTemplate by replacing the placeholders based on the arguments passed.  
String.prototype.FormatRow = function () {  
    try {  
        var content = this;  
        for (var i = 0; i < arguments.length; i++) {  
            var replacement = '{' + i + '}';  
            content = content.replace(replacement, arguments[i]);  
        }  
        return content;  
    }  
    catch (e) {  
        console.log("Error occurred in FormatRow " + e.message);  
    }  
}  

https://docs.microsoft.com/en-us/power-automate/

Send multiple attachments on a single email

https://flow.microsoft.com/en-us/blog/multiple-attachments-single-email/

Update fields

//use variables in expression
variables('DelegateSecurityLeader')

//get field
first(body('Get_items')?['value'])?['ID']

//Get multiple user field
first(first(body('Get_FYI')?['value'])?['Users'])?['Claims']

//get user claims
first(body('Get_items')?['value'])?[Claims']

//update user field in in item property
"Site_x0020_Manager": {
    "Claims": if(empty(variables('SiteManager')),null,variables('SiteManager'))
}
  
//update choice field in item property
{
  "WF_x0020_Status": {
    "Value": "Released"
  }
}

//update user claims
SiteManager
if(empty(variables('SiteManager')),null,variables('SiteManager'))

//update mutiple user field
Owners
concat(';','[email protected]',';','[email protected]')

//clear user field
single-valued user field: ‘<user field name>Id’ : -1
multi-valued user field: ‘<user field name>Id’ : { ‘results’: [0] }

Send http requst to sharepoint
{
"__metadata": {
"type": "SP.Data.COEAuditListItem"
},
"CurrentOwnerId": "-1"
}
https://jobs.collab365.community/how-to-update-the-sharepoint-people-picker-field-using-power-automate/?__cf_chl_captcha_tk__=8be9109fb76120cfcc86eca70e8278a8fc64da4f-1610688783-0-AYyGX7jrbiWKYMAA4P70X2bxFledvPpWXhW0ffi2zq9PK-kJNZHfUSUkU-xqlrrymeTdk5sPsELBmaDNDj5p24_ssemIbZbNV7N79RPANndxcy64e-fHS4_EkCTjNC_JeV_p_Hs4IF9uoEv76JrLtk5mH7f_jMEWfx847XaLRTHADUQ0YLhG3v7bh3SOv7dJvyeuTg4ZBjhgkh4CLBqcWoChhfvSSpQ9nyVruADXgJuGDgeBlFQ89XDteL1dUgb3MqhVVOMjEtoTo1N9edS0hK_aTr-j8AswblSGT8eYCofPI5qBaagA3MAQQdDQQNEsegEWZnZG6wsLH4hcGZ1R_msMNIGR16mPx5Dy4Y3SlGe3dfBiFRrgzpCzV_9cncLev8uep94_jLQd5STlUN23-jOK3viV58RaNCjYxD_tsle7D59D_vbya4RkfoGi3Syiuzlf41a1dbP83Xm5cEE1YFWtNDf0o5bNZ5OLnBpLaaTQZ-eChoYNd-lcA7PyJ6RkoJ7OofKnqZsYpg9xjpPJn9UlWdS9AxxJgEXAFkIWFf19PuVPYEwx3Fucic2DqtwTeVPCHx1XAZuDAY4HN647s2hpz25nlRXhsYe6d1nAa_rH

update mutiple user field

https://spknowledge.com/2020/10/04/power-automate-how-to-update-single-or-multiperson-field-in-sharepoint/

check field is empty

https://tomriha.com/what-value-to-use-in-condition-if-field-is-empty-in-power-automate/

Replace Newline in Flow Expression

uriComponentToString(replace(uriComponent(triggerOutputs()?['body/Description']), '%0A', '<br>'))

https://powerusers.microsoft.com/t5/Building-Flows/Replace-Newline-in-Flow-Expression/td-p/57333

Generate MS Word

https://www.c-sharpcorner.com/article/generate-ms-word-document-consuming-sharepoint-list-data-from-a-document-templat/

Stop & Set permission

https://www.c-sharpcorner.com/article/power-automate-break-inheritance-and-set-list-item-level-permissions-in-sharep/

https://www.c-sharpcorner.com/article/set-sharepoint-list-item-permission-using-ms-flow/

_api/web/lists/getbytitle('<List Name>')/items(<List Item ID>)/roleassignments/addroleassignment(principalid='<Group/User’s Principle ID>',roleDefId=<Role Definition ID>) 

How to get Role Definition ID

https://www.c-sharpcorner.com/article/get-sharepoint-role-definition-ids/  Role Definition Name  Role Definition Id  Full Control  1073741829  Design  1073741828  Edit  1073741830  Contribute  1073741827  Read  1073741826  Limited Access  1073741825  View Only  1073741924

https://www.portiva.nl/portiblog/2019/10/21/set-list-item-level-permissions-in-sharepoint-using-flow

https://blog.binarybits.net/item-level-permission-in-sharepoint-using-rest-and-power-automate/

⚠️ **GitHub.com Fallback** ⚠️