andriikulyk
andriikulyk

Reputation: 505

Can I get current record Guid in CRM dialog?

I call a crm dialog from ribbon button on some record form. Is there a way to get this record Guid inside dialog?

Upvotes: 0

Views: 2879

Answers (3)

GPGVM
GPGVM

Reputation: 5619

My need was slightly different and thus the two proposed solutions were not exact fits. I'm posting in case this helps someone else. I wanted to display the guid on a prompt and response page and then pass the guid on to custom code.

Of course CRM would translate the primary key guid to the record name.

In code this would be OK as I could query the entity for a record by that name but alot of extra processing in that.

We have an administration tab on all forms for extra support information. In this case I just created a field, put it on the admin tab and then added this javascript to form OnLoad.

function PopulateRecordGuid()
{
   if (Xrm.Page.ui.getFormType() != 1)
   {
      if(Xrm.Page.getAttribute('xxxx_recordguid').getValue() == null )
      {
        var Id = Xrm.Page.data.entity.getId();
        Id = Id.replace('{', '');
        Id = Id.replace('}', '');
        Xrm.Page.getAttribute('xxxx_recordguid').setValue(Id);
      }
   }
}

Of course there are many variations such as populating on create message with a plugin or workflow that triggers of record create etc.

Upvotes: 0

andriikulyk
andriikulyk

Reputation: 505

Thanks for all responses. I've found a way. In dialog form assistant we should Look for: {EntityName}, than choose in drop-down below {EntityName} - there is stored all data about current record that calls dialog.

Upvotes: 2

Paul Way
Paul Way

Reputation: 1951

Yes, here's a nice walk through of doing this:

http://crmmongrel.blogspot.com/2011/06/launch-dialog-from-ribbon-button-in-crm.html

In step 6, you'll notice the ribbon contains the following:

<CrmParameter Value="FirstPrimaryItemId" />

Upvotes: 0

Related Questions