2013-12-18 44 views
0

我想更改文本字段的標籤。 它應該以黑色顯示電子郵件,然後顯示紅色星號。 頁面的代碼是這一個:在CRM 2011中使用JS更改字段的標籤顏色

<td class="ms-crm-FieldLabel-LeftAlign FormSection_CellPadding ms-crm-Field-Required" id="emailaddress1_c"> 
    <label for="emailaddress1"> 
     E-mail 
    <img class="ms-crm-ImageStrip-frm_required" alt="Required" src="/_imgs/imagestrips/transparent_spacer.gif?ver=-657574203"> 
    </label> 
</td> 

是否有可能做到這一點的CRM?

+1

您可以添加JavaScript,它觸發表單的onload並執行這些操作。然而,不通過API完成的任何操作(如您建議的操作)都不受支持,並且可能隨時將彙總或新版本應用於您的CRM環境。 –

回答

0

您可以使用jQuery這一點,但它是不支持的,而不是在所有好主意(過去的經驗!)

如果你需要有一個功能,它不僅僅是一個領域,可能更最好構建一個HTML Web資源。

尼克

0

Crm有本地支持所需的字段。

您沒有指定何時需要該字段是必需的。下面的代碼演示了 當表單加載時以及某些其他屬性需要控制需求時,需要填寫字段。

var xrmPage = Xrm.Page; 
var MyApp = MyApp || {}; 

/** 
    Bind to form onload 
*/ 
function OnCrmPageLoad() { 
    /* Create a reference to the attribute that you want to make required */ 
    MyApp.Attr1 = xrmPage.getAttribute("new_attribute1"); 
    /* Create another reference to illustrate onchange event */ 
    MyApp.SomeOtherAttr2 = xrmPage.getAttribute("new_someotherattribute"); 
    /* Call requireAttribute1 when SomeOtherAttr2 changes */ 
    MyApp.SomeOtherAttr2.addOnChange(requireAttribute1); 
    /* Call requireAttribute1 for the first time when the form loads */ 
    MyApp.requireAttribute1(); 
} 
/** 
    Make the my field required 
*/ 
MyApp.requireAttribute1 = function() { 
    MyApp.Attr1.setRequiredLevel("required"); 
} 
+0

該字段是複選框,因此無法根據需要進行設置,因爲它從不真正存儲任何值。 – MaPi