<div>Hi Darlington Mpofu,</div>
<div> </div>
<div>Please see my comments inline:<br></div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">1. where do l write the function, in the module.js or in the module.php or either</blockquote>
<div> </div>
<div>If the function is to perform action on client side, then you write it in module.js. If the function is to perform action or do some computation on the server side, then you write it in module.php. Some times you may have to write function in module.js to trigger an action/function from module.php file as a way to interact from client end.</div>

<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><br>2.how do l capture values from custom fields in a function</blockquote>
<div> </div>
<div>You can call retrieve_entity_info on a CRMEntity instance to get the values of all the fields and fetch them from the object. (You can also query them directly from database if required).</div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><br>3.how do l place the values into fields after querying the tables</blockquote>
<div> </div>
<div>Have a look at retrieve_entity_info function of data/CRMEntity.php file</div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><br>4. is it the right thing to call the function inside the save_module function in the module.php file</blockquote>

<div> </div>
<div>It all depends on what your function does. If it performs a action that is part of save, then it makes sense to have it in place.<br clear="all"><br>-- <br>Regards,<br>Asha<br>vtiger Team<br></div>