1

I'm using CRM 2013, I'm writing a JavaScript to check if there is any 'Queue' type entity in the email participants list.

I'm stuck on the part, where I have to write the script to check for this Queue data type.

The MSDN article suggested to use Xrm.Page.data.entity.getEntityName(), however I'm not sure if it works if I plug-in the entity name in there like:

toParty[indxAttendees].getEntityName()

Appreciate your help.

function deleteSenderQueueFromEmail() {
  var formType = Xrm.Page.ui.getFormType();

  if (formType == 1 || formType == 2) {

    var toParty = Xrm.Page.getAttribute("to").getValue();
    var ccParty = Xrm.Page.getAttribute("cc").getValue();
    var bcParty = Xrm.Page.getAttribute("bcc").getValue();


    for (var indxAttendees = 0; indxAttendees < toParty.length; indxAttendees++) {

      if (toParty[indxAttendees].getEntityName() == "queue") {
        //delete the queue from the list of participants
      }
    }
  }
}
1
  • What does it record when you log "toParty[indxAttendees].getEntityName()" into the console? Commented Jan 25, 2016 at 21:41

1 Answer 1

4

Xrm.Page.data.entity.getEntityName() gets the logical name of the entity that is displayed on the form. On an e-mail form this will always be "email".

The lookup values you are looking for are in arrays that are part of the To/Cc/Bcc fields. A lookup value is an object with id, entityType and name property.

I would suggest a function accepting a party list parameter.

function deleteSenderQueue(partyList) {
    if (partyList == null) {
        return;
    }

    partyList.forEach(function(party) {
        if (party.entityType === "queue") {
            // Delete the queue from the list of participants.
        }
    });
}

This function can be used like this:

deleteSenderQueue(Xrm.Page.getAttribute("to").getValue());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.