Tuesday, 28 July 2015

PartyList

PartyList : This is a  data type available in MS crm.
It  is almost  a lookup  that can have references to more than one records of an entity for a single field.

A partylist  has certain attributes like   name, id, type,typename etc.

To retrieve values by jscript:
 
var partylistItem = new Array;
 
//get the items/values in a field named"resources"
partylistItem  = Xrm.Page.getAttribute("resources").getValue();
 
Thus now the array  holds all the items/record  referenced for a single field
 
.
we may  have a  loop through this array  to retrieve the values like,
 
partylistItem.length - gives how many records are referenced.
partylistItem[0].id - the guid of the item.


To set values by  jscript :
To set  values we also  need to  get an  array.
var partlistset= new Array();
partlistset[0] = new Object();
partlistset[0].id = id; // provide a guid type value
partlistset[0].name = name; // provide a suitable name
partlistset[0].entityType = entityType; // provide the entity  name  of the item  ie account/ contact etc .
Xrm.Page.getAttribute("resource").setValue(partlistset);



The following table lists the activity party types that are supported for each activity, and the corresponding activity properties to specify those activity party types.

 

Activity entity name Supported activity party type Activity attribute
Appointment
OptionalAttendee
Organizer
RequiredAttendee
Appointment.OptionalAttendees
Appointment.Organizer
Appointment.RequiredAttendees
CampaignActivity
Partner
Sender
CampaignActivity.Partners
CampaignActivity.From
CampaignResponse
Customer
Partner
From
CampaignResponse.Customer
CampaignResponse.Partner
CampaignResponse.From
Email
BccRecipient
CcRecipient
Sender
ToRecipient
Email.Bcc
Email.Cc
Email.From
Email.To
Fax
Sender
ToRecipient
Fax.From
Fax.To
Letter
BccRecipient
Sender
ToRecipient
Letter.Bcc
Letter.From
Letter.To
PhoneCall
Sender
ToRecipient
PhoneCall.From
PhoneCall.To
RecurringAppointmentMaster
OptionalAttendee
Organizer
RequiredAttendee
RecurringAppointmentMaster.OptionalAttendees
RecurringAppointmentMaster.Organizer
RecurringAppointmentMaster.RequiredAttendees
ServiceAppointment
Customer
Resource
ServiceAppointment.Customers
ServiceAppointment.Resources
 

Thanks.

Wednesday, 22 July 2015

Get and Set lookup value using javascript in CRM 2011



In this article , I am going to explain how to set and get CRM lookup attribute value using javascript

Get a lookup value
var lookup = new Array();
lookup = Xrm.Page.getAttribute("attributename").getValue();
if (lookup != null) {
    var name = lookup[0].name;
    var id = lookup[0].id;
    var entityType = lookup[0].entityType;
}

Set a lookup value
var lookup = new Array();
lookup[0] = new Object();
lookup[0].id = recorid;
lookup[0].name = recordname;
lookup[0].entityType = entityname;
Xrm.Page.getAttribute("attributename").setValue(lookup);

Alternate method to set lookup value
Xrm.Page.getAttribute("attributename").setValue([{ id: recorid, name: recordname, entityType: entityname}]);