web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Lookup display getting refreshed after form is saved

(0) ShareShare
ReportReport
Posted on by 125

Hey guys,

I am setting the display text for several (25+) product lookup fields to a description instead of the primary field which happens to be "name" in this case. This is working great on form load and on field change. However, when the form gets saved it is refreshing those fields and not executing the form load or field change events. I tried setting the display text on form save as well which works but the field values are getting refreshed after the event has executed. Does anyone have any insight on what is happening post save that would cause these lookup field values to refresh and possible how to work around it?

An even better idea would be for Microsoft to allow us to set a Display Member property on the lookup fields so we wouldn't have to hack this.

Thanks,

David

*This post is locked for comments

I have the same question (0)
  • Aileen Gusni Profile Picture
    44,524 on at

    Hi David

    If you hack this using unsupported way or even using modify the view it would give you the trouble especially for on save.

    I think I got a problem before as well so that I revert it back again.

    Thanks

  • David Pring Profile Picture
    125 on at

    I don't think it's really an unsupported hack although sometimes we're talking about fine lines :-) I'm setting the value of the name property to description instead of the actual name value on the lookup attribute at runtime. Since the lookup uses the id anyway its just altering the interface. The issue I'm running into is the refresh of the page is defaulting it back and I'm not sure why or where this is occurring.

    Here's the code I'm using to set the lookup value. The resArray is a REST lookup to get the description for the product:

    var lookup = Xrm.Page.data.entity.attributes.get(fieldName);

    if (lookup.getValue() != null) {

    Xrm.Page.getAttribute(fieldName).setValue([{

                  id: lookup.getValue()[0].id,

                  name: resArray[0].Description,

                  entityType: "product"

          }]);

    }

  • Aileen Gusni Profile Picture
    44,524 on at

    Hi David

    Seems semi supported.

    Well it is using SDK should be well but never documentrd well to edit the display text.

    And in your case since you put it in the onload and when you save the existing record it wont trigger the onload again so that the lookup field would be back to normal behaviour (since you only hack this once onload and onsave in crm form meaning pre-event) so there is no after-save event for supported way in crm. Once you save it will revert back the normal behaviour like crm normal lookup.

    Post you can see here

    community.dynamics.com/.../136580

    Probably you might try using xrmtoolbox to copy the view using view layout replicator tool.

    One thing you need is just a view with the field : description (the field you want to use as the display text) as the first column in the view.

    So create a view that description or any field you want to put in the display of lookup in the very left column then you use the tool to copy and replicate to the lookup view

    And as well remember to backup a view from the current lookup view using replicator just in case you want to revert it back.

    I tried before it would work can change the display name bases on the selected lookup first column.

    Or another workaround is by updating view and set to custom view the lookup and put the column after the primary id field name (guid primary key). You can update the view using c# or just update using js. .of course using xrm toolbox is easier.

    Hope this helps!

    Thanks

  • David Pring Profile Picture
    125 on at

    I'm not clear on the way you're using views. I created a view specific to my products and the description is the first column however the product number (aka name field) is being returned regardless of how the columns are arranged. My view is not a lookup view, just a Public view but I did set it to be the only view the lookup field is using for lookup. What am I missing?

  • Aileen Gusni Profile Picture
    44,524 on at

    Hi David

    Of course your need a lookup view.

    This is kind of hacking the lookup view.

    Public view wont have effect.

    Now you created the public view already pls as mentioned before you use xrm toolbox view layout replicator then use it to replicate the lookup view.

    You need to modify the lookup view itself not thr public view you use as the only one view in thr form as view.

    Thanks

  • David Pring Profile Picture
    125 on at

    I've considered the lookup view mod but I'm concerned that doing this will affect other areas of the system since this is the default lookup view for Product. Do you know if you can make a duplicate of a lookup view? And point the system to use specific lookup views?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans