Updating fields using popup windows from the editable grid

We have a requirement to show an editable grid on a form. Whenever a user enters a value, if it meets certain criteria then we need to prompt a message and save the input on the record.

This approach basically prevents us from showing too many fields on the editable grid and we can have a popup window to capture a field value on demand.

For this, we are going to use just a prompt command and register JS on the subgrid – it’s pretty straightforward.

Below is the code we use:

function ChangePreferredCommunication(executionContext)
var context = executionContext.getEventSource();
var parent = context.getParent();
var methodcode = parent.attributes.get("preferredcontactmethodcode");
var contactid = parent.getId().replace(/[{}]/g, "");
if(methodcode.getValue() == 2){
var userText = prompt("Please enter email", "Provide a email");
var data =
"emailaddress1": userText
} else if(methodcode.getValue() == 3){
var userText = prompt("Please enter telephone", "Provide a number");
var data =
"telephone1": userText
Xrm.WebApi.updateRecord("contact", contactid, data).then(
function success(result) {
Xrm.Utility.alertDialog("Contact Method Saved", null);
function (error) {
Xrm.Utility.alertDialog(error.message, null);

Registering web resources on subgrid

Now once you have registered the event, you can change the preferred method of contact and you will be prompted in a message box to enter text.

The example here can be used for adding new notes too.

%d bloggers like this: