Get and Set Values for Lookup (JavaScript)
Get and Set Values for Lookup (JavaScript)
Sometimes we need to get / set values for a field of type Lookup. We can do this using javascript.
*** This example I'm working with entity states.
Get Value
var lookupUF = new Array();
lookupUF = Xrm.Page.getAttribute("jd_UFDescricao").getValue();
if (lookupUF[0] != null)
{
var estado = lookupUF[0].name;
var guid = lookupUF[0].id;
var entidade = lookupUF[0].entityType;
}
Set Values
var valor = new Array();
valor[0] = new Object();
valor[0].id = '92EB0D0E-B22E-E011-9645-00155D106B02';
valor[0].name = 'Rio de Janeiro';
valor[0].entityType = 'jd_UF';
Xrm.Page.getAttribute("jd_UFDescricao").setValue(value);
Sometimes we need to get / set values for a field of type Lookup. We can do this using javascript.
*** This example I'm working with entity states.
Get Value
var lookupUF = new Array();
lookupUF = Xrm.Page.getAttribute("jd_UFDescricao").getValue();
if (lookupUF[0] != null)
{
var estado = lookupUF[0].name;
var guid = lookupUF[0].id;
var entidade = lookupUF[0].entityType;
}
Set Values
var valor = new Array();
valor[0] = new Object();
valor[0].id = '92EB0D0E-B22E-E011-9645-00155D106B02';
valor[0].name = 'Rio de Janeiro';
valor[0].entityType = 'jd_UF';
Xrm.Page.getAttribute("jd_UFDescricao").setValue(value);
Seja o primeiro a comentar 0 comentários
Postar um comentário