Saturday, July 24, 2021

Call Power Automate From Power Apps Portal

 In this blog , we are going to see how to call power automate from power apps portal.


1. Create Webtemplate to show the existing account information

2. Create Page Template ->Select created web template

3. Create Web page.

4. PowerAutomate to update the changed account in portal.


{% fetchxml acc %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="account">
<attribute name="name" />
<attribute name="primarycontactid" />
<attribute name="telephone1" />
<attribute name="accountid" />
<attribute name="address1_composite" />
<order attribute="name" descending="false" />
</entity>
</fetch>
{% endfetchxml %}
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 80%;
}

td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}

tr:nth-child(even) {
background-color: #dddddd;
}
</style>
<table class="center">
<tr style="background-color:#616A6B ">
<th style="color:white">Account Name</th>
<th style="color:white">Main Phone</th>
<th style="color:white">Address</th>
<th style="color:white">Primary Contact</th>
<th style="color:white">CRM Status</th>
<th style="color:white">Action</th>
</tr>
<body>
{% assign crmstatus = 0 %}
{% for ac in acc.results.entities %}
{% assign crmstatus = crmstatus | plus: 1 %}
<tr>
<td><input type="text" id="{{ac.accountid}}" value="{{ac.name}}"/></td>
<td><input type="text" readonly id="ACCID{{ac.accoundid}}" value="{{ac.telephone1}}"></td>
<td><input type="text" id="AddID{{ac.accoundid}}" value="{{ac.address1_composite}}"></td>
<td><input type="text" readonly id="ID{{ac.accoundid}}" value="{{ac.primarycontactid.Name}}"></td>
<td><span id="{{crmstatus}}" value="crmstatus" style="color:green"></span></td>
<td><button id="{{ac.accountid}}" onclick="updaterecord('{{ac.accountid}}','{{crmstatus}}')" type="button">Update</button></td>
</tr>
{%endfor %}
</body>
</table>
{% raw %}
<script type="text/javascript" language="javascript">
function updaterecord(id , status){
//document.getElementById(id).value = "updating.."
document.getElementById(status).textContent="updating..";
var acupdate ='{ "accountid": "'+id+'" , "name": "'+document.getElementById(id).value.trim()+'"}';
var req = new XMLHttpRequest();
var url ="https://prod-149.westus.logic.azure.com:443/workflows/814110a076614ca1be8b1b3e2f9df1a2/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=ToeEUUGg5s6M5Pq8re5hPGxgwTydIDgP7vzS0MAfefU";
req.open("POST" , url , true);
req.setRequestHeader('Content-Type', 'application/json');
req.onreadystatechange = function() {
if (this.readyState === 4){
req.onreadystatechange = null;
if(this.status === 200){
var results = this.response;
//document.getElementById(id).value = results;
document.getElementById(status).textContent=results;
}
}
};
req.send(acupdate);
}
</script>

{% endraw %}


Power Automate:

1. Choose When http request received
2. Give below sample load request

{
"accountid":"1234",
"name":"myaccount"
}

3. Choose Update row of dataverse
4. Add Http response , give status 200 and body value as "updated !"





















Create Simple Web Site in Powerapps portal

 In this blog , we will see how to create the simple web site using powerapps portal.


1. Choose Portal Management app after login CRM application.

2. Create new web page

3. Open local content web page

4. Paste Below HTML code.

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
body {margin: 0;}
.header {
padding: 10px;
text-align: center;
background: #5D6D7E; // #aed6f1;
color: white;
}
.navbar {
overflow: hidden;
background-color: dimgrey;
}
.navbar a {
float: left;
display: block;
color: white;
text-align: center;
padding: 10px 10px;
}
.navbar a.right {
float: right;
}
.navbar a:hover{
background-color: #eee;
color: black;
}
.row {
display: flex;
flex-wrap: wrap;
}
.sidebar {
flex: 10%;
background-color: #f1f1f1;
padding: 20px;
}
.main {
flex: 80%;
background-color: white;
padding: 20px;
}
.logoimg {
height:10%;
float:left;
}
</style><div class="header">
<div class="logoimg" style=""></div>
<h1>Welcome to Portal Demo</h1>
</div>
<div class="navbar">
<ul class="nav navbar-nav weblinks" role="menubar">
<li class="weblink " role="none"></li>
<li aria-hidden="true" class="divider-vertical"></li>
<li class="weblink " role="none"><a aria-label="Knowledge Base" href="/knowledgebase/" role="menuitem" title="Knowledge Base">Knowledge Base </a>
</li>
<li aria-hidden="true" class="divider-vertical"></li>
<li class="weblink " role="none"><a aria-label="Forums" href="/forums/" role="menuitem" title="Forums">Forums </a>
</li>
<li aria-hidden="true" class="divider-vertical"></li>
<li class="weblink " role="none"><a aria-label="My Support" href="/support/" rel="nofollow" role="menuitem" title="My Support">My Request</a>
</li>
  <li aria-hidden="true" class="divider-vertical"></li>
<li class="weblink " role="none"><a aria-label="My Support" href="/address/" rel="nofollow" role="menuitem" title="My Support">Service Request</a>
</li>
</ul>
</div>
<div class="row">
<div class="sidebar">
<h3>Register Now</h3>
<div><img src="/demopage/download.jpg" style="width: 180px; height: 100px;"></div>
<h3>Reviews</h3>

<marquee direction="up" scrolldelay="150" color="Green">
  Good site for learning data science
  Developed site very well
  .online training are very good</marquee>
</div>
<div class="main">
<h2>About Training Courses</h2>
<p>Choose your interest area and get certified with our online Courses in Finance, Data Science, Software Development, Excel, Design, Project Management, Personal Development, Marketing and Human Resources..</p>
<br>
<div class="row">
<div class="sidebar">
<h2><u>Certification Courses</u></h2>
<a href="https://www.educba.com/finance/">Financial Analyst Course - All in One Bundle</a><br>
<a href="https://www.educba.com/marketing/">Marketing Course - All in One Bundle</a><br>
<a href="https://www.educba.com/human-resource/">Human Resource Course - All in One Bundle</a><br>
<a href="https://www.educba.com/design/">Design Course -All in one Bundle</a> <br>
<a href="https://www.educba.com/excel/">Excel VBA Course - All in One Bundle</a>
</div>
<div class="sidebar">
<h2><u>Free Courses</u></h2>
<a href="https://www.educba.com/data-science/courses/free-data-science-course/">Free Course on Data Science</a><br>
<a href="https://www.educba.com/design/courses/free-graphic-design-online-course/">Free Course Graphic Design</a><br>
<a href="https://www.educba.com/excel/courses/free-online-excel-course/">Free Online Excel Course</a><br>
<a href="https://www.educba.com/marketing/courses/free-digital-marketing-course/">Free Course Digital Marketing</a><br>
<a href="https://www.educba.com/software-development/courses/free-programming-course/">Free Course Programming</a>
</div></div></div></div>