CRM 2013 批量更新two options的缺省值

  1:  string entNames = "new_print_plan,new_radio_plan,new_bill_board,new_tv_plan,new_btl_posm,new_btl_poe_fixed,new_promotion_girls,new_promotion_events,new_digital_plan";
  2:             string fieldNames = "new_actual_is_cancel,new_is_in_plan";
  3:             foreach (string entityName in entNames.Split(','))
  4:             {
  5:                 foreach (string fieldName in fieldNames.Split(','))
  6:                 {
  7: 
  8:                     RetrieveAttributeRequest rar = new RetrieveAttributeRequest()
  9:                     {
 10:                         EntityLogicalName = entityName,
 11:                         LogicalName = fieldName
 12:                     };
 13: 
 14:                     var am = (RetrieveAttributeResponse)service.Execute(rar);
 15:                     if (am.AttributeMetadata.AttributeType == AttributeTypeCode.Boolean)
 16:                     {
 17:                         var bam = am.AttributeMetadata as BooleanAttributeMetadata;
 18:                         bam.DefaultValue = true;
 19: 
 20:                         UpdateAttributeRequest uar = new UpdateAttributeRequest()
 21:                         {
 22:                             EntityName = entityName,
 23:                             Attribute = bam
 24:                         };
 25: 
 26:                         service.Execute(uar);
 27:                     }
 28:                 }
posted @ 2014-09-03 18:38  疯吻IT  阅读(570)  评论(0编辑  收藏  举报