如何在 JavaScript 中将用户字段设置为 SystemUserId?
我正在 Microsoft 的 CRM Dynamics Online 中自定义表单,需要将字段值设置为当前用户的 ID。我有正确提取 SystemUserID 的代码,但我很难将值输入表单字段。
//Lots of XML/SOAP stuff to pull the user information
var systemUserIdNode = entityNode.selectSingleNode("q1:systemuserid");
crmForm.all.FieldForUserID.DataValue = systemUserIdNode; //Fails silently
[更新] 经过一番挖掘,我根据 SDK 中的示例更新了我的代码。现在看起来像这样:
var userIdValue = new Array();
userIdValue [0] = new LookupControlItem(systemUserIdNode, 8, fullNameNode);
crmForm.all.new_useridfield.DataValue = userIdValue ;
但是,这会导致最后一行出现错误 - “对象不支持此属性或方法”。所以我仍然很困惑(更是如此,因为示例不在 SDK 中)。
I'm customizing a form in Microsoft's CRM Dynamics Online, and need to set a field value to the current users's ID. I've got code that correctly pulls the SystemUserID, but I'm having difficulty getting the value into the form field.
//Lots of XML/SOAP stuff to pull the user information
var systemUserIdNode = entityNode.selectSingleNode("q1:systemuserid");
crmForm.all.FieldForUserID.DataValue = systemUserIdNode; //Fails silently
[Update]
After some digging, I've updated my code based on the sample in the SDK. It now looks like this:
var userIdValue = new Array();
userIdValue [0] = new LookupControlItem(systemUserIdNode, 8, fullNameNode);
crmForm.all.new_useridfield.DataValue = userIdValue ;
However, this causes an error in the last line - "Object doesn't support this property or method". So I'm still stumped (even more so, as the sample is out of the SDK).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试删除前两行并将第三行替换为
id 属性可能需要大括号,因此您可能必须将其更改为:
Try getting rid of your first two lines and replacing your third with
The id property may require braces, so you might have to change it to: