web
You’re offline. This is a read only version of the page.
close
Skip to main content
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,084 Moderator on at
    RE: regardingobjectid is null

    can you share the code?

  • Gertjan Deschuytter Profile Picture
    20 on at
    RE: regardingobjectid is null

    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,084 Moderator on at
    RE: regardingobjectid is null

    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
    RE: regardingobjectid is null

    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,084 Moderator on at
    RE: regardingobjectid is null

    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
    RE: regardingobjectid is null

    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

Responsible AI policies

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

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 235

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 177

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 156 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans