Hello Team,
I am brand new to javascript. So, I'm struggling to understand the correct syntax for my requirement. I have a main email form and for that specific form, I'd like to populate the From column with a queue mailbox when the form state (getformtype) value is Create (1).
Here is the code from the .js web resource I've created:
function _setFromUser() { var formType = formContext.ui.getFormType(); var legalQueueID = "dcc80a43-39e4-e711-817f-e0071b715bc1"; var recordName = ""; var entityName = "queue"; if(formType == 1) { Xrm.Page.getControl("from").getAttribute().setValue([{ id: legalQueueID, name: recordName, entityType: entityName }]); }}
Here is how I have the event handler configured on the form:
Here is the error I receive:
ReferenceError: formContext is not defined at eval (eval at _executeFunctionInternal (https://********.crm.dynamics.com/uclient/scripts/app.js?v=1.4.3618-2111.2:1988:5296), :1:2) at eval () at y._executeFunctionInternal (https://********.crm.dynamics.com/uclient/scripts/app.js?v=1.4.3618-2111.2:1988:5296) at y.executeSync_DO_NOT_USE (https://********.crm.dynamics.com/uclient/scripts/app.js?v=1.4.3618-2111.2:1988:3404) at r (https://********.crm.dynamics.com/uclient/scripts/app.js?v=1.4.3618-2111.2:1719:61) at ee._convertEventDescriptorToCustomEvent (https://********.crm.dynamics.com/uclient/scripts/app.js?v=1.4.3618-2111.2:151:32656) at https://********.crm.dynamics.com/uclient/scripts/app.js?v=1.4.3618-2111.2:151:32306 at Array.map () at ee._getEventHandlerList (https://********.crm.dynamics.com/uclient/scripts/app.js?v=1.4.3618-2111.2:151:32294) at Object.execute (https://********.crm.dynamics.com/uclient/scripts/app.js?v=1.4.3618-2111.2:151:20784)
I've tried passing the formContext parameter to the function using the "Comma separated list of parameters that will be passed to the function" column in the event handler dialog. But, that doesn't seem to work either. Any ideas?