Hi,
Here is the code to set the party list values using java script.
Party List is a data type in CRM, using which you can set more than one records of an entity for a single field.
Part List type field, renders as Lookup on the form, but it works as multi select lookup
var partyRequired = Xrm.Page.getAttribute("to");
// Create new array
var partlist = new Array();
partlist[0] = new Object();
partlist[0].id = Id; //Guid (i.e., Guid of User or Contact etc)
partlist[0].name = "Name"; //Name (i.e., Name of User or Contact etc)
partlist[0].entityType = "systemuser"; //entity schema name of account or contact
// Set array value
partyRequired.setValue(partlist);
Hope this helps
--
Happy CRM'img
Gopinath
Here is the code to set the party list values using java script.
Party List is a data type in CRM, using which you can set more than one records of an entity for a single field.
Part List type field, renders as Lookup on the form, but it works as multi select lookup
var partyRequired = Xrm.Page.getAttribute("to");
// Create new array
var partlist = new Array();
partlist[0] = new Object();
partlist[0].id = Id; //Guid (i.e., Guid of User or Contact etc)
partlist[0].name = "Name"; //Name (i.e., Name of User or Contact etc)
partlist[0].entityType = "systemuser"; //entity schema name of account or contact
// Set array value
partyRequired.setValue(partlist);
Hope this helps
--
Happy CRM'img
Gopinath
I am facing issue on displaying icon image for phone call entity. My requirement is like when ever direction of call incoming or out going will be changed, the value of sent and receiver pastelist should be changed. I have used below code and its not working properly to display the icon image however data is swapping correctly
ReplyDeleteCode -
function SetReceipentAndSenderPartyListOnchange() {
//debugger;
if (Xrm.Page.data.entity.attributes.get("directioncode").getValue() == 1) //outgoing
{
document.getElementById("to").setAttribute("lookuptypes", "2");
document.getElementById("to").setAttribute("defaulttype", "2");
document.getElementById("to").setAttribute("lookuptypeIcons", "/_imgs/ico_16_2.gif");
document.getElementById("to").setAttribute("disableViewPicker", "1");
document.getElementById("to").setAttribute("lookupstyle", "multi");
document.getElementById("from").setAttribute("lookuptypes", "8");
document.getElementById("from").setAttribute("defaulttype", "8");
document.getElementById("from").setAttribute("lookuptypeIcons", "/_imgs/ico_16_8.gif");
document.getElementById("from").setAttribute("disableViewPicker", "1");
document.getElementById("from").setAttribute("lookupstyle", "single");
try {
if (!SwapLookups(document.getElementById("to"), document.getElementById("from"))) {
/* Unsuccessful swap-- restore the original incoming/outgoing direction. */
Xrm.Page.data.entity.attributes.get("directioncode").getValue() = !Xrm.Page.data.entity.attributes.get("directioncode").getValue();
}
}
catch (e) {
//alert("Field\u003a directioncode-Error\u003a " + e.description);
}
try {
if (!SwapLookups(document.getElementById("from"), document.getElementById("to"))) {
/* Unsuccessful swap-- restore the original incoming/outgoing direction. */
Xrm.Page.data.entity.attributes.get("directioncode").getValue() = !Xrm.Page.data.entity.attributes.get("directioncode").getValue();
}
}
catch (e) {
//alert("Field\u003a directioncode-Error\u003a " + e.description);
}
}
else if (Xrm.Page.data.entity.attributes.get("directioncode").getValue() == 0) {
debugger;
document.getElementById("from").setAttribute("lookuptypes", "2");
document.getElementById("from").setAttribute("defaulttype", "2");
document.getElementById("from").setAttribute("lookuptypeIcons", "/_imgs/ico_16_2.gif");
document.getElementById("from").setAttribute("disableViewPicker", "1");
document.getElementById("from").setAttribute("lookupstyle", "single");
document.getElementById("to").setAttribute("lookuptypes", "8");
document.getElementById("to").setAttribute("defaulttype", "8");
document.getElementById("to").setAttribute("lookuptypeIcons", "/_imgs/ico_16_8.gif");
document.getElementById("to").setAttribute("disableViewPicker", "1");
document.getElementById("to").setAttribute("lookupstyle", "single");
}
}
Thanks Gopi for this post.
ReplyDelete