Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Update Appointment with static and custom entity field values (onclick of button)

Posted on by 65

Hi Guys,

I copied Appointment button and placed on my Custom Entity. Now onClick of Appointment button i should update appointment record with custom entity values.

I'm only getting Regarding filled populated (which is Lookup) and if i place lookup in comments then remaining fields are populating.

How to set both 

Here is my code 

function createAppontment()
{
debugger;

var windowOptions = {openInNewWindow: true};


var entityId = Xrm.Page.data.entity.getId().replace("{","").replace("}","");
var entityName = Xrm.Page.getAttribute("new_name").getValue();
var entityType = Xrm.Page.data.entity.getEntityName();

var phone = Xrm.Page.getAttribute("new_phonenumber").getValue();

var parameters = {};

//setLookUp value

parameters["regardingobjectid"] = entityId;
parameters["regardingobjectidname"] = entityName;
parameters["regardingobjecttypecode"] = entityType;


parameters["new_appointmenttype"] = "100000001";     // static values
parameters["new_source"]= "100000000";                      // static values
parameters["new_phonenumber"] = phone;                    // retrieved from custom entity

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

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Update Appointment with static and custom entity field values (onclick of button)

    Hello,

    To populate lookup you have to pass entityType to <fieldname>type parameter so it should be

    parameters["regardingobjectidtype"] = entityType;

    according to following article - https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/set-field-values-using-parameters-passed-form#BKMK_setValueLookupfields

    According to the same article you can't set regardingid field - https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/set-field-values-using-parameters-passed-form#set-values-for-lookup-fields, quoting:

    You can’t set the values for partylist or regarding lookups.

    I had task similar to yours and I found my own way - https://butenko.pro/2013/01/11/ms-crm-2011-open-new-activity-form-with-regarding-field-prefilled/

    Try to use following to populate regarding field instead:

    parameters["pId"] = entityId;

    parameters["pName"] = entityName;

    parameters["pType"] = entityType;

    Also to pass pType you should pass objecttypecode instead of entity type name. You can get it from entity metadata - docs.microsoft.com/.../getentitymetadata

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans