Problem with workflow

Sara007
Tera Contributor
Hi! I was given a workflow project to do, but unfortunately I have some problems with it (I'm doing it for the first time and I'm new to ServiceNow). If anyone could give me some tips, I would be very grateful 🙂
------------------------------------------------------------------------------------
 So, let's start with the content of the task:
-I have two tables: Order (extends Task) and Order Task (extends Order).
- I have to create a workflow for the Order table with these steps in the following order:
 
1. Upon opening, it asks for approval from the manager of the requested for. If the person who opens the ticket is the manager, the approval is self-approved.
 
2. If the approval is approved, go to step 4, while if rejected, an Order Task opens in the "Order controller" group where it is viewed whether the order actually makes no sense and must be done
 
3. If the Order Task is closed "Close Complete" the Order is closed and skipped (step 8), if it is put in "Force order" you go to step 4
 
4. After approving ok or the Order Task in "Force Order", a "Fulfill order" Task is created. when this Task is opened, the Order automatically switches from the "Open" status to "In progress"
 
5. When the "Fulfill order" Task switches to "Close Complete" go to step 7, if instead it is put in "on hold" the state becomes readonly and it is mandatory to insert a work note and go to step 6
 
6. A Task is opened in the "Order Controller" group to view the reason for the "on hold" of the previous Task, once this Task is closed with "Close Complete" or "Force order" the status on the previous Task becomes editable, allowing you to proceed with the order.
 
7. A Task is opened for the "Order Controller" group to view the order, while the Order automatically switches to the "Review" state.
 
8. If the Task is placed in "Close Complete" the Order is placed in "Close Complete" and the workflow ends, if it is closed as "Close Incomplete" you return to step 4. (You can only get here from step 3 , the Order is placed in "Close Skipped" and the workflow ends)
 
NOTE: Whenever an Order Task is put into a closed state i.e. Close complete, Close Incomplete and Force order, the Task becomes read-only except for work notes
 
----------------------------------------------------------------------------------
Sara007_0-1713791044043.png

 

 
I created a workflow, but I have a problem with a few things:
A. The workflow is for the Order table, how can I see the fields of the Order Task I created here? I did something like that:
 
CREATE A ORDER TASK
var task = new GlideRecord('u_order_task');
task.short_description = 'Order_Task_';
task.insert();
var newTaskSysId = task.sys_id;
workflow.scratchpad.newTaskSysId = newTaskSysId;
 
 
WAIT FOR CONDITION
(function checkCondition() {
  var newTaskSysId = workflow.scratchpad.newTaskSysId; 
  var taskRecord = new GlideRecord('u_order_task');
  taskRecord.get(newTaskSysId); 
 
  if (taskRecord.isValidRecord()) {
    if (taskRecord.state == '3') {
      answer = true; 
    } else {
answer = false;
}
  } else {
    gs.log('Specified Order Task record not found');
  }
})();
 
Will something like this work here?
 
 
B. How should I set the fields to be read-only or mandatory in the Order Task table? (point 5). This is about this specific Task for the Fulfill group, I cannot set it generally for all Tasks because other groups in this workflow also use the Order Task table.
 
C. Point 6 - "once this Task is closed with "Close Complete" or "Force order" the status on the previous Task becomes editable". I have no idea how to do that. 
 
-----------------------------------------
I would be grateful for any tips!
Saluti!
 
 
 
0 REPLIES 0