Announcement

Collapse
No announcement yet.

getEventList in Espo\Modules\Crm\Services returns duplicates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • getEventList in Espo\Modules\Crm\Services returns duplicates

    Hi,
    I created a new custom entity almost the same as meeting (copied it and added a couple of text fields). Where there are multiple assigned users. I found that when this entity is added to the calendar and all other items were turned off that duplicate events are returned from: /api/v1/Timeline?from=2021-02-04%2023:41&to=2021-02-08%2023:41&userId=2&scopeList=MyCustomObject

    If a second scope was given even when no records exist for it the duplicate is not returned.

    I updated the code to remove the duplicates and also renumber the elements in the array and the error is fixed.


    PHP Code:

    $rowList 
    $sth->fetchAll(PDO::FETCH_ASSOC);

    $rowList array_unique($rowListSORT_REGULAR);
    $i=0;
    $rowList2 = [];
    foreach(
    $rowList as $row){
    $rowList2[$i] = $row;
    $i++;
    }
    return 
    $rowList2

    Here is a dump of the rowList variable before I made any changes as you can see item 2 and 3 have the same id this gives a this console error:

    PHP Code:

    VM3101
    :27 Uncaught ErrorCannot add itemitem with id 2-HillJob-601ccb0da43082528 already exists
    at n
    ._addItem (eval at _execute (espo.min.js?r=1612610760:1), <anonymous>:27:28677)
    at n.add (eval at _execute (espo.min.js?r=1612610760:1), <anonymous>:27:23812)
    at new (eval at _execute (espo.min.js?r=1612610760:1), <anonymous>:27:22580)
    at child.eval (eval at _execute (loader.js:97), <anonymous>:653:36)
    at child.eval (eval at _execute (loader.js:97), <anonymous>:904:17)
    at child.<anonymous> (jquery-2.1.4.min.js:2)
    at j (jquery-2.1.4.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-2.1.4.min.js:2)
    at x (jquery-2.1.4.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery-2.1.4.min.js:4
    PHP Code:
    2021-02-06 11:14:34rowList: Array
    (
    [
    0] => Array
    (
    [
    scope] => HillJob
    [id] => 601bcdd4724224e20
    [name] => AAA
    [dateStart] => 2021-02-05 10:30:00
    [dateEnd] => 2021-02-05 11:30:00
    [status] => Planned
    [dateStartDate] =>
    [
    dateEndDate] =>
    [
    parentType] =>
    [
    parentId] =>
    [
    createdAt] => 2021-02-04 10:35:00
    [color] =>
    )

    [
    1] => Array
    (
    [
    scope] => HillJob
    [id] => 601bcded703900b40
    [name] => CCCCCCCC
    [dateStart] => 2021-02-05 10:30:00
    [dateEnd] => 2021-02-05 11:30:00
    [status] => Not Held
    [dateStartDate] =>
    [
    dateEndDate] =>
    [
    parentType] =>
    [
    parentId] =>
    [
    createdAt] => 2021-02-04 10:35:25
    [color] =>
    )

    [
    2] => Array
    (
    [
    scope] => HillJob
    [id] => 601ccb0da43082528
    [name] => Job Numbers
    [dateStart] => 2021-02-06 11:00:00
    [dateEnd] => 2021-02-06 12:00:00
    [status] => Planned
    [dateStartDate] =>
    [
    dateEndDate] =>
    [
    parentType] =>
    [
    parentId] =>
    [
    createdAt] => 2021-02-05 04:35:25
    [color] =>
    )

    [
    3] => Array
    (
    [
    scope] => HillJob
    [id] => 601ccb0da43082528
    [name] => Job Numbers
    [dateStart] => 2021-02-06 11:00:00
    [dateEnd] => 2021-02-06 12:00:00
    [status] => Planned
    [dateStartDate] =>
    [
    dateEndDate] =>
    [
    parentType] =>
    [
    parentId] =>
    [
    createdAt] => 2021-02-05 04:35:25
    [color] =>
    )

    [
    4] => Array
    (
    [
    scope] => HillJob
    [id] => 601e3d4daa8c70c1d
    [name] => Job From Activity
    [dateStart] => 2021-02-06 10:00:00
    [dateEnd] => 2021-02-06 10:15:00
    [status] => Planned
    [dateStartDate] =>
    [
    dateEndDate] =>
    [
    parentType] => Account
    [parentId] => 60167a5a87468510a
    [createdAt] => 2021-02-06 06:55:09
    [color] =>
    )




Working...
X