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 CRM (Archived)

alert.js html webresourse get current record id

(0) ShareShare
ReportReport
Posted on by 7

I have alert js that opens html web resource with fetched table data. My fetch works with current record id, which I can't get inside html.

Here is my html :

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

var fetchInv = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">';
fetchInv += '<entity name="hms_invoice">';
fetchInv += '<attribute name="hms_customer" />';
fetchInv += '<attribute name="hms_pricelist" />';
fetchInv += '<filter type="and">';
fetchInv += '<condition attribute="hms_invoiceid" operator="eq" value="'+invoiceId+'" />';
fetchInv += '</filter>';
fetchInv += '</entity>';
fetchInv += '</fetch>';

var invoices = XrmServiceToolkit.Soap.Fetch(fetchInv);

Neigther window.parent, nor window.top.opener.parent. , etc, does work. 

Any thoughts? 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at

    Hi Hasmik,

    Try with below syntax in case if your html page is not embedded with CRM(Popup window)

    window.top.opener.Xrm.Page.data.entity.getId();

    It should work

  • Kunal Sharma 2019 Profile Picture
    on at

    you can pass the GUID from the parent page when you are opening the web Resource as part of the data Xrm.Navigation.openWebResource(webResourceName,windowOptions,data)

  • Dilip Kumar - CRM Profile Picture
    67 on at

    You can pass the id through the query string. You have to choose the HTML web resource on the URL Command action and select true on the Pass Parameters.

     id1.png

     

    Then you can get the record GUID from the querystring.

    var recordId = $.urlParam("id");

    id2.png

  • Hasmik Mnatsakanyan Profile Picture
    7 on at

    this also doesn't work, I can't access because its alert.js

  • Saad Kabarousse Profile Picture
    734 on at

    Hello Hasmik,

    did you add this tag in the above of your script?

     <script src="ClientGlobalContext.js.aspx" type="text/javascript" ></script>

  • Hasmik Mnatsakanyan Profile Picture
    7 on at

    I've got the record ID in alert javascript file which opens web resource, but how can I use it inside web resource? how to call it there?

  • Hasmik Mnatsakanyan Profile Picture
    7 on at

    Hi)

    Yes I added Client Global and Fetch libraries

  • Hasmik Mnatsakanyan Profile Picture
    7 on at

    Hello everyone!

    I found the answer.

    The right solution is to use :

    var crmWindow = parent.Alert.getCrmWindow();

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

    This works also for getting other types of data.

    Thanks for your suggestions!

  • Kunal Sharma 2019 Profile Picture
    on at

    this function is not supported and will not work in UCI (the new interface ) you should pass the value to web resource using Xrm.Navigation.openWebResource(webResourceName,windowOptions,data) or query string

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans