我想设置CRM的optionset值,属性类型为PicklistAttributeMetadata:
//Executing Status
CreateAttributeRequest executingStatusAttributeRequest =
new CreateAttributeRequest
{
EntityName = customEntityName,
Attribute = new PicklistAttributeMetadata
{
SchemaName = prefix + "executingstatus",
DisplayName = new Label("Executing Status", 1033),
OptionSet = new OptionSetMetadata
{
IsGlobal = false,
OptionSetType = OptionSetType.Picklist,
Options = {
new OptionMetadata(new Label("Draft",1033),null),
new OptionMetadata(new Label("Executing",1033),null),
new OptionMetadata(new Label("Complete (No Errors)",1033),null),
new OptionMetadata(new Label("Complete (Errors)",1033),null)
}
}
}
};
CreateAttributeResponse executingStatusAttributeResponse =
(CreateAttributeResponse)_serviceProxy.Execute(
executingStatusAttributeRequest);
如何设置值为'草稿'的'dh_executingstatus':
Entity dhEntity = new Entity(customEntityName);
dhEntity["dh_executingstatus"]=???
答案 0 :(得分:0)
您需要为每个选项创建自己唯一的整数值:
Options = {
new OptionMetadata(new Label("Draft",1033),1),
new OptionMetadata(new Label("Executing",1033),2),
new OptionMetadata(new Label("Complete (No Errors)",1033),3),
new OptionMetadata(new Label("Complete (Errors)",1033),4)
}
然后你需要发布实体。然后,在处理记录时,您可以像这样更新选项集值:
ent["dh_executingstatus"] = new OptionSetValue(2);