2017-02-07 1 views
0

当社のnetsuite環境でsuitscript 2.0スクリプトを作成しました。 RESTletを使用してアクセスしています。Suitcript 2.0設定クーポンとパートナーコード

このスクリプトは、さまざまなフィールドを含む受注を作成します。それは正常に動作しますが、クーポンコード値またはパートナーコードを設定できません。両方に対して同じエラーが発生します。内部IDを使用しており、クーポンコード自体も試しました。

エラー:

{ 
    "type":"error.SuiteScriptError", 
    "name":"INVALID_FLD_VALUE", 
    "message":"You have entered an Invalid Field Value 18 for the following field: couponcode", 
    "stack":[ 
     "<anonymous>(N/record/recordService.js)", 
     "setSalesOrderData(adhoc$-1$debugger.user:71)", 
     "saveSaleOrder(adhoc$-1$debugger.user:17)", 
     "<anonymous>(adhoc$-1$debugger.user:107)", 
     "<anonymous>(adhoc$-1$debugger.user:6)" 
     ], 
    "cause":{ 
     "type":"internal error", 
     "code":"INVALID_FLD_VALUE", 
     "details":"You have entered an Invalid Field Value 18 for the following field: couponcode", 
     "userEvent":null, 
     "stackTrace":[ 
      "<anonymous>(N/record/recordService.js)", 
      "setSalesOrderData(adhoc$-1$debugger.user:71)", 
      "saveSaleOrder(adhoc$-1$debugger.user:17)", 
      "<anonymous>(adhoc$-1$debugger.user:107)", 
      "<anonymous>(adhoc$-1$debugger.user:6)" 
     ], 
     "notifyOff":false},"id":"","notifyOff":false 
    } 
} 

のRestletコード:

var objRecord = record.create({ 
    type: record.Type.SALES_ORDER, 
    isDynamic: true 
}); 

/* add other values.....*/ 

objRecord.setValue({ fieldId: 'couponcode', value: 538 }); 

var recordId = objRecord.save({ 
    enableSourcing: false, 
    ignoreMandatoryFields: false 
}); 

答えて

1

あなたは1回の使用コードを設定しようとしているこれらのクーポンコードはありますか?または、プロモーションにリンクしていますか?

couponcodeフィールドには、どの内部IDが使用されていますか?

RESTletコードの関連部分も共有できますか?

私は受注のコンソールで、次の(つまり、クライアントスクリプト)をテストし、適切に推進してクーポンコードを設定しているようだ:1は、内部のIDで

require(["N/currentRecord"], function(c) { 
    c.get().setValue({ 
     "fieldId": "couponcode", 
     "value": 1 
    }); 
}); 

プロモーションプロモーションに関連付けられていない内部IDを使用するとエラーは発生しませんが、いずれのフィールドにも何も入力されません。

+0

を... –

+0

こんにちは、私たちの問題でsuitescript2のサポートを見て時間を割いてくれてありがとう@erictgrubaugh。 0は来るのが難しいです。プロモーション内部IDを使用してマルチユースクーポン(このクーポンの内部IDを取得するにはどうすればよいですか)と、クーポンの内部IDを持つシングルユースクーポンを試しました。それでも同じエラーが発生します。 SOを作成するときにコードを適用しようとしているため、N /レコードを使用しています。 –

+0

var objRecord = record.create({ タイプ:record.Type.SALES_ORDER、 isDynamic:true }); /*他の値を追加する..... */ objRecord。setValue({ fieldId: 'couponcode'、 値:538 }); var recordId = objRecord.save({ enableSourcing:false、 ignoreMandatoryFields:false }); –

0

私たちは最終的にNetsuiteサポートから作業コードを得ました。このトピックはオンラインでこのような小さなヘルプがあるので、私はここでそれを共有しています。我々は我々自身のスクリプトに必要なものをつかんだが、この基本的なものは、同様に動作しますが、NetSuiteのサポートエージェントから

私はパートナーのフィールドに値を入力するための簡単なのSuiteScript 2.0コード(ID作成:「パートナー')とクーポンコード(id:'クーポンコード ')。両方のフィールドは、マルチセレクトフィールドではなく、ドロップダウンフィールドです。 フィールド「クーポンコード」は「プロモーション」フィールドに依存するため、「クーポンコード」フィールドの代わりに「プロポコード」フィールドに値を入力する必要があります。私たちは、それが私たちのために機能するためには1修正しなければならなかった

/** 
*@NApiVersion 2.x 
*@NScriptType usereventscript 
*/ 

define(['N/record'], 
    function(record) { 

     function AfterSubmit(context) { 


      var result = record.load({ 
       type: 'salesorder', 
       id: 71040, 
       isDynamic: true 
      }); 

      result.setValue ({ 
       fieldId : 'partner', 
       value : 45140 
      }); 
      result.setValue ({ 
       fieldId : 'couponcode', 
       value : 'AMARILLO16' 
      }); 
      result.save({ 
       enableSourcing : false, 
       ignoreMandatoryFields : true 
      }); 
      return true; 
     } 

     return { 
      afterSubmit: AfterSubmit 
     }; 
}); 

:回答をフォーマット

result.setValue ({ 
      fieldId : 'partner', 
      value : 45140 
     }); 
     result.setText ({ 
      fieldId : 'couponcode', 
      text : 'AMARILLO16' 
     }); 
     result.save({ 
      enableSourcing : false, 
      ignoreMandatoryFields : true 
     }); 
関連する問題