0

This function buttonBuzz() works inside the Forms of the Entities Account, Contacts and Leads. But not in the Opportunity form. Mainly because there is no telephone1 attribute. There is however a Contact entity added with "Quick View" in a section with a telephonenumber inside.

View of the Opportunity Form w/ Contact Quick View marked in red

I think it can be accessed with the telephone1 as well just not with Xrm.page

Any ideas how i can grab the attribute from inside the "quick view"?

I dont know if the "Quick view" window is a form of an iFrame. And if it is i have no clue how to access it with the Xrm.Page.getAttribute("telephone1").getValue();

function buttonBuzz(exObj) {
var phoneNumber;

// Here i store the "telephone1" Attribute from the current .page
phoneNumber = Xrm.Page.getAttribute("telephone1").getValue();

if (phoneNumber != null) {      **Sends phonenumber**           } ...
1
  • And btw the form is just filled with Dummy information. So nothing confidential is shown here of course. Commented Feb 17, 2017 at 10:29

2 Answers 2

1

Quick Views display data from a record selected in a lookup field, in this case a Contact. You can query data from related records using the OData endpoint.

You first need to get the Guid of the record selected:

var contactId = Xrm.Page.getAttribute("parentcontactid")[0].id || null;

You would then need to send a SDK.REST request, passing parameters for the Id of the record (contactId), entityName and the columns:

var entityName = "Contact";
var columns = "Address1_Telephone1, FirstName, LastName";    

SDK.REST.retrieveRecord(contactId, entityName, columns, null, function(result) {
    // Success, logic goes here.
    var address1_Telephone1 = result.Address1_Telephone1;
}, function(e) {
    console.error(e.message);
});

As well as your JavaScript file, you would need to include the SDK.REST.js file that is included in the MS CRM SDK download within your Opportunity form libraries.

Sign up to request clarification or add additional context in comments.

Comments

1

You can pull that field up from the Contact into the Opportunity by creating a Calculated Field, setting it equal to parentcontactid.telephone1

Put the field on the form, and you'll be able to .getAttribute() it like any other Opportunity field (being Calculated, it updates itself whenever the source changes).

1 Comment

Clever and, so far, it seems to work for me. [Using a QuickView for this was problematic for me because the field concerned had a form-specific OnChange event handler in its own entity which was getting invoked and failing]

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.