Avatar of apollo7
apollo7Flag for United States of America

asked on 

CRM 2011 Default Lookup Values Not Connecting

I have created some javascript code to write default values to two lookups.  The correct values appear in the lookup field but do not bind to the lookup.  

The values are in the center of the lookup field and stop the form from being saved until the lookup is correctly populated using the spyglass.  

See the examples below.  The first image shows the lookups populated by JavaScript.  The second shows the lookups populated by selecting from the lookup icon.

User generated image
User generated image
I will include the javascript below
JavaScriptMicrosoft DynamicsSQL

Avatar of undefined
Last Comment
apollo7
Avatar of apollo7
apollo7
Flag of United States of America image

ASKER

The javascript that I have been using is below.  I have tried a number of variations but all produce the behavior listed above.

function FreightName() {
    var lookupValue = new Array();
    lookupValue[0] = new Object();
    lookupValue[0].id = "16F711C2-5C9C-E411-8DC3-005056897092";   // Guid Of That Look Up
    lookupValue[0].name = "Collect";                              // Name  Of That Look Up
    lookupValue[0].entityType = "csc_freightterm";                  // Entity Name Of That Look Up
    Xrm.Page.getAttribute("csc_freightterm").setValue(lookupValue);

}

function ShipName() {
    var lookupValue = new Array();
    lookupValue[0] = new Object();
    lookupValue[0].id = "1EF711C2-5C9C-E411-8DC3-005056897092";  // Guid Of That Look Up
    lookupValue[0].name = "Standard Priority";                   // Name  Of That Look Up
    lookupValue[0].entityType = "csc_shipmentpriority";                  // Entity Name Of That Look Up
    Xrm.Page.getAttribute("csc_shipmentpriority").setValue(lookupValue);
}

Open in new window

Avatar of apollo7
apollo7
Flag of United States of America image

ASKER

I am trying another function that I have used before.  I am still getting the indented value in the lookup (shown above)

function FreightName()
{
//Create an array to set as the DataValue for the lookup control.
var lookupData = new Array();
//Create an Object add to the array.
var lookupItem= new Object();
//Set the id, typename, and name properties to the object.
lookupItem.id = '{16F711C2-5C9C-E411-8DC3-005056897092}';
lookupItem.typename = 'csc_lookup';
lookupItem.name = 'Collect';
// Add the object to the array.
lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
Xrm.Page.getAttribute("csc_freightterm").setValue(lookupData);

}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of apollo7
apollo7
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo