Scenario is that for Account/Case entity if any record is selected then a preview screen would be appearing in the same window.
Like if i am select a record
Then
Please suggest.
*This post is locked for comments
Scenario is that for Account/Case entity if any record is selected then a preview screen would be appearing in the same window.
Like if i am select a record
Then
Please suggest.
*This post is locked for comments
I have 3 Account forms and i want to display information of selected Account.
How can i specify the account form name using webapi(CRM Rest Builder)
Code: -
function Preview(selectedItems)
{
var selectedItem = selectedItems[0];
console.log(selectedItems);
var recordid =selectedItems[0].Id.replace("{","").replace("}","");
alert(recordid);
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts("+recordid+")?$select=accountid,name,new_businessunit,new_formname,new_franchisecode,new_orgcode,new_orglocationcode", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var results = JSON.parse(this.response);
for (var i = 0; i < results.value.length; i++) {
var accountid = results.value[i]["accountid"];
var name = results.value[i]["name"];
var new_businessunit = results.value[i]["new_businessunit"];
// var new_businessunit_formatted = results.value[i]["new_businessunit@OData.Community.Display.V1.FormattedValue"];
var new_formname = results.value[i]["new_formname"];
var new_franchisecode = results.value[i]["new_franchisecode"];
var new_orgcode = results.value[i]["new_orgcode"];
var new_orglocationcode = results.value[i]["new_orglocationcode"];
}
alert("Business Unit= " +new_businessunit);
if(new_formname == Site){
alert(new_formname);
}
else if(new_formname == Organization){
alert(new_formname);
}
else if(new_formname == Account - Franchise){
alert(new_formname);
}
else{
alert(new_formname);
}
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
}
If I am not wrong, this is already answered here - community.dynamics.com/.../295229
We don’t have anything OOB. But we can develop custom HTML webresource to achieve the same.
Scenario is: - When i select a account record then it displays an modal to preview the summary information on which i have to display some other fields and association block.
For example -
So, Is it possible to do this?
Thanks man,
Problem is solved
Please suggest.
It shows that selectedItem is not a function.
I think selectedItem is not working in this code.
When i implement this code without selectItem then it will displays-
Code is-
function run(){
//var id =Xrm.Page.data.entity.getId();
//alert(id);
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts()?$select=address1_city,emailaddress1,name", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var result = JSON.parse(this.response);
var accountid = result["accountid"];
var address1_city = result["address1_city"];
// var address2_city = result["address2_city"];
var emailaddress1 = result["emailaddress1"];
var name = result["name"];
alert("AccId= " +accountid+ "\nCity= " +address1_city+ "\nEmail= " +emailaddress1+ "\nName= " +name);
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
}
Could you please try to debug and let me know which line causes the issue.
Error - SeletedItem is not a function.
Updated the code , there is small mistake I have not mentioned id when I am doing replace highlighted the code .
André Arnaud de Cal... 291,711 Super User 2024 Season 2
Martin Dráb 230,458 Most Valuable Professional
nmaenpaa 101,156