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 365 | Integration, Dataverse...
Suggested Answer

Javascript on Case form - Set null value on subject field

(2) ShareShare
ReportReport
Posted on by 6
Hello,
When I use a javascript to set null value on subject field on case form, the "id" value of field is set correctly to null, but the text in field remain populated and not return to blank value.
So for the user, seems that the subject is setting, even if the subject is null, and effectively, when the user try to save the record, the system rise an error for mandatory field subject.
There is a way to reset to empty string the field "subject" when I use formContext.getAttribute("subjectid").setValue(null) to null?
In the attachment, the value of my "subject" field after formContext.getAttribute("subjectid").setValue(null) instruction.
Thanks in advance
Gianluca
Subjectnullvalue.png
Categories:
I have the same question (0)
  • Suggested answer
    Inogic Profile Picture
    715 on at
    Hi,
    The lookup value of the Subject field (its ID, entity type, and name) is cleared correctly, but the control UI is not refreshed immediately. As a result, the old subject text still appears on the form even though the underlying value is null. This creates confusion for the user, since the field looks populated until they try to save, at which point Dynamics throws an error because Subject is a mandatory field.


    To resolve this, you need to clear both the attribute value and the control display value. You can do this with:
    formContext.getAttribute("subjectid").setValue(null);
    formContext.getControl("subjectid").setValue(null);

    This ensures the Subject field is fully cleared—both the backend value and what the user sees on the form.
     
    Hope this helps.
     
    Thanks!
    Inogic

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 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 51

#2
Martin Dráb Profile Picture

Martin Dráb 39 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 26 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans