Tag Archives: webforms

{Solved} Typing in character t automatically inserting current datetime in datepicker controls on WebForms in Dynamics 365/ PowerApps Portals

Well, this one is indeed weird when I first time saw it. So basically we set up custom datetime format in portals to dd-MMM-yyyy.

If you are unware of custom datetime format in portals, you can follow this blog here.

Advertisements

All set and done, I launch a webform and the first step of the webform is the account details page. I have field “New Date Field” on the form. Remember the format of datetime in portal is dd-MMM-yyyy.

In line with the format, I try to key in the date – 12-Oct-2020. And observe the behavior.

As you can see from the above experience, the moment in keyed in “t”, it printed the new date. Trust me this is one of the hardest bugs to catch and if I would not have faced this one, I could never know about it.

What is our way out here? Well, I am a developer by heart and whenever something like this comes up, I try to dig in to the root cause of it.

Advertisements

The first thing I wanted to check if there is any keydown handlers attached when I press the key ‘t’. To find that, I tried the below code

image

Here “cr6d3_newdatefield” is my date field logical name in CRM. So you can see there is a keydown event handler and using the developer tools I went inside that function

As you can see from the below screenshot, there is a function attached on keydown of character ‘t’ which sets the value to current datetime.

image

Awesome isn’t it, to find these little little things. So exploration is done. Now what is the next step? How to make it work.

Well the easiest option I found was to remove the keydown event altogether.

$(“#<yourdatefield>_datepicker_description”).data(“events”)[“keydown”][0].handler = null;

Well, not the most elegant but certainly it works.

Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/2019/02/28/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)



WebForm sessions in PowerApps/ Dynamics 365 portals-All you need to know

Webforms are wonderful things in PowerApps portals. It allows you to design wizard control providing user with multiple steps to complete an operation.

And one of the wonderful things with WebForms in PowerApps portals is to maintain sessions. Say a Webform have three steps – Step 1, Step 2 and Step 3.

Say a portal user named Joe starts a webform and fills in till step 2 and then leaves the portal. When Joe again login to the portal and start web form, he will start from Step 2 instead from beginning, basically from where he left off. That’s an awesome feature.

Now the first question – Does webform always maintain session? The answer is No. It depends on the setting of the WebForm.

Advertisements

There is a field on the webform – “Start New Session on Load”. If you set this to Yes, it won’t save user’s session. If set to No, then the user’s session shall be saved.

image

Now the next question – Where are session information saved? How does Portal load session information specific to user?

Well, it’s pretty simple. On the WebForm record, there is “Sessions” tab. As you can see from the below screenshot, we can see the session saved for my login.

Advertisements
image

It’s no brainer that Portal loads session information from this record. Before we close this blog, let’s see what’s there on the session record.

image

As you can from the above screenshot, the portal user information and the entire step journey is stored in this record. And guess what, the step the user was last in, is stored in the Step History field. Below is the step history for one my sessions in json viewer.

image

As I highlighted, the IsActive: true is the step the user was last in and hence when the same portal user browse the webform, the active step shall be loaded.

And for some reason if a portal user request to start afresh a webform session, all you need to do is identify the session record for the portal user and he/ she shall start afresh.

Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/2019/02/28/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)