Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

document.getElementbyId when control is set to "not visible"

Posted on by 1,575

Sorry if it is a newbie question, but does document.getElementbyId not work if the control's attribute is set to "hidden" (CRM form textfield with "visible by default= no")

I am trying to use a dummy field ("new_place_holder") as a reference point to insert a button (unsupported, I know). It is below a subgrid and rather than waiting and checking that the subgrid had properly loaded I thought a workaround would be to use a dummy field as a placeholder (knowing it would be accesible before the subgrid).

My code is:

var placetoinsert =  document.getElementById('new_place_holder');

insertAfterField.parentElement.insertBefore(my_new_button, var placetoinsert);

This works when the field 'new_place_holder' is set to "visible" on the form, but as it is just a referencing anchor I do not want it to be visible. As soon as I set it to visible=no it does not work. If indeed document.getElementbyId does not work if the control's attribute is set to "hidden", is there any other function/way of referencing a field for this purpose, which might work when the field is invisible?

I hope this makes sense.

Many thanks,

- Seamus

 

*This post is locked for comments

  • Seamus Profile Picture
    Seamus 1,575 on at
    RE: document.getElementbyId when control is set to "not visible"

    Thanks very much Aric - that makes sense - and it works!

  • Verified answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: document.getElementbyId when control is set to "not visible"

    Hi Seamus,

    As you are already aware that this is unsupported, I am not going to repeat that...

    You can try instead of using the control that you are setting to hidden, using a particular section. Check for the name of the section on the form, and see if you can insert your button before the end of the section.

    Hope this helps.

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans