web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Add a field of Account form in Case Form

(0) ShareShare
ReportReport
Posted on by 958

Hi All,

I have a custom field "Location Code" on the Account and Case Form.

I am making a case record from account form and i want the same value of "Location Code" field of account to the newly made case record.

Like, Value of location code is "Sample-1234" on the account form then value of its related case should be the same.

Please suggest for the same.  

*This post is locked for comments

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

    Hi Shakti,

    I believe you can use OOB functionality (mapping fields in relationship) to populate values on case

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Shakti,

    In addition ,

    Is there any specific reason you have created two different field ?

    If you want to display same value of the custom field  with the selected Account  , the better way to implement Quick View Form in the Case form , you dont need to do additional  sync for the same value.

    In addition if you still want to use the case field with the same Account field  then you can create workflow to update with same value.

  • Shakti Singh Rajput Profile Picture
    958 on at

    Yes, I want to add that field within the header section of the case form.

    Below is the code which i used and i am able to get the value but no able to setValue.

    So, Is there any need to make relationship first?

    If yes then suggest me.

    function getValues()

    {

    var contactId;

    var res;

    var lookupItem = Xrm.Page.getAttribute("customerid").getValue();

    if (lookupItem != null)

    {

    contactId = lookupItem[0].id;

    // Added new line

    res = contactId.replace("{", "").replace("}", "");

    }

    else

    {

    return;

    }

    var req = new XMLHttpRequest();

    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts("+res+")?$select=address1_city,new_orgcode,new_orglocationcode,new_teamflags", false);

    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 city = result["address1_city"];

    var orgcode = result["new_orgcode"];

    var locationcode = result["new_orglocationcode"];

    var teamflags = result["new_teamflags"];

    Xrm.Page.getAttribute("new_address1_city").setValue(city);

    Xrm.Page.getAttribute("new_orgcode").setValue(orgcode);

    Xrm.Page.getAttribute("new_orglocationcode").setValue(locationcode);

    Xrm.Page.getAttribute("new_teamflags").setValue(teamflags);

    }

    }

    };

    req.send();

    }

  • Verified answer
    Shakti Singh Rajput Profile Picture
    958 on at

    This is done.

    Thanks for help.

  • gdas Profile Picture
    50,091 Moderator on at

    Hi Shakti ,

    Please post your corrected  code and verified that answers only ,so that  in future people will get help. Otherwise there is no meaning of the verified  answers which you did   for this  thread,

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans