How to add phone number into phone call Quick create form.
How to add phone number into phone call Quick create form.
Hi,
Thanks for the response. Do you have any sample code?
Hi,
Thaks for the response.
You can write JS and pass the phone number
Hi,
From which contact phone number field do you want to populate the phone number field?
The field can be populated when creating the phone call or when loading it with JS.
- Creating (from contact)
With Xrm.Navigation.openForm(), you can open a quick create form and set the phonenumber from the contact.
Example:
Xrm.Navigation.openForm( { entityName: "phonecall", useQuickCreateForm: true, createFromEntity: { entityType: "contact", id: "00000000-0000-0000-0000-000000000000" } }, { phoneNumber: "555 555 5555" } );
- Loading
You can set the phonenumber by doing a request to WebApi with Xrm.WebApi.retrieveRecord(), then set the field value.
Example:
async function onFormLoad(execCtx) { const formCtx = execCtx.getFormContext(); const toAttr = formCtx.getAttribute("to"); const toLookupValue = toAttr.getValue(); if (toLookupValue == null) { Xrm.Navigation.openAlert({ text: "To field not set" }); return; } if (toLookupValue[0].entityType !== "contact") { Xrm.Navigation.openAlert({ text: "To is not a contact" }); return; } const contactId = toLookupValue[0].id; const result = await Xrm.WebApi.retrieveRecord("contact", contactId, "?$select=telephone1"); const telephone = result.telephone1; formCtx.getAttribute("phonenumber").setValue(telephone); }
Hi,
Thank you for the response. Let me explain the scenario. When trying to create a phone call activity to the customer using the Phone Call Quick Create form the Phone Number does not display on the Phone Number field. So I want to display the Phone number on the Contact card in Phone Call Quick Crete Form.
Hi,
You can follow this article : learn.microsoft.com/.../create-edit-quick-create-forms