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)

Javascript Code does NOT Work

(0) ShareShare
ReportReport
Posted on by

Hi, I have 2 issues in CRM 2016.

The first, is that this code, runs bot doesn't  update the screen:

var value = new Array();
value[0] = new Object();
value[0].id = Xid;
value[0].name = name;
value[0].entityType = "matter";
Xrm.Page.getAttribute("dxc_division").setValue(value)

it doesn't produce any errors, just runs but the field is NOT updated on the screen. Any help?

The second, is that I need code to get a value from a previous form. This code, worked on a Quick Create From but I cannot get it to work on a regular form. 

var caseType =  window.parent.frames[0].Xrm.Page.getAttribute("es_casetypelookup").getValue();

I've looked and tried ALL the posts I can find all over the internet, to no avail.

Any suggestions? All help will be appreciated. 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi,

    For your first question , your code is correct , you just need to check following -

    value[0].id = Xid;  // Make sure you are assigning GUID without "{}"

    value[0].entityType = "matter"; // Make sure you are providing correct entitytype (with publisher name )

    I am sorry, have some doubt on your second question , why you are using "window.parent.frames[0]" if its regular form? , if its regular form and the field is exists in the form its should work writing only  Xrm.Page.getAttribute("es_casetypelookup").getValue();

     

     

  • Community Member Profile Picture
    on at

    Ok. first, thanks for your reply.

    on the first one., Will try the GUID without "{}".  also, can you send me an example of how an entitytype with publisher name looks like? I don't think I have ever seen one.

    on the second it is because I am trying to get a value from the PREVIOUS (ergo "Parent") form.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    I can see you have used publisher name in your field name(dxc_) as well.

    Xrm.Page.getAttribute("dxc_division").setValue(value)

    I believe you are referencing some custom entity here , so to get the name go to settings --> Customization --> Customize the System --> Entities -->In the list find your entity and copy the Name.

    Its should be with some publisher name like here my entity is AccountCustom example then you should provide new_accountcustom where new_ is publisher name . 

    customentity.png

    Could you please post screen shot of parent and child form.

  • Community Member Profile Picture
    on at

    Sorry, I cannot post pics of the screens because of disclosure issues. But the one that worked with the "Parent" code is when the new form is a QuickCreate form. When I use a regular form the code does not work.

    var caseType =  window.parent.frames[0].Xrm.Page.getAttribute("es_casetypelookup").getValue();

    That line DOES work when the new form is the QuickCreate, but not when the new form is a "regular" one.   also on issue # 1 , the code does not work and does not produce an error, just doesn't update the field on the screen.  I took the {} out, and the entityType now has the dxc_ prefix... Thanks for all your help.

  • Suggested answer
    Adrian Begovich Profile Picture
    1,032 Moderator on at

    Hi Eduardo,

    Do you work for DXC Technology? If so message me on Skype for Business and I will look at your code.

  • Community Member Profile Picture
    on at

    Code on BOTH instances is STILL NOT WORKING. What can we do? how should we proceed?

  • sandeepstw Profile Picture
    4,601 on at

    Hi,

    Code sample does not look right, if you want to set entity reference you can take example for here

    community.dynamics.com/.../168027

  • Community Member Profile Picture
    on at

    No, sorry, the ode that you offer me has nothing to do with what I am trying to do. I am trying to set the value of a Lookup object.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Eduardo,

    May be it is a good time to learn how to troubleshoot your scripts - blogs.msdn.microsoft.com/.../debugging-custom-javascript-code-in-crm-using-browser-developer-tools

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)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans