Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Javascript to populate lookup field crashing

$
0
0

Hi everyone,

What I have is a script for Account create/update that when the zipcode is entered it then auto-populates the sales Territory lookup.  Everything works fine and dandy; I enter the zip code, the lookup is filled, looks the same as if I were to manually select it from the list.

The problem is when I try to save the Account with the Territory that was selected and populated with Javascript I get a generic error and it doesn't let me save; if I was to manually select the Territory it does save.

Are there any known issues with populating a lookup with an entity through script?

Below is the small code section that actually adds it to the field

            var lookup = new Object();
            var lookupValue = new Array();
            //set values that will go into the lookup in the form
            lookup.id = territory;
            lookup.entityType = "territory";
            lookup.name = territoryName;
            lookupValue[0] = lookup;

            //set city and territory on the form
            Xrm.Page.getAttribute("territoryid").setValue(lookup);

Thanks


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>