Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Javascript Code does NOT Work

Posted on by Microsoft Employee

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

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Javascript Code does NOT Work

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Javascript Code does NOT Work

    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.

  • sandeepstw Profile Picture
    sandeepstw 4,601 on at
    RE: Javascript Code does NOT Work

    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
    Community Member Microsoft Employee on at
    RE: Javascript Code does NOT Work

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

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: Javascript Code does NOT Work

    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
    Community Member Microsoft Employee on at
    RE: Javascript Code does NOT Work

    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
    gdas Profile Picture
    gdas 50,085 on at
    RE: Javascript Code does NOT Work

    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
    Community Member Microsoft Employee on at
    RE: Javascript Code does NOT Work

    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
    gdas 50,085 on at
    RE: Javascript Code does NOT Work

    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();

     

     

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans