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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

localStorage.setItem for an EntityReference, Possible?

(0) ShareShare
ReportReport
Posted on by

When user save and close a CRM form, I wish to remember the value of a field entered by user
via javascript like

localStorage.setItem("last_field", Xrm.Page.getAttribute("new_field").getValue());

But how to do the same for a lookup field as the value is now an EntityReference object?

Please advise.

Tiong

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Bas van de Sande Profile Picture
    4,383 on at

    Hi Tiong,

    actually it is the same call...

    when you do:

    Xrm.Page.getAttribute('new_invoiceperiodid').getValue()[0].id

    you get the id of the entityreference.  

    I hope this helps

    Bas

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    var id = Xrm.Page.data.entity.attributes.get('yourentitylookup').getValue()[0].id;

    var name = Xrm.Page.data.entity.attributes.get('yourentitylookup').getValue()[0].name;

    Mansoor

  • Verified answer
    Community Member Profile Picture
    on at

    I got it done via:

    localStorage.setItem("last_value", JSON.stringify(Xrm.Page.getAttribute("new_field").getValue()));

    and get back via

    Xrm.Page.getAttribute("new_field").setValue(JSON.parse(localStorage.getItem("last_value")));

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans