Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Display a Preview box when a record is selected

(0) ShareShare
ReportReport
Posted on by 932

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 

Record12.png

Then

record21.png

Please suggest.

*This post is locked for comments

  • RE: Display a Preview box when a record is selected

    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();
    }

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Need to Display Preview box of selected fields or association

    If I am not wrong,  this is already answered here - community.dynamics.com/.../295229

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: Need to Display Preview box of selected fields or association

    We don’t have anything OOB. But we can develop custom HTML webresource to achieve the same.

  • Need to Display Preview box of selected fields or association

    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 -

    8524.Preview.png

    So, Is it possible to do this?

  • RE: Display a Preview box when a record is selected

    Thanks man,

    Problem is solved

  • RE: Display a Preview box when a record is selected

    Please suggest.

  • RE: Display a Preview box when a record is selected

    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-

    pre3.png

    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();
    }

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Display a Preview box when a record is selected

    Could you please try to debug and let me know which line causes the issue.

  • RE: Display a Preview box when a record is selected

    Error - SeletedItem is not a function.

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Display a Preview box when a record is selected

    Updated the code , there is small mistake I have not mentioned id when I am doing replace highlighted the code .

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans