Revision: 62409
Updated Code
at February 21, 2013 08:00 by chetkloss
Updated Code
if (typeof (CLKLookup) == "undefined") { CLKLookup = { __namespace: true }; } CLKLookup.Utility = {     GetSetLookup: function () {         //Get a lookup value             var lookupItem = new Array();         lookupItem = Xrm.Page.getAttribute("yourAttributeSchemaName").getValue();         if (lookupItem[0] != null) {             var name = lookupItem[0].name;             var guid = lookupItem[0].id;             var entType = lookupItem[0].entityType;         }         //Set a lookup value            var value = new Array();         value[0] = new Object();         value[0].id = idValue;         value[0].name = textValue;         value[0].entityType = typeValue;         Xrm.Page.getAttribute("yourAttributeSchemaName").setValue(value);         //or alternatively you can set it like this           Xrm.Page.getAttribute("yourAttributeSchemaName").setValue( [{id: idValue, name: textValue, entityType: typeValue}]);     },     __namespace: true };
Revision: 62408
Updated Code
at February 21, 2013 07:59 by chetkloss
Updated Code
if (typeof (CLKLookup) == "undefined") { CLKLookup = { __namespace: true }; } CLKLookup.Utility = {     GetSetLookup: function () {         //Get a lookup value             var lookupItem = new Array();         lookupItem = Xrm.Page.getAttribute("yourAttributeSchemaName").getValue();         if (lookupItem[0] != null) {             var name = lookupItem[0].name;             var guid = lookupItem[0].id;             var entType = lookupItem[0].entityType;         }         //Set a lookup value            var value = new Array();         value[0] = new Object();         value[0].id = idValue;         value[0].name = textValue;         value[0].entityType = typeValue;         Xrm.Page.getAttribute("yourAttributeSchemaName").setValue(value);         //or alternatively you can set it like this           Xrm.Page.getAttribute("yourAttributeSchemaName").setValue( [{id: idValue, name: textValue, entityType: typeValue}]);     },     __namespace: true };
Revision: 62407
Updated Code
at February 21, 2013 07:57 by chetkloss
Updated Code
if (typeof (CLKLookup) == "undefined") { CLKLookup = { __namespace: true }; } CLKLookup.Utility = {     GetSetLookup: function () {         //Get a lookup value             var lookupItem = new Array();         lookupItem = Xrm.Page.getAttribute("yourAttributeSchemaName").getValue();         if (lookupItem[0] != null) {             var name = lookupItem[0].name;             var guid = lookupItem[0].id;             var entType = lookupItem[0].entityType;         }         //Set a lookup value            var value = new Array();         value[0] = new Object();         value[0].id = idValue;         value[0].name = textValue;         value[0].entityType = typeValue;         Xrm.Page.getAttribute("yourAttributeSchemaName").setValue(value);         //or alternatively you can set it like this           Xrm.Page.getAttribute("yourAttributeSchemaName").setValue( [{id: idValue, name: textValue, entityType: typeValue}]);     },     __namespace: true };
Revision: 62406
Updated Code
at February 21, 2013 07:04 by chetkloss
Updated Code
function GetLookup(lookup) { var msg = ""; var lookupItem = new Array(); lookupItem = Xrm.Page.getAttribute(lookup).getValue(); if (lookupItem != null) { var name = lookupItem[0].name; var guid = lookupItem[0].id; var entType = lookupItem[0].entityType; msg = name; } return(msg); } //Below function is an example of using the Lookup Function function SetName() { //First lookup field var lu1 = GetLookup('new_rbgid'); //Second lookup field var lu2 = GetLookup('new_rempid'); if (lu1 != null && lu2 != null){ //Set the name field Xrm.Page.getAttribute("new_name").setValue("First Part " + lu1 + " Second Part " + lu2 + " the end."); } }
Revision: 62405
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 21, 2013 07:02 by chetkloss
Initial Code
function GetLookup(lookup) { var msg = ""; var lookupItem = new Array(); lookupItem = Xrm.Page.getAttribute(lookup).getValue(); if (lookupItem != null) { var name = lookupItem[0].name; var guid = lookupItem[0].id; var entType = lookupItem[0].entityType; msg = name; } return(msg); } function SetName() { //First lookup field var lu1 = GetLookup('new_rbgid'); //Second lookup field var lu2 = GetLookup('new_rempid'); if (lu1 != null && lu2 != null){ //Set the name field Xrm.Page.getAttribute("new_name").setValue("First Part " + lu1 + " Second Part " + lu2 + " the end."); } }
Initial URL
Initial Description
Code returns text value of lookup field
Initial Title
Dynamics CRM - Get or Set Values Lookup Field Values
Initial Tags
Initial Language
JavaScript