2017-08-10 30 views
1

私はJavascriptとServicenowには新たに失敗しました。インシデント・タスクのインシデント・ブリーチ・タイム・ラベルを入力する修正スクリプトを作成しています。親のインシデントと同じSLAが表示されます。私の下のスクリプトは、更新すべき正しい数のレコードを返します。しかし、私が2番目のGlideRecordでレコードを更新すると、1つのレコードしか更新されません(約125でなければなりません)。私はテストの目的でコードの更新部分にコメントしました。助言がありますか?おかげ修正スクリプト1つのレコードを更新する

var grSLA = new GlideRecord('u_incident_task'); 
grSLA.addEncodedQuery('u_incident_breach_timeISEMPTY^parentISNOTEMPTY^stateIN1,2,4'); 
grSLA.query(); 

var count=0; 
gs.info("{0} of Itasks found to update", grSLA.getRowCount()); 

while (grSLA.next()) 
{ 
    var ipar = grSLA.parent.sys_id; 
} 
gs.print(ipar); 

var grName = new GlideRecord('task_sla'); 
grName.addQuery('task', ipar); 
grName.addQuery('stage', 'in_progress'); 
grName.query(); 

while (grName.next()) 
{ 
    var bTime = grName.planned_end_time.getDisplayValue(); 
    grSLA.u_incident_breach_time=bTime; //sets the Incident Breach Time on the iTask 

    //grSLA.update(); 
    count++; 
} 

答えて

0

私はあなたのu_incident_taskループの内側にあなたのtask_slaループを移動する必要が信じています。

iparがループ内の最後のレコードであるため、最後のものだけを更新しています。

var grSLA = new GlideRecord('u_incident_task'); 
grSLA.addEncodedQuery('u_incident_breach_timeISEMPTY^parentISNOTEMPTY^stateIN1,2,4'); 
grSLA.query(); 

var count=0; 
gs.info("{0} of Itasks found to update", grSLA.getRowCount()); 

while (grSLA.next()) 
{ 
    var ipar = grSLA.parent.sys_id; 
    gs.print(ipar); 

    var grName = new GlideRecord('task_sla'); 
    grName.addQuery('task', ipar); 
    grName.addQuery('stage', 'in_progress'); 
    grName.query(); 

    while (grName.next()) 
    { 
     var bTime = grName.planned_end_time.getDisplayValue(); 
     grSLA.u_incident_breach_time=bTime; //sets the Incident Breach Time on the iTask 

     grSLA.update(); 
     count++; 
    } 
} 
+0

ありがとうございました!今すぐ完璧に動作します。 – AdamK

関連する問題