web
You’re offline. This is a read only version of the page.
close
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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans