Dynamics 365 Configuration and Customization. Power App Portal Development, Power Platform development, Azure development, C#.Net, JavaScript, jQuery, SQL Server etc.
Download CRM 365 V9.X Tools using PowerShell
GET/SET Value to Different Data Types field in Dynamics 365 using JavaScript
GET/SET Value to Different Data Types field
Whenever you create function events on Entity's, we pass Execution Context of the form data to the function. We get he form context from Execution Context. Sample Code is as below.
function testFunction(executionContext) {
var formContext = executionContext.getFormContext();
}
Lets check GET/SET for different Data Types, here my prefix of fields schema name is dnlb.
Single Line Text or Multi Line Text
GET
var name = formContext.getAttribute("dnlb_name").getValue();
SET
formContext.getAttribute("dnlb_name").setValue("dotNetLittleBoy");
Two Options
GET
var isValid = formContext.getAttribute("dnlb_isvalid").getValue();
SET
formContext.getAttribute("dnlb_isvalid").setValue(true);
Option Set
GET value
var typecode = formContext.getAttribute("dnlb_typecode").getValue();
GET Text:
var typecodeText = formContext.getAttribute("dnlb_typecode").getText();
SET
Set using value
formContext.getAttribute("dnlb_typecode").setValue(99000000);
Set Option set using Text
var text = "TypeA";
var optionSetValues = formContext.getAttribute("dnlb_typecode").getOptions();
for (i = 0; i < optionSetValues.length; i++) {
if (optionSetValues[i].text == text) {
formContext.getAttribute("dnlb_typecode").setValue(optionSetValues[i].value);
}
}
Multi Select Option Set
GET values
var appcodeVal = formContext.getAttribute("dnlb_applicationcode").getValue();
GET Text
var appCodeName = formContext.getAttribute("dnlb_applicationcode").getText();
SET
Set using value
formContext.getAttribute("dnlb_applicationcode").setValue([990000000,990000001,990000005]);
Set using Text
var commonAppCode=[];
var optionText = ["AppCodeA","AppCodeB","AppCodeC"];
var optionSetValues = formContext.getAttribute("dnlb_applicationcode").getOptions();
for (i = 0; i < optionText.length; i++) {
for (j = 0; j < optionSetValues.length; j++) {
if (optionText[i] === optionSetValues[j].text) {
commonAppCode.push(optionSetValues[j].value);
formContext.getAttribute("dnlb_applicationcode").setValue(commonAppCode);
}
}
}
Whole Number
GET
var studentAge = formContext.getAttribute("dnlb_studentAge").getValue();
SET
formContext.getAttribute("dnlb_studentAge").setValue(25);
Decimal Number
GET
var testdn = formContext.getAttribute("dnlb_test").getValue();
SET
formContext.getAttribute("dnlb_test").setValue(40.6);
Floating Point Number
GET
var testfn= formContext.getAttribute("dnlb_testfn").getValue();
SET
formContext.getAttribute("dnlb_testfn").setValue(0.00009);
Date
GET
var dob = formContext.getAttribute("dnlb_dobdate").getValue();
SET
formContext.getAttribute("dnlb_dobdate").setValue(d); //d value should be in utc format based on date type as Date Only or Date Time both.
Currency
GET
var amount = formContext.getAttribute("dnlb_totalAmount").getValue();
SET
formContext.getAttribute("dnlb_totalAmount").setValue(176.98);
Lookup or Customer
GET
var studentGuid = formContext.getAttribute("dnlb_studentId").getValue()[0].id;
var studentEntityType = formContext.getAttribute("dnlb_studentId").getValue()[0].entityType;
var studentName = formContext.getAttribute("dnlb_studentId").getValue()[0].name;
SET
var studentLookup = new Array()
studentLookup[0]= new Object();
studentLookup[0].id = "{{RECORD_ID_WHICH_TO_BE_SET}}";
studentLookup[0].entityType = "dnlb_student";
studentLookup[0].name = "dotNetLittleBoy";
formContext.getAttribute("dnlb_studentId").setValue(studentLookup);
Happy Coding !!!
How to get the current Environment URL in Canvas App or Custom Page?
To get the Current Environment in canvas app,we can perform the following step:
Step 1: Include Canvas App data source in app and connector PowerAppForMakers as below screenshot.
Step 2: Set the below variable on load or particular event of the screen.
the variable varCurrentEvironmentURL will store the environment url.
What is Web-hook? How to configure the Web-hook?
Web-hooks is a lightweight HTTP pattern for connecting Web APIs and services with a publish/subscribe model.
Release with CE App 9.0
With Web-hook we can integrate Customer Engagement data with external service.
Web can be invoked from Plugin step or custom workflow activity.
It can be invoked as Synchronous and Asynchronous.
To secure your endpoint and Authenticate:
- HttpHeader
- WebhookKey
- HttpQueryString
How to read the file content when uploaded in file data type in Dynamics 365 field?
Created new Entity File Upload. Created new field '* Upload' as file data type.
A flow is created which will trigger on Modified event on this entity record.
Design of flow is as below
Design of base64ToString is as below:
After the flow has run the output will be like below:
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
$(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>");
});
});
});
MS CRM Portal : What is Advance Form and How to Configure it?
Advance Form
- Basic Form
- Advance Form
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.
Then we need to create the Advance Form.
- 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.
- Condition
- Load Form
- Load Tab
- Redirect
- Load User Control
Now we have created the Advance Form Steps, let setup the steps.
Lets Create Web Page, Page Template & Web Template to render the Advance Form.
Finally, configured the Table Permission and Associated the Permission to Web Role.
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
-
To get the Current Environment in canvas app,we can perform the following step: Step 1: Include Canvas App data source in app and connecto...
-
What is Plugin in Dynamics 365? Plugin is custom business logic (code) which is added to dynamics 365 to extend the standard behavior....
-
What is Assign and Share Privilege in Microsoft Dynamics CRM? Ans: Basically two type of entities are created: a. Organization ...
-
Plugin vs Workflow, which will execute first? Execution of plugin and workflow depend on whether it is registered as Per or Post events. B...
-
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 avoi...
-
MS CRM Portal : Web Page Configuration Web Page is use to display the content of website. It represents URL in Portal. It is represented wi...
-
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...
-
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. The...
-
What is Field Level Security in Dynamics 365? As name indicates, it is applicable to the entity fields. However all field are not applicabl...
-
GET/SET Value to Different Data Types field Whenever you create function events on Entity's, we pass Execution Context of the form data...
