Hi,
In version v8.3.0 I cannot import Work for a Ticket item, because in the Import Result field it says "ERROR idAssignment mandatory". (By the way I can import real work to Activities the same way.)
My csv look like this:
id;resource;project;type of item;element id;name;work;date;cost;
;"Username";"Projectname";"Ticket";197;RE: DI Oracle minus alternatíva;0.06;2020-01-27;0.00;
;"Username";"Projectname";"Activity";166;Megvalósítási koncepció elkészítése;1.25;2020-01-28;0.00;
If I dispatch work from the Ticket itself, then in the database table 'work' the idassignment will be null, which is ok, in my opinion.
Is it possible to somehow import real Work to Ticket from Import Data?
Regards,
Zsolt
For work on tickets, you must indicate idWorkElement.
It doesn't work neither with idworkelement, nor with workelement. I got the same message.
What value should I put as workelement id, if I want to create a new real work?
resource;project;type of item;element id;work;date;idWorkElement
User;Project;Ticket;208;0.06;2020-02-03;
I think Work-->saveWork() doesn't handle this scenario. I mean adding new real work to a new ticket.
I am not sure what I have done doesn't make planning(calculating remaining work) wrong, but I added a few lines of code to saveWork to handle adding real work to a ticket, see below. I am also not sure if updateAssignment needs to be changed as well or not. Sorry if I am on the wrong track.
public function saveWork() {
if ($this->id) { // update existing work
$old=$this->getOld();
$result=$this->save();
$this->updateAssignment($this->work-$old->work);
return $result;
} else { // add new work
if (! $this->idResource and ! $this->idAssignment) { // idResource Mandatory
return "ERROR idResouce mandatory";
}
if (! $this->workDate) {
if ($this->day) {
$this->workDate=substr($this->day,0,4).'-'.substr($this->day,4,2).'-'.substr($this->day,6,2);
} else { // Work Date is mandatory
return "ERROR workDate mandatory";
}
}
if (!$this->idAssignment) { // unknown assignment
if ($this->refType and $this->refId) {
$crit=array('refType'=>$this->refType,'refId'=>$this->refId,'idResource'=>$this->idResource);
$ass=SqlElement::getSingleSqlElementFromCriteria('Assignment', $crit);
if ($ass->id) {
$this->idAssignment=$ass->id;
} else {
$crit=array('refType'=>$this->refType,'refId'=>$this->refId);
$tick=SqlElement::getSingleSqlElementFromCriteria('WorkElement', $crit);
if ($tick->id) {
$this->idWorkElement=$tick->id;
} else {
return "ERROR either idAssignment or idWorkElement is mandatory"; // could not retrieve assignment, so is mandatory
}
}
}
} else { // refType & refId can be retreived from assignment
$ass=new Assignment($this->idAssignment);
$this->refType=$ass->refType;
$this->refId=$ass->refId;
$this->idResource=$ass->idResource;
}
if ($this->idAssignment) {
$crit=array('idAssignment'=>$this->idAssignment,'workDate'=>$this->workDate); // retreive work for this assignment & day (assignment includes resource)
$work=SqlElement::getSingleSqlElementFromCriteria('Work', $crit);
}
else {
$crit=array('idWorkElement'=>$this->idWorkElement,'workDate'=>$this->workDate); // retreive work for this assignment & day (assignment includes resource)
$work=SqlElement::getSingleSqlElementFromCriteria('Work', $crit);
}
if ($work->id) {
$work->work+=$this->work;
$result=$work->save();
$work->updateAssignment($this->work);
return $result;
} else {
$this->setDates($this->workDate);
$result=$this->save();
$work->updateAssignment($this->work);
return $result;
}
}
}
Hi,
Thanks for pointing out the issue and proposing a solution.
We'll include your proposal (with minor changes) to next patch.