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 :
Service | Customer Service, Contact Center, Fie...
Answered

Save new record in Web Resource and get its Id

(0) ShareShare
ReportReport
Posted on by 76

Hello,

When I click New button and create a new record, opens a new form(Client), In that form I have web resource (type=HTML), in this web resource I need to save this record and get Id.

How can i do this ? I try to write 

window.parent.Xrm.Page.data.save();
window.parent.Xrm.Page.data.refresh();

var entityId = window.parent.Xrm.Page.data.entity.getId();

but var entityId = ""

How can I get Id ? 

Thanks.

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Marina,

    Try to get the id in the onsave event of the form. Create a new function onSave and attach it to the onsave handler of the form. At that point the record id should be ready to consume.

    Thanks

  • Verified answer
    LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner, 

    You could try my code here.

    <script>
            function myFunction() {
                window.parent.Xrm.Page.data.save().then(successCallbackerrorCallback);
                
            }
            function successCallback(){
                var entityId = window.parent.Xrm.Page.data.entity.getId();
            }
            function errorCallback(){
                alert("error")
            }
        </script>

    3343.pastedimage1570159361592v1.png

    The reason why you did not catch the recordid is that when you save&refresh the form, the "window.parent.Xrm.Page.data.entity.getId();" function could not get the latest data.

    So I add a callback function in "save" action and when the system saved the record successfully, it will return the correct record id.

    Hope it helps.

    Best Regards,

    Leo

  • Marina Karapetyan Profile Picture
    76 on at

    Hi Leo,

    It works, thank you very much!

    6644.Capture1.PNG

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 > Service | Customer Service, Contact Center, Field Service, Guides

#1
11manish Profile Picture

11manish 36

#2
Mallesh Deshapaga Profile Picture

Mallesh Deshapaga 32

#3
Goloknath Profile Picture

Goloknath 28 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans