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 :
Customer experience | Sales, Customer Insights,...
Unanswered

regardingobjectid is null

(0) ShareShare
ReportReport
Posted on by 20

Hi,

On the create form of an email, when coming from a case, the regardingobjectid is null.

I am using javascript to check if the user is creating an email from a case, if the regardingobject is of type case, the "to" field should be left blank. However, javascript gives an error and tell me regardingobjectid is null.

Is there any alternative to produce this functionallity?

Thank you!

KInd regards,

Gertjan

I have the same question (0)
  • Guido Preite Profile Picture
    54,086 Moderator on at

    can you share the code?

  • Gertjan Deschuytter Profile Picture
    20 on at

    This code runs on onload event

    function onLoadForm(executionContext) {

       SetReceiverFieldEmpty(executionContext)

    }

    function SetReceiverFieldEmpty(executionContext) {

      var formContext = executionContext.getFormContext();

      if (formContext.ui.getFormType() == 1 && formContext.getAttribute("regardingobjectid").getValue()[0].entityType == "incident") {

        formContext.getAttribute("to").setValue(null);

      }

    }

  • Guido Preite Profile Picture
    54,086 Moderator on at

    which exact error you are receiving? because that code should not give you an error.

    did you try to check the content (using a console.log) of the getValue before extracting the lookup info?

  • Gertjan Deschuytter Profile Picture
    20 on at

    When debugging the code within the formcontext. the attribute exists, but it just seems to be null. is there any alternative to executing this logic?

    4135.code.png

    Thanks for the help!

  • Guido Preite Profile Picture
    54,086 Moderator on at

    looks like the script is executed before the form is completely loaded (maybe because it's created started from a case?) so the code is ok (I would add a check to verify is not null before accessing [0].

    Maybe you can add a setTimeout (but you need to pay attention to allow an exit if the form is created with regardingobjectid as null) to check if the field has a value.

    hope it helps

  • Gertjan Deschuytter Profile Picture
    20 on at

    For some odd reason, after clearing cache once again and refreshing the form, it is no longer giving me the error. Thank you for the help!

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 > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 192 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 129

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans