# Flexible relationships

**URL:** <https://community.spicecrm.io/t/flexible-relationships/135>\
**Category:** KReporter\
**Created:** [June 6, 2017, 3:28pm UTC](https://community.spicecrm.io/t/flexible-relationships/135 "2017-06-06T15:28:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![j.dickinson](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@j.dickinson](https://community.spicecrm.io/u/j.dickinson)\
**Post date:** [June 6, 2017, 3:28pm UTC](https://community.spicecrm.io/t/flexible-relationships/135/1 "2017-06-06T15:28:13Z")

</div>

I’m using Supertimesheet in SuiteCRM to track work hours. See attached an excerpt of the timesheet table.

 ![](https://canada1.discourse-cdn.com/flex030/uploads/spicecrm/original/1X/fa06cfe13e83f3e8376fd01be923e6f60dec46c6.png)

As you can see in the attached screenshot, “project\_id” is listed in a dedicated column, so the link to a project is simple.  
However, the relationship to a specific ProjectTask is done via two columns: “parent\_type” & “parent\_id”.

KReporter seems unable to to report the timesheet table by ProjectTasks. I assume this is because of this complex relationship for project tasks. Reporting by Project works fine.  
KReporter doesn’t even show that complex relationship on the left where the relationships are shown (“relationship tree”?). And there is no field listed that could be used either.

What can I do to make KReporter happy? 🙂

- add a helper column with only the Projecttask\_IDs in the timesheet table? (or in a new timesheet\_cstm table?)
- add custom code to Reporter somehow?

---

<div class="post-metadata">

**Author:** ![maretval](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@maretval](https://community.spicecrm.io/u/maretval)\
**Post date:** [June 7, 2017, 8:33am UTC](https://community.spicecrm.io/t/flexible-relationships/135/2 "2017-06-07T08:33:22Z")

</div>

KReporter can handle relationships defined with 2 columns.  
However we do not garantee that KReporter will work properly under SuiteCRM. KReporter is designed to work under SugarCRM and SpiceCRM.

I guess that Timesheet is defined as a module. If so you should be able to select timesheet as base module for your report. If the link to ProjectTasks is defined properly then ProjectTasks module should appear as related module in KReporter Module Tree. If not, then the link definition should be checked. But as I wrote, we do not support SuiteCRM.

---

<div class="post-metadata">

**Author:** ![j.dickinson](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@j.dickinson](https://community.spicecrm.io/u/j.dickinson)\
**Post date:** [June 8, 2017, 9:53am UTC](https://community.spicecrm.io/t/flexible-relationships/135/3 "2017-06-08T09:53:43Z")

</div>

That’s a shame. Unfortunately ProjectTasks does not appear as related module in the Module tree. Would you give me any idea what you mean with “the link definition should be checked”?

---

<div class="post-metadata">

**Author:** ![maretval](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@maretval](https://community.spicecrm.io/u/maretval)\
**Post date:** [June 8, 2017, 1:07pm UTC](https://community.spicecrm.io/t/flexible-relationships/135/4 "2017-06-08T13:07:34Z")

</div>

Check in Timesheet vardefs if you see any link deifnition to ProjectTasks. Insert it if missing  
’projecttask’ =\> array(  
‘name’ =\> ‘projecttask’,  
‘type’ =\> ‘link’,  
‘relationship’ =\> ‘nameOfRelationshipForTimesheetProjectTasks’, //probably defined in timesheet module vardefs. Look for the right name  
’module’ =\> ‘ProjectTask’,  
‘bean\_name’ =\> ‘ProjectTask’,  
‘source’ =\> ‘non-db’,  
‘vname’ =\> ‘LBL\_PROJECTASK’,  
),

---

<div class="post-metadata">

**Author:** ![j.dickinson](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@j.dickinson](https://community.spicecrm.io/u/j.dickinson)\
**Post date:** [June 12, 2017, 1:20pm UTC](https://community.spicecrm.io/t/flexible-relationships/135/5 "2017-06-12T13:20:24Z")

</div>

There is indeed no such block in the timesheet vardefs.php file.  
There is also no corresponding relationship name to be found in the timesheet vardefs file.

The only relevant relationship definition I could find so far is in the DB in the table “relationships”:  
name = projecttask\_timesheet  
relationship\_type = one-to-many  
relationship\_role\_column = parent\_type  
relationship\_role\_column\_value = ProjectTask

 ![](https://canada1.discourse-cdn.com/flex030/uploads/spicecrm/original/1X/b523b2bc1c18cff48b8ecd26052390df066ca6ca.png)

I checked again whether the timesheet table shows up in KReporter’s module tree if I start with module ProjectTask. But that is not the case.

---

<div class="post-metadata">

**Author:** ![maretval](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@maretval](https://community.spicecrm.io/u/maretval)\
**Post date:** [June 12, 2017, 2:05pm UTC](https://community.spicecrm.io/t/flexible-relationships/135/6 "2017-06-12T14:05:26Z")

</div>

Add  
’projecttask’ =\> array(  
‘name’ =\> ‘projecttask’,  
‘type’ =\> ‘link’,  
‘relationship’ =\> ‘projecttask\_timesheet’,  
‘module’ =\> ‘ProjectTask’,  
‘bean\_name’ =\> ‘ProjectTask’,  
‘source’ =\> ‘non-db’,  
‘vname’ =\> ‘LBL\_PROJECTASK’,  
),

in the timesheet module vardefs.php (=\> in the “fields” list), do a repair/rebuild and check if projecttask module appears in Kreports tree having timesheet module selected as main module.

---

<div class="post-metadata">

**Author:** ![j.dickinson](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@j.dickinson](https://community.spicecrm.io/u/j.dickinson)\
**Post date:** [June 14, 2017, 12:18pm UTC](https://community.spicecrm.io/t/flexible-relationships/135/7 "2017-06-14T12:18:52Z")

</div>

thanks maretval

I tried exactly that (in a copy of vardefs.php in /custom/modules/Timesheet/) but unfortunately no effect. This code doesn’t even show up in /cache/modules/Timesheet/Timesheetvardefs.php

---

<div class="post-metadata">

**Author:** ![maretval](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@maretval](https://community.spicecrm.io/u/maretval)\
**Post date:** [June 14, 2017, 12:34pm UTC](https://community.spicecrm.io/t/flexible-relationships/135/8 "2017-06-14T12:34:37Z")

</div>

I don’t know about custom rules in SuiteCRM but in SugarCRM you would add it to custom/Extension/modules/Timesheet/Ext/Vardefs/Timesheetvardefs.php  
I can’t help further unless we agree on a development fee.

---

<div class="post-metadata">

**Author:** ![j.dickinson](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@j.dickinson](https://community.spicecrm.io/u/j.dickinson)\
**Post date:** [June 14, 2017, 12:39pm UTC](https://community.spicecrm.io/t/flexible-relationships/135/9 "2017-06-14T12:39:27Z")

</div>

Yeah, sorry. My mistake. Added it to /custom/Extension/modules/Timesheet/Ext/Vardefs/customname.php.

Now shows up on KReporter! I did some tests, working fine.

Thanks so much!
