2017-01-23 140 views
0

我需要第二双眼睛来帮助我编写此代码。具体而言,存在导致工作流程无法启动的情况。Servicenow审批工作流程代码

  1. “部门”是不确定每当请求的部门是空
  2. 有些时候跳过批准true和false(我不知道怎么写这部分)
  3. 这个审批工作流代码的情况下是帮助通过的ServiceNow(不通过服务目录)的后端创建门票

if (gs.nil(current.assignment_group)) { 
    if (!gs.nil(current.variable_pool.requested_for_department)) { 
     department = current.variable_pool.requested_for_department; 

     gs.log('0 ' + current.variable_pool.requested_for_department); 
    } 
    else if (!gs.nil(current.u_requested_for.department)) { 
     department = current.u_requested_for.department; 

     gs.log('1 ' + current.u_requested_for.department); 
    } 

    //If request was not created by e-mail. 
    if (current.u_email_creation != 2 && gs.nil(current.assignment_group)) { 

     //Finds value in Catalog Appr Fulfill Group table where Requestor Department IS NOT empty. 
     var vardept = new GlideRecord('u_catalog_appr_fulfill_group'); 
     vardept.addQuery('u_catalog_item', current.cat_item); 
     vardept.addQuery('u_requestor_department', department); 
     vardept.query(); 

     gs.log('2 approver ' + department); 

     //If record exists and the approval group for that item is not empty and approvals are not skipped... 
     if (vardept.next()){ 

      if (!gs.nil(vardept.u_catalog_item_approval_group) && vardept.u_skip_approval == false) { 
       //If record exists and the approval group for that item is not empty and approvals are not skipped... 

       //Current assignment group sets to the approval group from Catalog Appr Fulfill Group table. 
       current.assignment_group = vardept.u_catalog_item_approval_group; 

       gs.log('3 approver '); 
      } 
     } 

     else { 

      gs.log('4 approver '); 
      //Finds value in Catalog Appr Fulfill Group table where Requestor Department IS empty. 
      var vardept2 = new GlideRecord('u_catalog_appr_fulfill_group'); 
      vardept2.addQuery('u_catalog_item', current.cat_item); 
      vardept2.addNullQuery('u_requestor_department'); 
      vardept2.query(); 

      //If record exists and the Requestors department for that item is empty and approvals are skipped... 
      if (vardept2.next()) { 

       //If record exists and the Requestors department for that item is empty and approvals are NOT skipped... 
       if (!gs.nil(vardept2.u_catalog_item_approval_group) && vardept2.u_skip_approval == false) { 
        //Set assignment group to the record's approval group from Catalog Appr Fulfill Group table. 
        current.assignment_group = vardept2.u_catalog_item_approval_group; 

        gs.log('4 approver ' + vardept2.u_catalog_item_approval_group); 
       } 

      } 

      else if (gs.nil(group2.u_skip_approval) && current.assignment_group == '') { 
       gs.log('5'); 
       //If no record is found, set assignment group to Helpdesk Remote Approvers (For catalog items not in Catalog Appr Fulfill Group table). 
       current.assignment_group.setDisplayValue('Helpdesk Remote Approvers'); 
      } 
     } 
    } 
} 
+0

你应该突出你的疑问,而不是简单地在这里粘贴代码..... – Rupsingh

回答

0

好奇:你在运行这个工作流代码时面对哪个表?如果是请求表,您可以直接点到部门,因为请求表已具有此字段/列:sc_request.requested_for.department。不知道为什么你创建了一个名为requested_for_department的自定义变量?