Discussion:
[Vtigercrm-developers] vtlib, setRelatedModules() associative array does not create a related list.
Martin Allen
2018-10-29 16:04:46 UTC
Permalink
When creating a field using vtlib it is possible to pass an associative
array to setRelatedModules() function which SHOULD create a related list in
the related module.

However it never correctly creates the list, as it can't call the function
Vtiger_Module_Model::getRelationshipActions() .

e.g. $field1->setRelatedModules(Array('Contacts'=>'Accounts')) should
create a related list in Contacts module labelled 'Accounts', relating to
the module that the field was in.

Are we missing a include/require?? (Only including vtlib/Vtiger/Module.php
and Field.php and Block.php)

We tried including /modules/Vtiger/models/Module.php but still can't get it
working??

Any ideas, as the ability to add a related field and its equivalent related
list in one call would be a great time saver!!

Martin Allen

*>>Call me now for free<< <https://emailrtc.voiceflex.com/?c=7b355216c4>*


*01392 248692 - Main Office01392 690659 - Direct Line*

*[image: signature2]*

Have you visited our website recently? http://www.clystnet.com


The information in this email is confidential If you are not the intended
recipient, you must not read or use that information. This email and any
attachments are believed to be virus free however no responsibility is
accepted by Clystnet for any loss or damage arising in any way from receipt
or use thereof. Clystnet Ltd (company reg number 7164503) is based at
Silverdown Park, Fair Oak Close, Clyst Honiton, EX5 2UX
Alan Lord
2018-10-29 16:31:48 UTC
Permalink
Err, but you also need to specify which function to call to generate the
related list of data and also what features are available from the
related List, e.g. "ADD, SELECT"...

Can't see how that would work some how, unless I am missing the point.

Al
Post by Martin Allen
When creating a field using vtlib it is possible to pass an associative
array to setRelatedModules() function which SHOULD create a related list
in the related module.
However it never correctly creates the list, as it can't call the
function Vtiger_Module_Model::getRelationshipActions() .
e.g. $field1->setRelatedModules(Array('Contacts'=>'Accounts')) should
create a related list in Contacts module labelled 'Accounts', relating
to the module that the field was in.
Are we missing a include/require?? (Only including
vtlib/Vtiger/Module.php and Field.php and Block.php)
We tried including /modules/Vtiger/models/Module.php but still can't get
it working??
Any ideas, as the ability to add a related field and its equivalent
related list in one call would be a great time saver!!
Martin Allen
*>>Call me now for free<< <https://emailrtc.voiceflex.com/?c=7b355216c4>*
*01392 248692 - Main Office
01392 690659 - Direct Line*
*signature2*
Have you visited our website recently? http://www.clystnet.com
<http://www.clystnet.com/>
The information in this email is confidential If you are not the
intended recipient, you must not read or use that information. This
email and any attachments are believed to be virus free however no
responsibility is accepted by Clystnet for any loss or damage arising in
any way from receipt or use thereof. Clystnet Ltd (company reg number
7164503) is based at Silverdown Park, Fair Oak Close, Clyst Honiton, EX5 2UX
_______________________________________________
http://www.vtiger.com/
_______________________________________________
http://www.vtiger.com/
Martin Allen
2018-10-29 16:52:14 UTC
Permalink
If you look at the code in vtlib, it defaults the related list function to
get_dependents_list, and inserts the field id of the related field that we
just related to this module.
Which is perfect, its only if you want it do something custom that we need
to change the function in which case we would manually create the list
function.

It also *attempts *to get the actions (Add & Select) using the call to
Vtiger_Module_Model::getRelationshipActions() which *should* return
Array('ADD','SELECT') (presumably the idea being that if further actions
are ever added they would get returned too!) - however this call never
works. I think its becuase this function is located in
/modules/Vtiger/models/Module.php which the first line of which does
vimport('~/vtlib/Vtiger/Module.php') which I think upsets it when we've
already included it??

Martin Allen

*>>Call me now for free<< <https://emailrtc.voiceflex.com/?c=7b355216c4>*


*01392 248692 - Main Office01392 690659 - Direct Line*

*[image: signature2]*

Have you visited our website recently? http://www.clystnet.com


The information in this email is confidential If you are not the intended
recipient, you must not read or use that information. This email and any
attachments are believed to be virus free however no responsibility is
accepted by Clystnet for any loss or damage arising in any way from receipt
or use thereof. Clystnet Ltd (company reg number 7164503) is based at
Silverdown Park, Fair Oak Close, Clyst Honiton, EX5 2UX


On Mon, 29 Oct 2018 at 16:33, <
Send vtigercrm-developers mailing list submissions to
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.vtigercrm.com/cgi-bin/mailman/listinfo/vtigercrm-developers
or, via email, send a message with subject or body 'help' to
You can reach the person managing the list at
When replying, please edit your Subject line so it is more specific
than "Re: Contents of vtigercrm-developers digest..."
1. Re: vtiger 7.0 calendar access issue (IT-Solutions4You)
2. vtlib, setRelatedModules() associative array does not create
a related list. (Martin Allen)
3. Re: vtlib, setRelatedModules() associative array does not
create a related list. (Alan Lord)
----------------------------------------------------------------------
Message: 1
Date: Mon, 29 Oct 2018 13:38:24 +0100
Subject: Re: [Vtigercrm-developers] vtiger 7.0 calendar access issue
Content-Type: text/plain; charset=utf-8; format=flowed
If I remember my right sharing rules don't work with Calendar (Task,
Events) module. Calendar module has own "Calendar Sharing" setting. Each
user can define own sharing criteria.
But you can also set
View All - Can view all the modules information
Edit All - Can edit all the modules information
in profile setting of Vice profile.
Matus.
Hi,
in my vtiger I have the admin with role = CEO and a subrole called vice
which is not an admin, then I have a third role which is a subordinate
of vice. The vice role should have all the permission of the admin
except the delete, so the vice must be able to view/create/edit
everything, while the third role can view all the record but be able to
edit only the ones they created. To do that I created a sharing rule and
it works. The only problem is with the calendar. The calendar must
follow the sames rules so: vice can be able to view and edit all records
while third role can view all but can edit only the entries they've
created. The third role works as expected but the vice is not. At the
moment for calendar entries, the vice can view all the records but they
can modify only the record they've created. I need them to be able to
edit all the records.
I've set all the entries to Public but this doesn't solve the issue.
I've also tried to invite the other users just as a test but it doesnt
work either: the invited vice still cannot edit the record.
Is there a way to set the calendar in a way that the vice role can view
and edit all the records?
_______________________________________________
http://www.vtiger.com/
------------------------------
Message: 2
Date: Mon, 29 Oct 2018 16:04:46 +0000
Subject: [Vtigercrm-developers] vtlib, setRelatedModules() associative
array does not create a related list.
<CAL1vgxEUVvDC63CA9zm9JPBN53v=
Content-Type: text/plain; charset="utf-8"
When creating a field using vtlib it is possible to pass an associative
array to setRelatedModules() function which SHOULD create a related list in
the related module.
However it never correctly creates the list, as it can't call the function
Vtiger_Module_Model::getRelationshipActions() .
e.g. $field1->setRelatedModules(Array('Contacts'=>'Accounts')) should
create a related list in Contacts module labelled 'Accounts', relating to
the module that the field was in.
Are we missing a include/require?? (Only including vtlib/Vtiger/Module.php
and Field.php and Block.php)
We tried including /modules/Vtiger/models/Module.php but still can't get it
working??
Any ideas, as the ability to add a related field and its equivalent related
list in one call would be a great time saver!!
Martin Allen
*>>Call me now for free<< <https://emailrtc.voiceflex.com/?c=7b355216c4>*
*01392 248692 - Main Office01392 690659 - Direct Line*
*[image: signature2]*
Have you visited our website recently? http://www.clystnet.com
The information in this email is confidential If you are not the intended
recipient, you must not read or use that information. This email and any
attachments are believed to be virus free however no responsibility is
accepted by Clystnet for any loss or damage arising in any way from receipt
or use thereof. Clystnet Ltd (company reg number 7164503) is based at
Silverdown Park, Fair Oak Close, Clyst Honiton, EX5 2UX
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <
http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20181029/77c65185/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 10550 bytes
Desc: not available
URL: <
Loading Image...
------------------------------
Message: 3
Date: Mon, 29 Oct 2018 16:31:48 +0000
Subject: Re: [Vtigercrm-developers] vtlib, setRelatedModules()
associative array does not create a related list.
Content-Type: text/plain; charset=utf-8; format=flowed
Err, but you also need to specify which function to call to generate the
related list of data and also what features are available from the
related List, e.g. "ADD, SELECT"...
Can't see how that would work some how, unless I am missing the point.
Al
When creating a field using vtlib it is possible to pass an associative
array to setRelatedModules() function which SHOULD create a related list
in the related module.
However it never correctly creates the list, as it can't call the
function Vtiger_Module_Model::getRelationshipActions() .
e.g. $field1->setRelatedModules(Array('Contacts'=>'Accounts')) should
create a related list in Contacts module labelled 'Accounts', relating
to the module that the field was in.
Are we missing a include/require?? (Only including
vtlib/Vtiger/Module.php and Field.php and Block.php)
We tried including /modules/Vtiger/models/Module.php but still can't get
it working??
Any ideas, as the ability to add a related field and its equivalent
related list in one call would be a great time saver!!
Martin Allen
*>>Call me now for free<< <https://emailrtc.voiceflex.com/?c=7b355216c4
*
*01392 248692 - Main Office
01392 690659 - Direct Line*
*signature2*
Have you visited our website recently? http://www.clystnet.com
<http://www.clystnet.com/>
The information in this email is confidential If you are not the
intended recipient, you must not read or use that information. This
email and any attachments are believed to be virus free however no
responsibility is accepted by Clystnet for any loss or damage arising in
any way from receipt or use thereof. Clystnet Ltd (company reg number
7164503) is based at Silverdown Park, Fair Oak Close, Clyst Honiton, EX5
2UX
_______________________________________________
http://www.vtiger.com/
------------------------------
_______________________________________________
vtigercrm-developers mailing list
http://lists.vtigercrm.com/cgi-bin/mailman/listinfo/vtigercrm-developers
End of vtigercrm-developers Digest, Vol 153, Issue 25
*****************************************************
Alan Lord
2018-10-29 17:35:57 UTC
Permalink
Post by Martin Allen
If you look at the code in vtlib, it defaults the related list function
to get_dependents_list, and inserts the field id of the related field
that we just related to this module.
Not in vtiger 7.1.1:

function setRelatedList($moduleInstance, $label = '', $actions =
false, $function_name = 'get_related_list', $fieldId = null) {

get_related_list is suitable for the n:n relationship using the
vtiger_crmentityrel table.
Post by Martin Allen
It also /attempts /to get the actions (Add & Select) using the call to
Vtiger_Module_Model::getRelationshipActions() which /should/ return
Array('ADD','SELECT')
If you wanted to use get_dependents_list then SELECT will not work as
this implies you would be replacing the value in the source field of the
record being selected; and vtiger has no way of dealing with that at the
moment anyway.

Still not sure what benefit there would be of using an associative array
as you originally suggested. With the changes since v6 vtiger supports
having multiple related lists of the same module (maybe with different
functions or from a different source field) - using your mechanism would
not work at all in that scenario.


Al

_______________________________________________
http://www.vtiger.com/
Alan Lord
2018-10-29 17:54:35 UTC
Permalink
It seems you are partially correct...

I think what that is for is as I mentioned on your ticket:

http://code.vtiger.com/vtiger/vtigercrm/issues/1066

Cheers

Al
Post by Martin Allen
If you look at the code in vtlib, it defaults the related list
function to get_dependents_list, and inserts the field id of the
related field that we just related to this module.
 function setRelatedList($moduleInstance, $label = '', $actions =
false, $function_name = 'get_related_list', $fieldId = null) {
get_related_list is suitable for the n:n relationship using the
vtiger_crmentityrel table.
Post by Martin Allen
It also /attempts /to get the actions (Add & Select) using the call to
Vtiger_Module_Model::getRelationshipActions() which /should/ return
Array('ADD','SELECT')
If you wanted to use get_dependents_list then SELECT will not work as
this implies you would be replacing the value in the source field of the
record being selected; and vtiger has no way of dealing with that at the
moment anyway.
Still not sure what benefit there would be of using an associative array
as you originally suggested. With the changes since v6 vtiger supports
having multiple related lists of the same module (maybe with different
functions or from a different source field) - using your mechanism would
not work at all in that scenario.
Al
_______________________________________________
http://www.vtiger.com/
____________________________________________
Alan Lord
2018-10-30 08:47:01 UTC
Permalink
Amazing what a bit of sleep does...

Martin is completely right about the intention of this code. I think the
error is occurring because he was running his module creation script
from the command line (as I do, and I suspect many others) and in
vtlib/Vtiger/Field.php there is no automatic access to the loader so it
cannot find the class.

Adding
require_once('includes/main/WebUI.php');
To the vtlib file allows it to work from the command line. But I am not
sure if this the right way to do it or not. I would guess the right
place would be to add it to the top of vtlib/Vtiger/Utils.php

HTH


Al
It seems you are partially correct...
http://code.vtiger.com/vtiger/vtigercrm/issues/1066
Cheers
Al
_______________________________________________
http://www.vtiger.com/

Loading...