Hi,
Can anyone help me that how to get the id of the entity by using the javascript. As I'm using MS Dynamics CRM 2011
Thanks,
Kamyaka
*This post is locked for comments
Hi,
Can anyone help me that how to get the id of the entity by using the javascript. As I'm using MS Dynamics CRM 2011
Thanks,
Kamyaka
*This post is locked for comments
I will appreciate if you will close all of your thread, so that it can others. Thanks
Hi Mahender,
Thanks for your help. I got it.
Thanks,
Kasani
What are the parameter your web page expecting
window.open("xxxxxxxxx.html?Userid=" + retrievedUser.FullName+"&LeadID="+EntityID, "_blank");
UserId - Is this a user id (GUID) or fullname string ??
As I'm new to MS Dynamics CRM, so I'm confusing on this. Can you review my code
function Checkuser() {
var context = Xrm.Page.context;
var serverUrl = context.getServerUrl();
var UserID = context.getUserId();
var EntityID = Xrm.Page.data.entity.getId();
var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
var retrieveUserReq = new XMLHttpRequest();
retrieveUserReq.open("GET", ODataPath + "/SystemUserSet(guid'" + UserID + "')", true);
retrieveUserReq.setRequestHeader("Accept", "application/json");
retrieveUserReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
retrieveUserReq.onreadystatechange = function () {
retrieveUserReqCallBack(this);
};
retrieveUserReq.send();
}
function retrieveUserReqCallBack(retrieveUserReq) {
if (retrieveUserReq.readyState == 4 /* complete */) {
if (retrieveUserReq.status == 200) {
var retrievedUser = this.parent.JSON.parse(retrieveUserReq.responseText).d;
if (retrievedUser.FullName != null)
window.open("xxxxxxxxx.html?Userid=" + retrievedUser.FullName+"&LeadID="+EntityID, "_blank");
}
else {
alert("Error in Fetching User data");
}
}
}
You need to follow these steps
1. Get your leadid using getId only, not need to write service call for this
2. Get User full name that you are already getting with your function
so it should be like below
var EntityID = Xrm.Page.data.entity.getId();
var Fullname=GetUsername(); your custom function, also I am assuming you want to get current logged in user name, but you want to get current lead owner you can get it directly from lead form without writing service call
After that you should be able to call your custom page
As my requirement is on clicking the ribbon button on lead form it should open the window with fullname of the user and leadid of the particular lead which I have selected..
Now I'm getting the fullname of user and unable to retrieve the leadid
I still don't understand if you are in lead form itself why you want to open the same form again using ribbon button, but if this is the only requirement you can simply write below code in your function that you can calling on ribbon button
var EntityID = Xrm.Page.data.entity.getId(); //get current record id
Xrm.Utility.openEntityForm("lead",EntityID); //open lead form with record id passed
I wrote the service call because on clicking the button it should open the window with url with LeadId.
Hi Mahender,
As I'm trying to get the leadId in Url.
As I don't have any custom fileld.
Thanks,
Kamyaka
if you are in the same form you will get it using your above code
var EntityID = Xrm.Page.data.entity.getId();
why are you writing service call ??
André Arnaud de Cal... 291,711 Super User 2024 Season 2
Martin Dráb 230,458 Most Valuable Professional
nmaenpaa 101,156