Hi All,
I am using the following code to fetch the name of account for specific opportunity.
1. function setAccount()
2. {
3. debugger;
4. var opportintytId = Xrm.Page.getAttribute("new_opportunity").getValue()[0].id;
5. req.open("GET", Xrm.Page.context.getClientUrl() +"/api/data/v9.1/opportunities?$select=_customerid_value&$filter=opportunityid eq ("+opportintytId+")", true);
6. req.setRequestHeader("OData-MaxVersion", "4.0");
7. req.setRequestHeader("OData-Version", "4.0");
8. req.setRequestHeader("Accept", "application/json");
9. req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
10. req.onreadystatechange = function () {
11. if (this.readyState === 4) {
12. req.onreadystatechange = null;
13. if (this.status === 200) {
14. var result = JSON.parse(this.response);
15. var account = result["=_customerid_value"];
16. }
17. else {
18. alert(this.statusText);
20. }
21. }
22. };
23. }
The code is getting executed till line 9. But after line 10 it goes out of code and not getting executed at all.
I am new to web api and not able to figure out what else is needed. Please help.
Thanks
Aparna
*This post is locked for comments
I have the same question (0)