Sunday, January 2, 2022

Call liquid template in Basic Form Portal

 In this post, we are going to see how to call liquid template code in basic form field change.

On select of lookup, retrieve lookup value in Basic form.

Follow below steps 

1. Create web template and write below liquid template

2. Create page template and refer created web template

3. Create web page and refer created page template

4. Jquery to call liquid template


1. Create web template name "GetContactEmailAddress" and  add below liquid template code in source box.


{% fetchxml getcontact %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="contact">
<attribute name="fullname" />
<attribute name="telephone1" />
<attribute name="contactid" />
<attribute name="emailaddress1" />
<attribute name="wbab_vpu" />
<order attribute="fullname" descending="false" />
<filter type="and">
<condition attribute="contactid" operator="eq" value="{{request.params['contactid']}}" />
</filter>
</entity>
</fetch>
{% endfetchxml %}

{% if getcontact.results.entities.size > 0 %}
{
"results":
[
{% for contact in getcontact.results.entities %}
{
"emailaddress": "{{contact.emailaddress1}}",
"vpu": "{{contact.wbab_vpu}}"
}
{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
{% else %}
No data found.
{% endif %}

2. Create page template and refer created web template.
3. Create webpage and refer created page template name.
4. Below jquery to call liquid template of change of lookup field.

$("#test_cc").bind('change', function () { // debugger; contactclick++; $("#test_cc_name").val(""); if (contactclick > 4) { alert("Maximum Four CC allowed"); contactclick--; return; } var contactid = $("#test_cc").val(); getContactEmail(contactid); }); $("body").on("click", ".remove", function () { $(this).closest("div").remove(); contactclick--; var values = ""; $("#note").show(); $("input[name=DynamicTextBox]").each(function () { values += $(this).val() + ";"; }); $("#test_ccemailaddress").val(values); // alert(values); //alert(contactclick); });


function getContactEmail(contactrecordid){ var webTemplateURL = ""; var emailaddress = ""; var contactcollection = null; try { //Web tempalte url to retrieve account url webTemplateURL = "/getemailaddress/?contactid=" + contactrecordid + ""; //alert(webTemplateURL); //Request to custom page to get account data in json format contactcollection = getResponse(webTemplateURL); //Check for each account from account collection contactcollection.results.forEach(function (contact) { emailaddress = contact.emailaddress; var div = $("<div/>"); div.html(GetDynamicTextBox(emailaddress)); // $("#cccontent1").html(div); $("#TextBoxContainer").append(div).show(600); var values = ""; // $("#note").show(1000); $("input[name=DynamicTextBox]").each(function () { values += $(this).val() + ";"; // values += contactid + ";"; }); // $("#ccbuttonid").attr("value",contactname); $("#test_ccemailaddress").val(values); }); } catch (e) { console.log("getAccountData :: " + e.message); } } function getResponse(webTemplateURL) { var response = null; try { $.ajax({ type: "GET", url: webTemplateURL, dataType: "json", async: false }).done(function (json) { response = json; }); } catch (e) { console.log("getResponse :: " + e.message); } return response; }

function GetDynamicTextBox(value) {

    return '<input name = "DynamicTextBox" type="button" class="text-left" size ="60" style="background-color:white ;border-style:double;border-width:think;border-color:#5DADE2;display: block;  width:230px; height: 25px; margin:0px; float: left;" value = "' + value + '" readonly/>' +

        '<input type="button" style="background-color:white;border-width:thin;border-color:#5DADE2; display: block;  margin-right: 5px;padding:0px width: 20px; height: 25px; float:left;" value="x" class="remove" />'
}





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>




Friday, May 28, 2021

Create HTML Table and Bind the array data in Power automate

 In this post , we are going to see how to bind the array data into html table and send the mail.


Follow the below step to achieve this.


1. Create Array variable before foreach action

2. Bind the array value inside the foreach action

3. Add Create HTML table after foreach action

4. Add Style compose to style html type

5. Add compose to remove a href tag if column has hyperlink

6. Add style output first in outlook email send

7. Add Replace a href output as second in email


Case ID array object has link ->outputs('Case_ID_Link');


Style:


<style>

Table {

  font-family: Arial, Helvetica, sans-serif;

  background-color: #EEEEEE;

  border-collapse: collapse;

  width: 100%;

}


Table td, Table th {

  border: 1px solid #ddd;

  padding: 3px 3px;

}


Table th {

  font-size: 12px;

  font-weight: bold;

  padding-top: 10px;

  padding-bottom: 10px;

  text-align: left;

  background-color: #1C6EA4;

  color: white;

}

</style>


Replace a href tag:

replace(replace(body('Create_HTML_table'), '&lt;', '<'), '&gt;', '>')




1. 

2. 


3. 




output:









Wednesday, March 10, 2021

Custom filter button to show metadata filter on entity list

 Below jquery is to add custom filter button to show and hide the metadata filter in entity list.


var btncount = 0;
$(".entitylist.entity-grid").on("loaded", function (e) {
e.preventDefault();
if(btncount == 0){
$(this).children(".view-toolbar").append
('<button id="filterbtn" style="font-size:23px ;background-color:#FDFEFE;color:#2980B9;border:none; ">
<i class="fas fa-filter" style="font-size:25px;color:#2980B9"></i></button>');
btncount++
}
$('.view-loading, .message, .text-center').prop("style" , "display:none");
$(this).children(".view-grid").find("th").css("background-color", "#EBF5FB ");
$(this).children(".view-grid").find("tr:even").css("background-color", "#F4F6F6");
var count = 0;
$("#filterbtn").click(function(){
count++;
$('.col-md-3, .filter-vertical').show();
$('.col-md-3, .filter-vertial').prop("style","margin-left:-20px;")
$('.entity-grid, .entitylist').prop("style" , "margin-right:-35px;margin-left:-9px")
if(count % 2 == 0) {
// $('.col-md-3, .filter-vertical').hide();
// $('.entity-grid, .entitylist').prop("style" , "margin-right:-215px ; margin-left:33px")
} else {
}
})




Color Highlights in Entity list rows and column in powerapps portal

 In this post , we are going to see how to highlight the row and specific column in entity list. 


Add below mentioned jquery in entity list options tab



Use below jquery to highlight the rows alone in entity list

$(document).ready(function () {
$(".entitylist.entity-grid").on("loaded", function (e) {
e.preventDefault();
if(btncount == 0){
$(this).children(".view-toolbar").append('<button id="filterbtn" style="font-size:23px ;background-color:#FDFEFE;color:#2980B9;border:none; "><i class="fas fa-filter" style="font-size:25px;color:#2980B9"></i></button>');
}
$('.view-loading, .message, .text-center').prop("style" , "display:none");
$(this).children(".view-grid").find("th").css("background-color", "#EBF5FB ");
$(this).children(".view-grid").find("tr:even").css("background-color", "#F4F6F6");
var count = 0;

});

})




use below jquery to highlight rows as well as specific column in entity list
$(document).ready(function () {
$(".entitylist.entity-grid").on("loaded", function (e) {
e.preventDefault();
if(btncount == 0){
$(this).children(".view-toolbar").append('<button id="filterbtn" style="font-size:23px ;background-color:#FDFEFE;color:#2980B9;border:none; "><i class="fas fa-filter" style="font-size:25px;color:#2980B9"></i></button>');
btncount++
}
$('.view-loading, .message, .text-center').prop("style" , "display:none");
$(this).children(".view-grid").find("th").css("background-color", "#EBF5FB ");
$(this).children(".view-grid").find("tr:even").css("background-color", "#F4F6F6");
var count = 0;


$(this).children(".view-grid").find("td[data-attribute='statuscode']").each(function (i, e){

var value = $(this).data(value);

if(value.value.Value ==100000001)

{

$(this).closest('td').prepend('<i class="fas fa-exclamation-circle" style="color:#F1C40F;"></i>&nbsp;');

}
if(value.value.Value ==1)

{

$(this).closest('td').prepend('<i class="fas fa-clock" style="color:#E67E22;"></i>&nbsp;');

}

if(value.value.Value ==3)

{

$(this).closest('td').prepend('<i class="fas fa-minus-circle" style="color:#CB4335;"></i>&nbsp;');

}

if(value.value.Value == 5)

{

$(this).closest('td').prepend('<i class="fas fa-check-circle" style="color:#2ECC71;"></i>&nbsp;');
}

else{


}
// $("ul.pagination").click(function(e){
// e.preventDefault();
// })

});
})




Tuesday, March 9, 2021

Custom Date Range Filter in Entity List powerapps portal

 

In this post , we are going to see how to add the custom date range filter in powerapps portal entity list.

As we all know that we can add the filter in entity list using metadata filter configuration in portal management app. However there is no OOB date range filter in entity list. To achieve this need write Jquery and add calendar css reference.

Below step will help us to add the date range filter in entity list.

1. Select Metadata filter and choose orientation


2.  Create two fetch xml one is for from date and other for to date.


1st Fetchxml:

<filter type="or" adx:uiinputtype="dynamic" adx:uiname="From">
      <condition value="" attribute="createdon" operator="on-or-after" adx:uiinputtype="dynamic" />
</filter>

2nd Fetchxml:

<filter type="or" adx:uiinputtype="dynamic" adx:uiname="To">
      <condition value="" attribute="createdon" operator="on-or-before" adx:uiinputtype="dynamic" />
</filter>

3. Go to option tab in entity list and write the jquery to change the property of from and to control from checkbox to text


//Change the ‘checkbox’ control’s type as Text
$('[name="3"]').prop('type', 'text');
//Set Unique Id for the control
$('[name="3"]').prop('id', 'from');
//Hide the control
$('[name="3"]').hide();
$('[for="3"]').hide();
//Set null value for the Dates
$("#from").val("");


$('[name="4"]').prop('type', 'text');
$('[name="4"]').prop('id', 'to');
$('[name="4"]').hide();
$('[for="4"]').hide();
//Set null value for the Dates
$("#to").val("");
$('[for="dropdown_1"]').hide();
$("#dropdown_1").hide();

$("ul#entitylist-filters").append("<li class='entitylist-filter-option-group'><label class='entitylist-filter-option-group-label h4'>Date Range</label><div id=DateRange class='form-control'><i class='fa fa-calendar'></i>&nbsp;<span id=DateRangeValue></span><i class=fa fa-caret-down pull-right></i></div></li>");

var start = moment();
var end = moment().add(10, 'days');
function cb(start, end) {
$('#DateRangeValue').html(start.format('MM-DD-YYYY') + ' - ' + end.format('MM-DD-YYYY'));
}

$('#DateRange').daterangepicker({
startDate: start,
endDate: end
}, cb);
cb(start, end);

$('#DateRange').on('apply.daterangepicker', function(ev, picker) {
var dates = $("#DateRangeValue").html().split(" - ");

$("#from").val(dates[0]);
$("#to").val(dates[1]);
});
});

4. Go respective webtemplate and paste the below reference.

<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">




5. Thats it , go to make.powerapps.com ->Sync configuration









Saturday, July 4, 2020

Calling power automate in portals



Calling Power automate  from portal

In this post , we will see about how to call the power automate by clicking button from portal.

Create web page
Go localize content of web page
Paste the below content in copy(HTML) section

<h1>Send an Email</h1>

<form action="/action_page.php">
  Subject: <input type="text" id="subject" name="subject" size="100" maxlength="100px"><br><br>
  Message: <textarea id="message" name="message" rows="4" cols="100"></textarea><br><br>
  <button id="sendemailbtn" onclick="Sendmail()" type="button" class="btn btn-primary button" style="margin-center:10px;"><span></span>Send Email</button>
</form>
<div>
    {% raw %}
    <script type="text/javascript" language="javascript">
   
     function Sendmail(){
         var subjectval = document.getElementById("subject").value;
         var messageval = document.getElementById("message").value;
        
    parent.$.ajax
    ({
        type: "POST",
        url: "https://prod-47.westus.logic.azure.com:443/workflows/47d1962b0cdd4b0fba8a8aa44622d49e/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=cqkmZaBfh1P92dYRy4_4Eu5af8u8kzYn5Ox_kmAEk-o",
        contentType: 'application/json',
        data: JSON.stringify({"subject" : subjectval , "message" : messageval}),
        success: function ()
        {

            alert("Email sent successfully");
                                    
        }
    });
     }
    </script>
    {% endraw %}
</div>









To call power automate on html button click

Need to give the portal url http request in javascript

 




Click on sample payload and type {“subject” : “test” , “message” : “test”}