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)

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

I have the same question (0)
  • Verified answer
    Dynamics365 Rocker Profile Picture
    7,755 on at

    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.

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    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
    gdas Profile Picture
    50,091 Moderator on at

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

  • Keysersozeey Profile Picture
    195 on at

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

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)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans