Get current entity logical name and record ID in CRM Portal forms using JavaScript

Use the following JavaScript to retrieve the current entity logical name and record ID in CRM Portal forms:

For Entity Form:

Entity logical name: $(“#EntityFormControl_EntityFormView_EntityName”).val()

Record ID: $(“#EntityFormControl_EntityFormView_EntityID”).val()

For Web Form Step:

Entity logical name: $(“#EntityFormView_EntityName”).val()

Record ID: $(“#EntityFormView_EntityID”).val()

Tested on xRM Portal CE.

 

UPDATE 10/01/2019:

The HTML structure is now different for Portal version 9.0.12.12 (cloud). There is now a GUID in the HTML field ID, e.g. EntityFormControl_978076ec8cf7e811a965000d3ae13a46_EntityFormView_EntityID.

For Entity Form, use the following:

  • Entity logical name: $(“input[id^=’EntityFormControl_’][id$=’_EntityFormView_EntityName’]”).val()
  • Record ID: $(“input[id^=’EntityFormControl_’][id$=’_EntityFormView_EntityID’]”).val()
  • Record state: $(“input[id^=’EntityFormControl_’][id$=’_EntityFormView_EntityState’]”).val()
  • Record status: $(“input[id^=’EntityFormControl_’][id$=’_EntityFormView_EntityStatus’]”).val()
Advertisement

About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in CRM, CRM Portal. Bookmark the permalink.

1 Response to Get current entity logical name and record ID in CRM Portal forms using JavaScript

  1. yabela says:

    Hi, Can I do Javascript that runs on submit of the form (Basic Form)? Something like;

    $(#formid).submit(function () {
    //do logic here
    });
    });

    If so, how do I get the form id?

    Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s