The create Task on toolbar doesn’t fire the on Add event
so when we use it to create a task it's not created in the database
we can only create it if we pressed on the enter key
you can use this project to test "Test For Create Task2"
Support Forum
- Attachments
-
- create task - Made with Clipchamp.mp4
- (15.31 MiB) Downloaded 46 times
How can we review the code you used in Save btn handler of your custom "Add Task" popup?
All the best,
Alex Lazarev
How to ask for help? Please read our Support Policy
We do not write the code in bounds of forum support. If you need help with development, contact us via bryntum.com/services
This is the code
async onAddTaskClick() {
const
{ gantt } = this,
added = gantt.taskStore.rootNode.appendChild({
name : 'New task',
duration : 1,
effort : gantt.project.hoursPerDay,
shcedulingMode : 'Normal',
calendar : 'general',
});
// run propagation to calculate new task fields
await gantt.project.propagate();
// scroll to the added task
await gantt.scrollRowIntoView(added);
gantt.features.cellEdit.startEditing({
record : added,
field : 'name'
});
}
You can find the code in the GanttToolbar.js under the lib folder in the lwc named tasksGantt
I tested this code and I see add
event is triggered on taskStore
of Gantt.
I checked your video second time, I can't get why do you think the problem you faced caused by not triggered add event.
Could you please subscribe on add
event and log into console?
All the best,
Alex Lazarev
How to ask for help? Please read our Support Policy
We do not write the code in bounds of forum support. If you need help with development, contact us via bryntum.com/services
i'm already subscribing to add event on the task store
this.gantt.taskStore.on('add', ({ source, records, allRecords, parent, index, oldIndex, isChild, isExpand, isMove }) => {
if(! isExpand) { //if(!isExpand && !isMove) //isMove ||
let allTasks = this.getFlatTasks(records);
for(let record of allTasks){
if(!this.isSalesforceId(record.id)){
this.isInserting = true;
let task = JSON.parse(JSON.stringify(record));
task.wbs = record.wbsCode;
task.id = null;
task.successors = null;
task.generateInvoice = task.generateInvoice == undefined ? false : task.generateInvoice;
task.stopTimeEntry = task.stopTimeEntry == undefined ? false : task.stopTimeEntry;
task.costAdjustment = task.costAdjustment == null?0:task.costAdjustment;
task.revenueAdjustment = task.revenueAdjustment == null ? 0 : task.revenueAdjustment;
task.percentDone = task.percentDone == null ? 0 : task.percentDone;
task.duration = task.duration == null ? 0 : task.duration;
task.effort = task.effort == null ? 0 : task.effort;
task.readOnly = false;
task.baselines = null;
task.predecessors = null;
task.children = null;
this.mpaTasks2Insert.set(record.id, task);
}
}
}
});
Hi Maxim,
i'm sorry to tell you that the event is not triggered.
i added a console.log on the first line of the code and it's not writing it
Line 411
this.gantt.taskStore.on('add', ({ source, records, allRecords, parent, index, oldIndex, isChild, isExpand, isMove }) => {
console.log('on add');
if(! isExpand) { //if(!isExpand && !isMove) //isMove ||
please check this project
https://klenka5-dev-ed.develop.lightning.force.com/lightning/r/cwproject360__Project__c/a01d2000005CU97AAG/view
While in this project the on add event is not being triggered
https://klenka5-dev-ed.develop.lightning.force.com/lightning/r/cwproject360__Project__c/a01d20000056wzJAAQ/view
It's kind of a random behavior