Webapi Configuration in Power App Portal

Webapi Configuration in Power App Portal

We can test the API in browser.

Example: We want to retrieve the details of entity "dnlb_student", then use below format url.

<portal_url>/_api/dnlb_students

the letter 's' will be appended at the end of entity logical name.


So, it will give error. We need to configure the Web API setting in Site Setting of portal.

To configure it, Go to the Portal Management App and Site Setting.


Create new Site Setting Configuration to enable the Web API on "dnlb_student" entity and fields to be retrieved in result as below.

To Enable the Webapi:

To Enable the Fields:

Here, when we put * in Value then it will retrieve all the fields/columns of entity. 

However we can specify the fields logical name which we want to retrieve by separating them in comma (,).


Now, when we try to access, it gives permission issue.

To fix it, we need to create the table permission for "dnlb_student" entity and associate Web Role to it. Web Role should be the role which is associated to Login Contact user.

Now try to access the Webapi URI:

It gives the result now. It has all the fields in result.


To get the limited fields in the result, we can configure those fields in Webapi configuration.

Example, we need to get "dnlb_name", "dnlb_firstname", "dnlb_lastname". Then we need to configure the Webapi/dnlb_student/fields values as below:


Now try to access the api:

It gives error because we have specified particular fields in Webapi configuration and trying to retrieve all fields. Since we have not mentioned $select fields in query URI, it fails.

lets specify the fields names in $select in query as below:

It gives result perfectly.


We can also configure the Webapi for inner details of error as below:



Thank you !

Good Day 👏

Use code of Web file in Basic forms or Advance Forms steps scripts.

Web files are used to add some additional components to Portal. It is just like adding the attachment using Notes. Web files are reference by partial URL specified. We can configured web file for Particular web page or home page. When it is at home page then it can be reference directly as below in Web Template. Since home page will have '/' as partial URL.

<script src="/mytestscripts.js"></script>
 
The other web page which is configured it will be configured as child/under Home page. 

Take an Example, we have configured webpage with partial URL as 'test-page' & its parent is home page. We have configured JavaScript Web file which is having partial URL as 'test-page-logic.js'. While configuring web file, we have webpage which was having this 'test-page' partial URL.

Web file can be reference test-page-logic.js file in test-page web template as below.

<script src="/test-page/test-page-logic.js"></script>
 
Consuming web file on Web template is direct by using partial URL.
 

Sometime we will have web file which is having common kind of function we want to use in different places. Using in Web template is directly by linking the file.
But to use in Basic form or Advance form steps custom JavaScript logic is bit different. 
We can not directly link using HTML <script> tag.

Take an example, I have web file 'test-common-logic.js' file. It has some common variable/function as below:
 
var someVariable = "someValue";
function doSomething() {
    console.log("Perform something");
}

 
I want to use some of the function/variable of this file in Basic Form.

To use this, we need to load the function written in 'test-common-logic.js' file.
And to load, we need fetch text which will be nothing but our logical code. Append this text inside the head tag of HTML. We can push JavaScript code text when document gets ready as below.
 
 
$(document).ready(function(){
    fetch("/
test-common-logic.js")
      .then(res => res.text())
      .then(jsCode => {
        var jsElement = document.createElement("script");
        jsElement.textContent = jsCode;

        //append the jscode under in head tag of loaded html
        document.head.appendChild(jsElement);
        
        //once code is added in head, we can use components from that.
        var x = someVariable;
        doSomething();
    });
});


 

Different Way to Open Edit Form Web Page from Entity List in Power App Portal

Open Web Page From Entity List In this blog post

I will show you three different way to open particular Web Page from Entity List (table display in portal).

To display the list of records in tabular grid, you would must have configured List or Entity List.
Entity List must be selected on Web Page to display the records.

We need to modify the entity list or list to get open the Edit Web Page. To open the record in Edit Page or Read Page, we need the Id (It is D365 record id) of the record. 
So for that we must select the web page and append the target URL with Id. 
We have different way of doing it. 
Lets take a look on different way.

1)    On the List or Entity List, under General Tab, we need to select the your edit web page.
Select  web page in Web Page for Details View field. You can see id is selected in ID Query String Parameter Name field. If you want to add some text to display button, you can the button display text in Details Button Label field.

2)    In List or Entity List, go to Option tab and add Item Action. We can use Details & Edit action to redirect on particular Web Page.
Select the Target Type as Web Page
Select the Redirect to Web Page as your particular Web Web which you want to open from table.
Enter the button display name in Button Label.

3)     Another way is to bind the hyperlink on each record of table. To do that add below code in List or Entity List under Option tab, there custom JavaScript area.
When DOM module is ready, it will execute the logic.
Find the entity list grid element by class (entitylist.entity-grid) and when it is loaded then execute the logic.
For all the Children element of entity list grid, find the field on which you want to make hyperlink. Here in code I have added on dnlb_name field. 
Get the record id using attribute data-id.
Add wrapInner function and hardcode the URL you want to open.

$(document).ready(function(){
$(".entitylist.entity-grid").on("loaded",function(){
$(this).children(".view-grid").find("td[data-attribute='dnlb_name']").each(function(){
var studentId = $(this).parent().attr("data-id");
$(this).wrapInner("<a href=\"/studentlist/editstudent/?id="+studentId+"\"</a>");
});
});
});



Good Luck Geeks 😎

MS CRM Portal : What is Advance Form and How to Configure it?

Advance Form

There are two types of form available in Power App Portal.
  • Basic Form
  • Advance Form

Basic Form : It is used to Edit, Create and Read the data of Single Tabbed Form (Form from Dynamics).
Advance Form: It is like wizard type form, which give functionality similar to Basic Form.

The main difference between Basic Form and Advance Form is that Basic Form is use to collected data from Single Entity Form with Single Tab where as Advance Form is use to collect data from multiple entities and it consist of Advance Form Steps to capture the data from multiple tab and with condition branched on the steps feature.

Both the forms are used in Web Page to render the form in Portal web page.

Lets follow the steps to create the Advance Form and render on Web Page.

First we need to design the Main Forms in Dynamics 365 for the entity which we want to capture the data or display the data in Web Page.


Note: Only Main Form type can be used to create the Advance Form, we can not use Quick View Form, Quick Create Form, Card Form etc.

Example: I have two entities - dnlb_application & dnlb_student.
I have created the main form and design as below for Application Entity. It has only one tab i.e. General tab.
For the another Student Entity, I have created the main form and added three tabs i.e. General, Class Details & Payment Details as below.
So the configuration I have done in Dynamics 365.
Now lets move to he Portal Configuration, go to the Portal Management App.

Then we need to create the Advance Form. 

Create new Advance Form:
Name : Enter the name of Advance Form.
Website : Select the website for which creating Advance Form.
Start Step : (Will select it in below when we configure the step).
Authentication Required : Make is Yes if want to make Advance to be authenticated first.
Start New Session on Load : Select Yes if every time when browser window is referesh, in that the session will start with fresh load. If No is selected then window is restart then it will load from previous session.
Scroll down and Enable Progress indicator on the form.
Select the Type : It has three types 
  • Title : It give name of Advance Form steps which will configure.
  • Numeric (Step 1 of N) : It give the number of steps.
  • Progress Bar : It gives percent of form complication.
There are some other configuration which can be enabled as required.

Step3: Now will create Advance Form Steps. Go to Advance Form Step tab to add new steps.
I have added two steps, one for the application and another for the Student.
Application Advance Form Step:
Name : Enter the name of step.
Advance Form : Select the Advance Form.
Type : There are five types
  • Condition
  • Load Form
  • Load Tab
  • Redirect
  • Load User Control 
I have selected type as Load Form, so I have selected the form which I have configured in Dynamics. To select the form, go to the form Definition tab.
Note : Entity Permission should be enabled for all type of form for security reason.
I have created the application step for create mode. There are other feature which we can configured as per requirement.
I have selected the form which I have configured in Dynamics, it has three tabs. 
I have enabled the Auto Generate Steps from Tab option to automatically the generate the steps for tabs which I have configured on the dynamics form.

Finally the Advance Form Steps will look like below:

Now we have created the Advance Form Steps, let setup the steps.
I have set the Application step as start step as below.

On the Step1, select the next as step2.
On Steps 2, I do not have any steps further so I will keep is blank.



Finally we have configured the Advance Form and Advance Form Steps.

Lets Create Web Page, Page Template & Web Template to render the Advance Form.

Web Template:
Add the code as below in Web Template to include the Advance Form (Which will be selected on Web Page). This code is included because Entity for Advance Form is Web Form.
Next, Create Page Template under the Web Template.
Now Create the Web Page under the Page Template. Select the Advance Form which we created in Web Page. 
Verify the same Advance Form is selected on Content Web page also.

Finally, configured the Table Permission and Associated the Permission to Web Role.

The Table Permission is important because all the Forms which we created have Enabled Table Permission. To load the Form we need to provide the access.

I have configured the Table Permission for my both Application and Student Entity as below.

I have associated these Permission to my Web Role.
I have associated the Web Role to my Portal Contact user so that when I will login to Portal, I will have access to these Entities to load the form.




Result

Now will login to portal, try to load the Web Page which we configured.
Bingo !!! :) 
Web Page has loaded the Advance Form.







Good Luck Guys 😎

What is Site Marker and How to use Site Marker?

MS CRM Portal : What is Site Marker and How to use Site Marker?

If you ask what is Site Marker?
Answer would be very simple, it use to avoid the hard code URL of web pages in portal development.

Take a scenario where we can use the Site Marker.
You have some custom button on Web Page. On the click of this button, you want to open some Web Page in new tab.

To open the Web Page in new tab, you need the URL of the Web Page so that you can use href tag to open it new tab. If you know then you can directly hardcode the URL in code. Which is not the correct way to do.

To avoid such coding of hardcode URL you need to configure the Site Marker.
So, basically Site Marker hold the URL of Web Page and it will give you URL of your Web Page selected on the Site Marker Configuration.

The URL can be retrieve using the Liquid Script as below.
{% assign siteMarkerURL = sitemarkers['Site Marker Name'].url %}
To show you with demo:
Let me tell you the setup I have configured.
First I have create the Web Template and Page Template as below.
Under the Page Template, I have created two Web Page as below. 

On the Web Template code area, I have added custom button. On click of this button I want to open my DNLB - Site Marker Web Page. 
The button which is added through code will display on Web Page as below. I have open DNLB - Application Create Web Page on portal.
On Click of Open Site Marker button, I want to open DNLB - Site Marker Web Page.

I hope now you have understood the setup.

Lets configure the Site Marker.
Go to Portal Management App and select Site Marker on left navigation.
Create new Site Marker.
Name : Enter the name of Site Marker. Through this name you can access the Site Marker in Liquid Code.
Website : Select the website for which you are creating the Site Marker.
Page : Select the Web Page for which you want to use the URL. (I have selected DNLB - Site Marker Web Page as I need the URL in code.)


Now lets modify the Web Template code where we have to register the function on click of custom button.
I have added below code to retrieve the URL of selected Web Page (DNLB - Site Marker Web Page).
{% assign siteMarkerPage = sitemarkers['DNLB - Site Marker Web Page'].url %}

As code as below when DOM module gets ready then bind the function on click.


{% assign siteMarkerPage = sitemarkers['DNLB - Site Marker Web Page'].url %}
<script>
var SiteMarkerButton = $("<input type='button' id='btnSiteMarker'
    value='Open Site Marker' style='float:right' class='btn btn-primary' />");
$(".page-header").before(SiteMarkerButton);
$(document).ready(function(){
$("#btnSiteMarker").on("click",function(){
window.open("{{%siteMarkerPage%}}","_blank");
});
});
</script>




Open the Web Page where custom button is present. Click on Custom button.
Bingo !!! New Tab is loaded with page of Site Marker as configured.

This is how you can use the Site Marker in your Portal development.




Stay Safe and Best of Luck !!! 😎

How to use JavaScript Web File in Portal?

How to use JavaScript Web File in Portal?

Web file use to store images, .json type file, .js type file, documents and other file types. These attached files can be downloaded. 

When the files are attached, it is accessible by code written in Web Template, Page Template or other codes.

When you go to the portal, you will find already some web files added to portal. The file like bootstrap.js, bootstrap.min.css (used for responsive portal website), banner image, home page logo etc. These web files are used to build the default Portals. 

To store the actual content of file, portal uses attachment feature of notes associated with a web file record. When files are attached, it has limitation of size it supports to upload based on type of files are being attached. 


In this post will see in details about how to use JavaScript as Web File in Power App portal?

I will show you steps how to use JavaScript or jQuery code written in .js Web File can be use in Web Page through Web Template.

Let's see step by step.

Scenario: I have one Web Page (Partial URL as create-application) which contains a Submit button with id InsertButton. On click of this button, I want to show confirm dialog. The code of logic will be written in .js Web File.


Step1: create your .js file which contains your code of logic. 

Yea, you are right !. Code is pretty simple. When DOM module becomes ready my code loads and register on click event function which shows confirm dialog when Submit (i.e. InsertButton) is clicked.

Save the file of code with extension (.js) in your local system. This file we need to upload to the Web File in Portal.

Step2: before you upload any file extension to D365, you need to remove restriction. By default D365 restrict some file type and .js type is one of it. 

To remove go to Advance Setting - > Administration - > System Setting.

Remove the js from the list of Set blocked file extension for attachments.

Step3: Now go to the Portal Management App and select Web File. Under the Web File, create new Web File. I have already created a Web File with partial URL dnlb_application.js as below.

Name : Enter the name of the Web File.

Website : Select the web site portal for which you are creating web file.

Parent Page : You can select home if you want web file to accessible from home page. You can create the web files for specific pages then you need to the specific page as parent page.

Partial URL : Partial URL is important. Through Partial URL you can access the Web Files. Enter the partial URL text.

Published State : Select published state as Published.

Title : You can specify the title through which you can see the Web File in XrmToolBox and all.


Step4: Once the Web File record is created then go to Notes tab of Web File. Add .js file as attachment which you created and contain code of your logic.

I have attached my saved file as below.

Now the content of notes which we attached can be access through Partial URL.

Step5: To check if it is correctly uploaded, get the portal URL and append the partial URL in the web site URL.

Example: If my Portal Website URL is https://xyz.powerappsportal.com/ then append the partial URL as https://xyz.powerappsportal.com/partialurl. In below image you can I have append my Web File Partial URL as dnlb_application.js. You can see the code written in the attached file. If content load correctly then you successfully uploaded the file.

Step6: Now to use the code of .js Web File in Web Page, you can include this .js Web File in Web Template or Page Template as below.

When you include your web file to Web Template then it can access variable or function which are present in Web Template also.

I have already created Web Template file to load the Web Page. I have placed code as below to include the my Web File with Partial URL dnlb_application.js.

Step7: Now save the Web Template and go to Web Page and try to Click on Submit button.

Bingo !! I got my confirm alert as coded in .js file.

This is how you can use the Web File to your Portal.




Stay Safe and Good Luck !

Featured Posts

Download CRM 365 V9.X Tools using PowerShell

This configuration explains about how to download D365 utility tools step by steps. Step1 : Create a folder in your particular drive where y...

Popular Posts

Contact Me

Name

Email *

Message *