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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

auto mapping value of the lookup field to single line of text

(0) ShareShare
ReportReport
Posted on by 224

Hi guys is there a way that a lookup field value map automatically to a single line of text field without using JS? i tried the business rules but when i set the condition that if  the lookup field contains data and on the action part to map the data to a single line of text this (single line of text) field not available on the action and that field is the default NAME field on the form. and also i tried the workflow and also is not working. my goal is i want the value on the NAME field (single line of text) so that it will appear the value on the value on the view. or is anybody knows how to map the value of the lookup field to the name on the view?

Thanks in advance for the help

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    sandeepstw Profile Picture
    4,601 on at
    RE: auto mapping value of the lookup field to single line of text

    HI,

    You can make relationship in similar data types only.

  • KaeL Profile Picture
    224 on at
    RE: auto mapping value of the lookup field to single line of text

    Thank you so much. your awesome :)

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: auto mapping value of the lookup field to single line of text

    It will, it seems you are calling it on Save, but you need to call it on change of the field.

    Follow these setps

    1. Open form editor

    2. Double click on the lookup field

    3. Go to Events tab

    4. Click on Add under event handler and add your web resource name and method name.

    5. Save and publish your changes

    Now it will set value to text as soon as you will change value in lookup and tab out from lookup field

    I hope you have already created web resource if not please refer these steps to create web resource

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/walkthrough-write-your-first-client-script#step-2-add-your-javascript-code-in-a-script-web-resource

    Hope it will help

  • KaeL Profile Picture
    224 on at
    RE: auto mapping value of the lookup field to single line of text

    Hi Good Day, last question, is there a way that if the lookup field has a data/value and the new text field will populate right away with a data before saving on the form?

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: auto mapping value of the lookup field to single line of text

    Yes, you will code for that only, so it should something like this, you need to call this method on change of the lookup

    function OnLookupFieldChange()

    {

    if(Xrm.Page.getAttribute("lookupfieldname")!=null && Xrm.Page.getAttribute("lookupfieldname").getValue()!=null)

    {

    var lookupvalue=Xrm.Page.getAttribute("lookupfieldname").getValue()[0].name; //assuming you want to read text of the lookup

    Xrm.Page.getAttribute("your text field").setValue(lookupvalue);

    }

    }

  • KaeL Profile Picture
    224 on at
    RE: auto mapping value of the lookup field to single line of text

    Thank you so much for the information :) and btw do you have any idea that everytime the lookup field change it will automatically change also the value on the single line of text field? Thanks for the reply

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: auto mapping value of the lookup field to single line of text

    No, you have to write js code for this

    > Relationship mapping can be only applied to the similary data type fields

    > While try to set/map value in business rule/workflow it follow the same, only

    So you have to write javascript for this.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans