开发者

How do I set a User field to a SystemUserId in JavaScript?

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]开发者_StackOverflow中文版 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).


Try getting rid of your first two lines and replacing your third with

crmForm.all.new_useridfield.DataValue = 
    [{ 
        id: systemUserIdNode,
        name: fullNameNode,
        typename: 'systemuser'
    }];

The id property may require braces, so you might have to change it to:

id: '{' + systemUserIdNode + '}'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜