how to get selected value from a option set crm 4 dynamics 2011 online

a 夏天 提交于 2019-12-10 15:58:27

问题


This is a question related to using javascript with crm 4 2011 online

I created an optionset -status: open,closed and a onchange event handler that calls the function run with the context as parameter.

In js i tried the following and more:

function run(selectedItems)
{
    var s = selectedItems[0];
}

But i always get an undefined variable.

How can get the selected value from a optionset?

Thanks

EDIT:

i tried

function run() { 
alert("hello"); 
var texter = Xrm.Page.getAttribute("new_state_request").getSelectedOption().text; 
alert(texter); 
} 

just now. Gettin this: Error in userdefined event of this field. field:new_state_request event:onchange error:undefined


回答1:


these are the right methods with an optionset attribute, for more information visit this link:

http://msdn.microsoft.com/en-us/library/gg334409.aspx

get the text of selected option

Xrm.Page.getAttribute("fieldname").getText();

get the numeric value of selected option

Xrm.Page.getAttribute("fieldname").getValue();



回答2:


try

To Get the selected text of a OptionSet field

Xrm.Page.getAttribute("CRMFieldName").getSelectedOption().text;

To Get the selected value of a OptionSet field

Xrm.Page.getAttribute("CRMFieldName").getSelectedOption().value;


来源:https://stackoverflow.com/questions/16737209/how-to-get-selected-value-from-a-option-set-crm-4-dynamics-2011-online

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!