Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to set entityreference to partylist field?

Posted on by Microsoft Employee

Hi all, 

I am trying to set an entityreference to a partylist field. Till now its only possible for me to set a string as reference to an account, but i want to fill the field with the account name. 

This is my code: 

var parameters = {};
var partylist = Xrm.Page.getAttribute("to");  // "to" is the name of the partylist field 
var partlist = new Array();
partlist[0] = new Object();
partlist[0].id = "982D83BD-2FBA-E711-8119-5065F38BF4D1";
partlist[0].name = "TESTNAME" // here i want to set the name of the account, wich i want to reference to. 
partlist[0].entityType = "account";

parameters["phonenumber"] = "0843148191";
parameters["to"] = partylist.setValue(partlist);

var windowOptions = { openInNewWindow: true };


function openNewPhoneCall() {

debugger;

Xrm.Utility.openEntityForm("phonecall", null, parameters, windowOptions);

}

The reference to the current account with the GUID (982D83BD-2FBA-E711-8119-5065F38BF4D1) is working, but i want to fill the partylist field with the name of the account.


Hopefully there is someone who understands my requirement and can help me.

Thanks for the help. 

*This post is locked for comments

  • RE: How to set entityreference to partylist field?

    So how did you solve this, Max?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set entityreference to partylist field?

    Hi Maxi_Bergbauer,

    if you solved the problem thanks to an answer, please mark it as verified to encourage the community to provide more and more a better support. Thank you. Francesco

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set entityreference to partylist field?

    Hi Maxi_Bergbauer,

    if you solved the problem thanks to an answer, please mark it as verified to encourage the community to provide more and more a better support. Thank you. Francesco

    If you found the answer helpful, please mark as Verified 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set entityreference to partylist field?

    I solved it thanks =)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set entityreference to partylist field?

    Have you solved the problem?

    Please, let us know.

    If you found the answer helpful, please mark as Verified 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

    Xrm.Utility.openEntityForm("phonecall", null, partylistarray, windowOptions);

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set entityreference to partylist field?

    The following line of code is wrong:

    Xrm.Utility.openEntityForm("phonecall", null, partylistarray, windowOptions);

    You are trying to open a phonecall passing partylist as third parameter ... if you check openEntityForm reference you will see that is not correct:

    https://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenEntityForm 

    A right call will be:

    Xrm.Utility.openEntityForm("phonecall", phoncallid, null, windowOptions);

    Please, let me know.

    If you found the answer helpful, please mark as Verified 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set entityreference to partylist field?

    ERRORMESSAGE:  Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #94EEB34EDetail:

    <OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance&quot; xmlns="schemas.microsoft.com/.../Contracts&quot;>

     <ActivityId>de25fac6-18c2-4f22-85bf-758ef43c8746</ActivityId>

     <ErrorCode>-2147220970</ErrorCode>

     <ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic&quot; />

     <Message>System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #94EEB34E</Message>

     <Timestamp>2017-10-27T10:42:26.2439255Z</Timestamp>

     <ExceptionRetriable>false</ExceptionRetriable>

     <ExceptionSource i:nil="true" />

     <InnerFault>

       <ActivityId>de25fac6-18c2-4f22-85bf-758ef43c8746</ActivityId>

       <ErrorCode>-2147220970</ErrorCode>

       <ErrorDetails xmlns:d3p1="schemas.datacontract.org/.../System.Collections.Generic&quot; />

       <Message>System.InvalidOperationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #9A4C7772</Message>

       <Timestamp>2017-10-27T10:42:26.2439255Z</Timestamp>

       <ExceptionRetriable>false</ExceptionRetriable>

       <ExceptionSource i:nil="true" />

       <InnerFault i:nil="true" />

       <OriginalException i:nil="true" />

       <TraceText i:nil="true" />

     </InnerFault>

     <OriginalException i:nil="true" />

     <TraceText i:nil="true" />

    </OrganizationServiceFault>

    CODE:

    var partylistarray = []; // new array

    partylistarray[0] = {}; // new object

    partylistarray[0].id = "982D83BD-2FBA-E711-8119-5065F38BF4D1";

    partylistarray[0].name = "TESTNAME";

    partylistarray[0].entityType = "account";

    Xrm.Page.getAttribute("to").setValue(partylistarray);

    var windowOptions = { openInNewWindow: true };

    function openNewPhoneCall() {

       debugger;

       Xrm.Utility.openEntityForm("phonecall", null, partylistarray, windowOptions);

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set entityreference to partylist field?

    Could you post the sceenshot view the detail?

    Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set entityreference to partylist field?

    Thank you for your quick reponse, but that doesent solve the problem.

    But really thank you.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to set entityreference to partylist field?

    Try with the following code:

    var partylistarray = []; // new array
    partylistarray[0] = {}; // new object
    partylistarray[0].id = "982D83BD-2FBA-E711-8119-5065F38BF4D1";
    partylistarray[0].name = "TESTNAME";
    partylistarray[0].entityType = "account";
    Xrm.Page.getAttribute("partylistattribute").setValue(partylistarray);

    After saving page you should view account name.

    Please, let me know.

    If you found the answer helpful, please mark as Verified 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans