@QMcKay thank you very much for backup. I debugged it and found:
It searching for item with id Donair Wrap.Wrap-cbEflBWTfUagdJe5xUahCg and task type KD Waiter - Food but the actual task type for that item is KD Task GUI - Food. So r.data.task becomes null in getTaskbyIdentifier function.
But, it works properly when you complete only 1 Task at a time.
The Duplicate Command copies KD Task GUI - Food to KD Waiter - Food.
Then the Automation command executes the Function to update KD Waiter - Food (the duplicate) by its Identifier, to change its Color.
The problem is that the Duplicate command is only duplicating a single Task. Additional Tasks are not duplicated.
If we disable the Script call, no error occurs. However, you can see that 1 Task is duplicated TWICE, and the 2nd Task is NOT duplicated. I just tested this by disabling the Script action.
If I test Completing 3 Tasks, the 1st Task is duplicated 3 times, and the 2nd and 3rd Tasks are NOT duplicated.
That is probably a different issue. I don’t think they are related. When I create a ticket that have two orders and select both to complete same error throws.
I have another idea to go about it a different way, without duplicating or changing the Task Type. Will try different method later today or tomorrow.
EDIT: just tried my other idea, but the Color of the Task Card is ignored once the Task is Completed. In fact, all formatting is lost on Completed Task Cards…
This is my original idea (even before the Duplicate idea) simply using the GQL addTask() mutation in Script to copy the all the Task details to a new Task Type.
I was having trouble getting this work last night, but today it is working!
I think it might be because yesterday I was using {CALL:X} to execute the function, but today I am using the Execute Script Action.
This script looks the same as previously posted, but one of the functions has been updated, so you need to update the Script functions. Specifically, the addTask() function has been updated.
taskTypeNew = 'KD Waiter - Food' // our new Task Type for the Waiter Display
taskName = '' // optional, when left blank, it will use the same taskName as the KD Food Task
content = 'XXXXX READY XXXXX' // optional, content will be appended to the Order on the Waiter Task Card
identifier = '[:CommandValue]' // leave this alone, the value is passed as the [Id] for the KD Food Task Widget
color = '#55007700' // medium Green color
taskTypeOld = 'KD Task GUI - Food' // the original KD Food Task Type (ie. 'FoodDisplayTask')
Hi emre,
this is the script i have copied:
function getTaskbyIdentifier(taskType,ident,field) {
// getTaskbyIdentifier(‘KD Task GUI - Food’,‘27751-Qure Burger.Burger-12837-j9tXI2XMRkq7Q446SFfroQ’)
taskType = typeof taskType===‘undefined’ ? ‘’ : taskType;
ident = typeof ident===‘undefined’ ? ‘’ : ident;
field = typeof field===‘undefined’ ? ‘name’ : field;
if (taskType==‘’ || ident==‘’) {
return false;
}
var qry = ‘{task:getTask(taskType:"’+taskType+‘“,identifier:”’+ident+‘"){id,name,identifier,content}}’;
var r = gql.Exec(qry);
r = JSON.parse(r);
var task = r.data.task;
var qry=‘mutation m {addTask (task:{taskType:"’+taskType+‘“,name:”’+name+‘“,content:”’+content+‘“,isCompleted:false,identifier:”’+ident+‘“,customData:[{name:“Color”,value:”’+color+‘"}]}){id,name,isCompleted,content,identifier,customData{name,value}}}’;
var r = gql.Exec(qry);
r = JSON.parse(r);
var task = r.data.addTask;
var qry=‘mutation m {updateTask (taskType:"’+taskType+‘“,identifier:”’+ident+‘“,task:{taskType:”’+taskType+‘“,isCompleted:false,identifier:”’+ident+‘“,customData:[{name:“Color”,value:”’+color+‘"}]}){id,name,isCompleted,content,identifier,customData{name,value}}}’;
var r = gql.Exec(qry);
r = JSON.parse(r);
var task = r.data.updateTask;
Hi sir i follow this tutorial for waiter screen when we complete the order from kitchen screen it must come on waiter screen but it is not coming sir please help me for this sir
var qry = ‘{task:getTask(taskType:"’+taskType+’",identifier:"’+ident+’"){id,name,identifier,content}}’;
var r = gql.Exec(qry);
r = JSON.parse®;
var task = r.data.task;
var qry=‘mutation m {addTask (task:{taskType:"’+taskType+’",name:"’+name+’",content:"’+content+’",isCompleted:false,identifier:"’+ident+’",customData:[{name:“Color”,value:"’+color+’"}]}){id,name,isCompleted,content,identifier,customData{name,value}}}’;
var r = gql.Exec(qry);
r = JSON.parse®;
var task = r.data.addTask;
var qry=‘mutation m {updateTask (taskType:"’+taskType+’",identifier:"’+ident+’",task:{taskType:"’+taskType+’",isCompleted:false,identifier:"’+ident+’",customData:[{name:“Color”,value:"’+color+’"}]}){id,name,isCompleted,content,identifier,customData{name,value}}}’;
var r = gql.Exec(qry);
r = JSON.parse®;
var task = r.data.updateTask;
You have several mistakes that I can seee right off the bat for example Task complete commands you have a less than sign? What did you expect that to do? Also in your template you have [Content] I am fairly sure that is not accurate as well.