0

I would like to be able to include a link in a view on the contact entity of dynamics crm that will pop a custom window that we have built. The custom window needs the contact id and the user id in order to function. Our users have requested that such a link be on the view rather than having to go into the contact record itself. So, is it possible to create a dynamic URL that will be utilized from the view and will be able to determine the contact id and the user id? I would assume I need to do this with a web resource, but I've only ever used a web resource in an iframe.

I have tried to build a web resource and just use the web resource's link to put into a field and display that field on the view, but obviously that didn't work.

Essentially the link would build a url and then pop up a new window with that url. Here's my url structure: https://example.com/mscrm/ticketing/Activity/PhoneCallSave.aspx?cId=00000000-0000-0000-0000-000000000000&id=%7b00000000-0000-0000-0000-000000000000%7d&orgname=00000000-0000-0000-0000-000000000000&userid=%7b00000000-0000-0000-0000-000000000000%7d&type=contact&token=Zf7Hi3PFokqRn3RnTD6hPA

Jared
  • 48
  • 1
  • 12

1 Answers1

0

This is an interesting request that I have not encountered before...

I thought about using a URL-formatted field, and the fact that D365 by default will hyperlink lookup fields. But, with those options you'd have to write data into a field on each Contact or create an entire new record for each Contact, on the fly.

What about creating a separate web resource that contains a table with only one column to hold the dynamically generated URL's? Run the same query as the view to get the Contacts, then generate the URL's and populate them into that "mini-grid". Put the main Contacts view in one section (say two-columns wide), and the mini-grid web resource in a single-column section right next to it, with no border and the same row height.

This way you rely on the main Contact grid for the Contact info, with the mini-grid holding your dynamic URL's (with proper link names of course, rather than raw URL's).

The high-level steps would be:

  1. Get the user's id from the form context.
  2. OnLoad of the sub-grid, get the set of Contact Id's.
  3. Generate the URL for each Contact.
  4. Populate the URL's into the mini-grid in the same order as the Contacts in the sub-grid, so each row in the mini-grid lines up with its Contact row to the left.

Another idea would be to look into the custom icon functionality in V9 to see if there are any hooks in there where you can add a dynamic URL.

You could also write a RetrieveMultiple plugin to dynamically populate a URL-formatted text field. RetrieveMultiple plugins have their caveats. But, how bad is it?

An unsupported option might be to hack the DOM and put your dynamic URL into a blank URL-formatted field in the view.

Aron
  • 3,877
  • 3
  • 14
  • 21
  • I'm not sure I understand your first suggestion. If the mini grid holds the Dynamic URLs the URLs won't be dynamic anymore, correct? Part of the URL that I need dynamic is the userid for the user that needs to interact with the form. – Jared Feb 06 '19 at 21:03
  • Your second solution, as far as I can tell, doesn't allow for you to actually click on the image. It just displays differently depending on the value in the referenced field. Do you know if you can somehow build in the functionality to click on it? – Jared Feb 06 '19 at 21:07
  • Re: the mini-grid suggestion... I added the proposed high-level steps to the answer. Let me know if that helps. – Aron Feb 07 '19 at 03:50
  • Re: the custom icons... I'm not sure if there's a supported way to add onClick functionality to them. You might be able to hack the DOM to achieve it in an unsupported way (of course at your own risk). – Aron Feb 07 '19 at 03:51
  • I'm trying to go the route of using an icon. I'll only use 1 icon obviously and will figure out if it's clickable, but in order for this to work I'll need to get the GUID for each record in the view. Do you know how I'd go about doing that? – Jared Feb 12 '19 at 17:33
  • I believe it is GridRowData. Please see:https://learn.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/grids#methods – Aron Feb 12 '19 at 18:57