2017-05-25 51 views
1

如果這是一個愚蠢的問題,我很抱歉,但我是NetSuite的新手,並且已經注意到他們的文檔是絕對令人恐怖和令人厭惡的。儘管如此,所有的幽默和苦澀,我找不到應該存在於SuiteAnswers中的細節。我可以找到字段或記錄類型,但它不會顯示這些類型可用的選項。它只是顯示調用哪些方法來返回一個字段或記錄。基於複選框的NetSuite SuiteScript 2.0禁用字段

所以我把它放在fieldChanged事件上,就像培訓指定的一樣,下面是我所擁有的。

function fieldChanged(context) { 
     debugger; 
     var customer = context.currentRecord 

     if (context.fieldId == 'custentity_apply_coupon') { 
      var field = record.getField("custentity_apply_coupon"); 
      if (record.getValue("custentity_apply_coupon") == true) { 
       reord.getField("custentity_coupon_code").isDisabled = false; 

      } 
      else{ 
       reord.getField("custentity_coupon_code").isDisabled = true; 
      } 
      field.isDisabled = false; 
     } 
    } 

回答

2

事實證明,我從來沒有發現這個文檔中,一旦你從currentRecord.currentRecord拿到場,你可以通過它設置field.isDisabled爲禁用。永遠讓我發現isDisabled是領域的一個屬性,然後進行了完整的猜測,看看isDisabled是ClientSide腳本的get/set調用。以下是最終工作的代碼。

function fieldChanged(scriptContext) { 
    var customer = scriptContext.currentRecord; 

    if(scriptContext.fieldId == "custentity_sdr_apply_coupon"){ 
     debugger; 
     var field = customer.getField("custentity_sdr_coupon_code"); 

     field.isDisabled = !customer.getValue(scriptContext.fieldId); 
     if(field.isDisabled){ 
      customer.setValue(field.id, ""); 
     } 
    } 
} 
+0

您是如何在複選框上附加事件的? – fiberOptics

+0

這是一個腳本2.0,所以NetSuite已經處理了。我只是檢查是否選中或未選中的字段是複選框 – Godrules500

相關問題