Skip to main content

Posts

Showing posts from August, 2021

D365 portal currency field formatting

D365 portal is not able to format the currency field. It shows like that I also try to use mask but that is not solve my problem. https://oliverrodrigues365.com/2020/04/15/power-apps-portals-adding-field-mask/ I use the following java script. $(document).ready(function(){ // Hide default currency icon from this form $("span."+"input-group-addon").hide(); // Set currency icon var std_classfee_onload = parseFloat($('#std_classfee').val()); $('#std_classfee').val(new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(parseFloat(std_classfee_onload))); // Form validation for next button or save button click window.webFormClientValidate = function () { // Presave remove currency icon var std_classfee_presave = parseFloat($('#std_classfee').val()); $('#std_classfee').val(std_classfee_presave);

D365 portal date field formatting

 In portal the CRM form date field is not showing in to the right format. it shows like this. If you want to format this date field you can use this script. function setDateTimeFieldValue(fieldId, dateValue) { //Get the submit field var $submitField = $("#" + fieldId); //Get the display field var $displayField = $submitField.nextAll(".datetimepicker").children("input"); //Get the display date format var dateFormat = $displayField.attr("data-date-format"); //Set the submit field. Remember this needs to be in UTC and the format must be exact. $submitField.val(moment.utc(dateValue).format("YYYY-MM-DDTHH:mm:ss.SSSSSSS")); //Set the display field using the page's date format $displayField.val(moment(dateValue).format(dateFormat)); } Call this function with field name and value var std__eventstartdatetime = setDateTimeFieldValue('std__eventstartdatetime',data.value[0].s

D365 portal hide Azure AD login button

 Open theme.css of your portal. add this line at the end of the file. .btn-line { visibility: hidden; } Go to your portal management and into site settings set Authentication/Registration/ExternalLoginEnabled False. Now your portal login window will look like this.

D365 portal form validation script with other script

 In your portal form you have form script which is based on your form input. If you also want add form validation in to same script you can use this sample code. $(document).ready(function(){ // Write your other form script code // Client validation this will trigger during submit or next button for advance form window.webFormClientValidate = function () { // write your client validation logic var assistenstd = parseFloat($('#proevt_assistenstd_discount').val()) var filePath = $('#AttachFile').val(); if(assistenstd>0){ if(filePath){ return true; } else { // Validation error alert("Please upload document."); return false; } } }; });

D365 portal please wait bar with animation

 if you want to use please wait with animation in your portal in any event you can use this  this jquery will work with the default bootstrap of the portal.  // Please wait function showPleaseWait() { if (document.querySelector("#pleaseWaitDialog") == null) { var modalLoading = '<div class="modal" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false" role="dialog">\ <div class="modal-dialog">\ <div class="modal-content">\ <div class="modal-header">\ <h4 class="modal-title">Bitte warten...</h4>\ </div>\ <div class="modal-body">\ <div class="progress">\ <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar"\

D365 portal checkbox enable / disable

Checkbox is special input type into javascript. You can try the following for checkbox enable / disable //Disable $("#std__assistenzarzt").attr('disabled', 'disabled'); $("#std__assistenzarzt").attr("readonly", "readonly"); //Enable $("#std__assistenzarzt").removeAttr('disabled'); $("#std__assistenzarzt").removeAttr('readonly');

D365 portal advance form get the previous step data in the current step

 Using localStorage in javascript we can easily get the previous step data in the current step. // Set value into previous step window.localStorage.setItem('studentregistrationadvancestudentGuid', studentGuid); // Get value into next step var requeststudentId = window.localStorage.getItem('studentregistrationadvancestudentGuid');

D365 portal enable error previewing

 If any error occurs in the portal it is not showing the proper reason for the error. If you enable EnableCustomPluginError it will show the proper message of the error. Go to Site settings and create new : Site/EnableCustomPluginError

d365 portal many to many relationship table permissions

 Sometimes we need to access many to many table relationship access. By default, the portal is not allowing to give permission many to many tables because there is no physical Entity.  Using  Levelup-for-Dynamics-CRM  you can easily set the many to many table permission.  Navigate to your table permission menu into portal enable God Mode Select new, select any entity. Replace the table name with your many-to-many relationship table name. Add web role for this table access

d365 portal fetchxml query as a json service

 In D365 portal sometimes we need to write a complex query which is not covered by List as OData Feed. If you use D365 Form Liquid fetchxml query is also not supported. You can write any fetch xml query as JSON data service into the portal. 1. Create Web Template Into your web template, you need to write your fetchxml query {% assign std_discountid = request.params['id'] %} {% fetchxml discountAccount %} <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"> <entity name="std_std_discount_account_membership" > <attribute name="accountid" /> <attribute name="std_discountid" /> <filter> <condition attribute="std_discountid" operator="eq" value="{{std_discountid}}" /> </filter> </entity> </fetch> {% endfetchxml %} { "accountdiscounts" :

D365 portal field change event set other field value

 if you need to get value from any field into the portal and set other field values you can use this script $(document).ready(function(){ $('#student_couponcode').on('change',(studenteventdiscountamount) => { debugger; var eventcouponcode = studenteventdiscountamount.target.value; var eventcouponcodefilteroption = "student_couponcode eq '"+eventcouponcode+"'"; var odataUrI = "https://yourportal.com/_odata/student_discounts?$filter="+encodeURIComponent(eventcouponcodefilteroption); $.ajax({ type:'GET', contentType: 'application/json; charset=utf-8', datatype: 'json', url: odataUrI, beforeSend: function(XMLHttpRequest){

D365 portal select lookup field value on form load

 If you want to select your lookup field on form load or other events you can use this script. $(document).ready(function(){ var requeststudentId = '{{ request.params.id }}'; if(requeststudentId) { var eventLookupfilteroption = "studentid eq guid'"+requeststudentId+"'"; var odataUrI = "https://yourpotal.com/_odata/students?$filter="+encodeURIComponent(eventLookupfilteroption); $.ajax({ type:'GET', contentType: 'application/json; charset=utf-8', datatype: 'json', url: odataUrI, beforeSend: function(XMLHttpRequest){ XMLHttpRequest.setRequestHeader('Accept', 'application/json'); }, async: true, success: function(data, textStatus, xhr){ if(data.value[0]) { // Populate lookup field var studentid = data.value[0].studentid; v

D365 portal OData query filter

  I am using this OData query filter in my D365 portal. For Guid filtering var userId = '{{ user.id }}'; var contactfilteroption = "contactid eq guid'"+userId+"'"; var odataUrI = "https://yourportal.com/_odata/contacts?$filter="+encodeURIComponent(contactfilteroption); For string filtering var couponcode = eventdiscountamount.target.value; var couponcodefilteroption = "stdsscouponcode eq '"+couponcode+"'"; var odataUrI = "https://yourportal.com/_odata/stdssdiscounts?$filter="+encodeURIComponent(couponcodefilteroption);

D365 portal remove bar from read only field

 If we define a field read-only into CRM and into the portal it shows (-). if you want to remove the bar you can use the following javascript for that field.  $(document).ready(function(){ $("#stdsscode").attr("readonly", true); setTimeout( function(){$("#stdsscode").next("div").hide()}, 300); });

D365 portal set option set value

 In the D365 portal, you can set option set value using javascript. var salutationTitle = data.value[0].stdss_salutation_opt.Name; $("select#stdss_salutation_opt option").filter(function() { return $(this).text() == salutationTitle; }).prop('selected', true);

D365 Error converting attribute value to Property

 You are getting this error into your plugin  Unable to cast object of type 'System.Guid' to type 'Microsoft.Xrm.Sdk.EntityReference' Your crud operation Entity field has a Lookup field relationship and it is expecting EntityReference. EntityReference conactEntityReference = new EntityReference { Id = newContactEntity.Id, LogicalName = Contact.EntityLogicalName }; localContext.OrganizationService.Update(new Entity(proevt_eventregistration.EntityLogicalName, inputEventseriesEntity.Id) { ["proevt_contactid"] = conactEntityReference });