Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How to get territory id in the form of related entity?

(0) ShareShare
ReportReport
Posted on by 96

I have a custom entity as a related of Territory entity. In a new create form of that custom entity, I want to retrieve it's parent (territory) id. In edit mode I can get through url but for create mode it doesn't exist as a query string.

I want to retrieve that territory id using javascript client api.

Need your valuable suggestion.

  • S. Hossain Profile Picture
    96 on at
    RE: How to get territory id in the form of related entity?

    Do you think I can get the lokup field without save the form?

  • Verified answer
    Marco.P Profile Picture
    2,405 on at
    RE: How to get territory id in the form of related entity?

    Hi,

    Refer to this for getting and setting lookup values trough JavaScript:

    www.magnetismsolutions.com/.../how-to-get-and-set-a-lookup-field-using-javascript-in-dynamics-365

    If you need to get the id of the current new record, then you First need saving the record.

    Try something like this:

    Xrm.Page.data.save().then(function(){

    var id = Xrm.Page.data.entity.getId();

    }, function(){

    //handle error here

    });

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106 Most Valuable Professional

#3
Eugen Podkorytov Profile Picture

Eugen Podkorytov 102

Overall leaderboard

Product updates

Dynamics 365 release plans