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

Dynamically set a lookup value from javascript

$
0
0

I am trying to dynamically change the lookup value in a  field on a form after a user does something. When a user presses a button on a ribbon something happens and then the form updates with the person who last did something.

So on the form I have a field which is a lookup to system user. That field is set to readonly. In my Javascript when the code has completed I run the following code;

			// Change the current engineer
			var lookup = new Array();
			lookup[0] = new Object();
			var user = Xrm.Page.context.getUserId();
			//user = user.substring(1,37);
			lookup[0].id = user;
			lookup[0].entityType = 'systemuser’';
			lookup[0].name = 'someone';
			Xrm.Page.getAttribute("new_servicemodule_engineer").setValue(lookup);

Except that it doesn't work. It certainly tries to change something but it's not displaying as the selected user it comes up as a blank. If I add a value for name that appears as a display name but isn't linked to the user as a normal user lookup box would be. So what am I missing here? In normal HTML this is just a select element and should be easy to set, what does CRM want?



Viewing all articles
Browse latest Browse all 8223

Trending Articles



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