Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Can we Set value that not appear on form with javascript ?

(0) ShareShare
ReportReport
Posted on by 195

Hi i want know, if we set value from javascript are they just for field that appear on form ? or we can set value that not appear on form too ? im using this method to run set value on javascript

Xrm.Page.getAttribute("fieldname").setValue(edc());
i don't know why im getting error message, but the data is already right . i'm setting string value. so my first assumption is maybe xrm.page only get the data that in form, so is there any special way to set value that not in form ? or maybe we can do that ? 
Thanks in advance

*This post is locked for comments

  • Keysersozeey Profile Picture
    Keysersozeey 195 on at
    RE: Can we Set value that not appear on form with javascript ?

    thanks for your answer, it works with api. so i create api request to update the value, without change the form

  • Verified answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: Can we Set value that not appear on form with javascript ?

    Hi ,

    Field should be exists in the form to set the value using javascript.

    Below line having some issue with the value , if the value is  text then it will be inside   ""  like below .

    Xrm.Page.getAttribute("fieldname").setValue(edc());

    here is the correct code -

    Xrm.Page.getAttribute("fieldname").setValue("test");

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Can we Set value that not appear on form with javascript ?

    Hi,

    The field needs to be on a form. You can hide it though. This is because JavaScript read the elements which renders in the browser, so if the field is on the form, it will render and will be accessible using JS. Even if the field is hidden, it will render has hidden but still accessible.

    The error could be because you do not have the field on the form? You could also got the error  teh way you are setting the value i.e. a methor edc() inside setvalue ( I haven't tested this though).

    We can update the field which are not form using web api but adding the field and hiding it is much more easier.

    Hope this helps.

  • Verified answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Can we Set value that not appear on form with javascript ?

    Hi,

    You can not set value of a field that is not on form.

    If you really want that then you have to use web API and update entity. But it reduce performance.

    Hence I suggest to put that particular field on form and make it invisible.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,399 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans