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)

How can i use javascript to match guids and hide field when GUID doesn't match

(0) ShareShare
ReportReport
Posted on by

On the Phone call form, there is a lookup field pointed at a custom entity named printers and that entity is connected to the Products entity.  The products entity hold the Part number, and the Printer entity is used to associate the printer's serial number to a contact.  When the user enters in the contacts name then goes to the printer field to select a serial number that is associated with that contact.  The challenge that I am facing is that we have one model printer that needs to have 2 additional fields.  I have added those 2 fields to the form, and would like to be able to hide them when the other printers are in the lookup field.  The lookup field is showing the Serial Number and the rest of the printer entity fields are being pulled over by a Quick view form.  I have the GUID of the specific product and having trouble writing the javascript that would check if the GUID match to that of record in the lookup field.  Then telling to show those two fields when the GUID match and hide when they don't.  If someone could guide me through this that would be awesome. 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at

    Hi..

    Generally when you get lookup guid using java script it will be returned with brackets

    e.g.

    var contactLookup = Xrm.Page.getAttribute("contactid").getValue();

    var contactid = contactLookup[0].id;

    to compare with any other lookup make sure you remove brackets and case of text is same (either upper case or lower case)

    var contactidwithoutBrackets = contactid.replace(/[{}]/g,"");

    another guid is suppose childContactid

    then compare like

    if(contactidwithoutBrackets.toUpperCase()==childContactid.toUpperCase())

    {

    // write your own code..

    }

    hope this will help..

  • Community Member Profile Picture
    on at

    Thanks, I will give it try.  I

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