javascriptdynamics-crmliquiddynamics-365adxstudio-portals

How to pre-fill fields in Dynamics 365 Portal entity form using liquid?


I'm using Dynamics 365 CRM Online and have the customer self-service portal add-on installed. I've built a list of records from a fetch query on one page (entity list didn't work here because of filtering limitations) and from that list I provide a button on each item that links to another page with some querystring parameters. The page that button goes to is a web page with an entity form to insert a task.

For example, the list page could be 'http://mysite123.microsoftcrmportals.com/availableitems' and the second page is '/scheduleitem?id=abc123&type=def'

I want to take values from the query string and use those values to fill in some fields on the entity form. I would like to fill in those fields in the background when the form is submitted or have them as hidden fields, but if they have to be visible then make them read-only so the customer doesn't alter them.

I've looked at the portal documentation and at entity metadata options for the entity form but that doesn't seem to have a way to tie fields to the query string params. Is there a way to do this with liquid or javascript or ??


Solution

  • We've found that if you hide the field (in the CRM form) then the fields aren't included in the page viewstate (i.e. if you change the value of the field, it won't persist to CRM). However, you can hide the field using JavaScript. It's not ideal but it works

    Secondly, you can set values using JavaScript. You should be able to add some JavaScript to the portal EntityForm and in a document.onready method read the querystring values and populate the fields. These changes should be persisted.