<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://sugarclub.sugarcrm.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Relate field to &amp;#39;Employees&amp;#39; module</title><link>https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/2063/relate-field-to-employees-module</link><description>Hi, I have built a custom module using module builder and have deployed to a Sugar instance. I want to add a Relate field in the custom module which links to the Employees module. This is because the information to be captured can relate to either ex</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Relate field to 'Employees' module</title><link>https://sugarclub.sugarcrm.com/thread/7543?ContentTypeID=1</link><pubDate>Fri, 19 Jun 2020 20:52:10 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:14d867f7-c132-4957-8887-ca1c25f9e31c</guid><dc:creator>Neil Conacher</dc:creator><description>&lt;p&gt;Hi Andres Lopez&lt;/p&gt;&lt;p&gt;I&amp;#39;ve been away from this for a few weeks and now back on it. Must admit, still struggling a bit.&lt;/p&gt;&lt;p&gt;Managed to get the endpoint e-num piece working so that the field now surfaces a list of the employees when I am creating/editing the record. However, when I save the record, the chosen value does not get saved into the record, it remains empty.&lt;/p&gt;&lt;p&gt;Would welcome your advice.&lt;/p&gt;&lt;p&gt;Thanks&lt;/p&gt;&lt;p&gt;Here is my vardefs file (based on Angel blog)&lt;/p&gt;&lt;p&gt;Notes :&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Commented out the original type =&amp;gt; relate as type from your guidance is &amp;#39;enum-api&amp;#39;&lt;/li&gt;&lt;li&gt;When I ran the QRR after adding this vardef file , was prompted to create field and this added field sym_employeenew_id_c to the module table in the SQL database&lt;/li&gt;&lt;li&gt;In Studio I see the field and its name shows as sym_employee_c with type Enum-api&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;This is the vardefs file&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;lt;?php&lt;/p&gt;&lt;p&gt;$dictionary["symfc_FCQuotas"]["fields"]["sym_employee_c"] = array (&lt;br /&gt; &amp;#39;required&amp;#39; =&amp;gt; false,&lt;br /&gt; &amp;#39;source&amp;#39; =&amp;gt; &amp;#39;non-db&amp;#39;,&lt;br /&gt; &amp;#39;name&amp;#39; =&amp;gt; &amp;#39;sym_employee_c&amp;#39;,&lt;br /&gt; &amp;#39;vname&amp;#39; =&amp;gt; &amp;#39;Employee&amp;#39;,&lt;br /&gt; //&amp;#39;type&amp;#39; =&amp;gt; &amp;#39;relate&amp;#39;,&lt;br /&gt; &amp;#39;type&amp;#39; =&amp;gt; &amp;#39;enum-api&amp;#39;,&lt;br /&gt; &amp;#39;api&amp;#39; =&amp;gt; &amp;#39;Employees/employees_list/&amp;#39;, &lt;br /&gt; &amp;#39;massupdate&amp;#39; =&amp;gt; 0,&lt;br /&gt; &amp;#39;comments&amp;#39; =&amp;gt; &amp;#39;&amp;#39;,&lt;br /&gt; &amp;#39;help&amp;#39; =&amp;gt; &amp;#39;&amp;#39;,&lt;br /&gt; &amp;#39;importable&amp;#39; =&amp;gt; &amp;#39;true&amp;#39;,&lt;br /&gt; &amp;#39;duplicate_merge&amp;#39; =&amp;gt; &amp;#39;disabled&amp;#39;,&lt;br /&gt; &amp;#39;duplicate_merge_dom_value&amp;#39; =&amp;gt; &amp;#39;0&amp;#39;,&lt;br /&gt; &amp;#39;audited&amp;#39; =&amp;gt; false,&lt;br /&gt; &amp;#39;reportable&amp;#39; =&amp;gt; true,&lt;br /&gt; &amp;#39;calculated&amp;#39; =&amp;gt; false,&lt;br /&gt; &amp;#39;len&amp;#39; =&amp;gt; &amp;#39;255&amp;#39;,&lt;br /&gt; &amp;#39;size&amp;#39; =&amp;gt; &amp;#39;20&amp;#39;,&lt;br /&gt; &amp;#39;id_name&amp;#39; =&amp;gt; &amp;#39;sym_employeenew_id_c&amp;#39;,&lt;br /&gt; &amp;#39;ext2&amp;#39; =&amp;gt; &amp;#39;Employees&amp;#39;,&lt;br /&gt; &amp;#39;module&amp;#39; =&amp;gt; &amp;#39;Employees&amp;#39;,&lt;br /&gt; &amp;#39;rname&amp;#39; =&amp;gt; &amp;#39;name&amp;#39;,&lt;br /&gt; &amp;#39;quicksearch&amp;#39; =&amp;gt; &amp;#39;enabled&amp;#39;,&lt;br /&gt; &amp;#39;studio&amp;#39; =&amp;gt; &amp;#39;visible&amp;#39;,&lt;br /&gt;&lt;br /&gt;);&lt;/p&gt;&lt;p&gt;$dictionary["symfc_FCQuotas"]["fields"]["sym_employeenew_id_c"] = array (&lt;br /&gt; &amp;#39;required&amp;#39; =&amp;gt; false,&lt;br /&gt; &amp;#39;name&amp;#39; =&amp;gt; &amp;#39;sym_employeenew_id_c&amp;#39;,&lt;br /&gt; &amp;#39;vname&amp;#39; =&amp;gt; &amp;#39;&amp;#39;,&lt;br /&gt; &amp;#39;type&amp;#39; =&amp;gt; &amp;#39;id&amp;#39;,&lt;br /&gt; &amp;#39;massupdate&amp;#39; =&amp;gt; 0,&lt;br /&gt; &amp;#39;comments&amp;#39; =&amp;gt; &amp;#39;&amp;#39;,&lt;br /&gt; &amp;#39;help&amp;#39; =&amp;gt; &amp;#39;&amp;#39;,&lt;br /&gt; &amp;#39;importable&amp;#39; =&amp;gt; &amp;#39;true&amp;#39;,&lt;br /&gt; &amp;#39;duplicate_merge&amp;#39; =&amp;gt; &amp;#39;disabled&amp;#39;,&lt;br /&gt; &amp;#39;duplicate_merge_dom_value&amp;#39; =&amp;gt; 0,&lt;br /&gt; &amp;#39;audited&amp;#39; =&amp;gt; false,&lt;br /&gt; &amp;#39;reportable&amp;#39; =&amp;gt; true,&lt;br /&gt; &amp;#39;calculated&amp;#39; =&amp;gt; false,&lt;br /&gt; &amp;#39;len&amp;#39; =&amp;gt; 36,&lt;br /&gt; &amp;#39;size&amp;#39; =&amp;gt; &amp;#39;20&amp;#39;,&lt;br /&gt;);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;?&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;This is the api.php file which populates the DD list&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;lt;?php&lt;br /&gt;class symEmployeesApi extends SugarApi&lt;br /&gt;{&lt;br /&gt; public function registerApiRest()&lt;br /&gt; {&lt;br /&gt; return array(&lt;br /&gt; &amp;#39;getEmployeeList&amp;#39; =&amp;gt; array(&lt;br /&gt; &amp;#39;reqType&amp;#39; =&amp;gt; &amp;#39;GET&amp;#39;,&lt;br /&gt; &amp;#39;path&amp;#39; =&amp;gt; array(&amp;#39;Employees&amp;#39;, &amp;#39;employees_list&amp;#39;),&lt;br /&gt; &amp;#39;pathVars&amp;#39; =&amp;gt; array(),&lt;br /&gt; &amp;#39;method&amp;#39; =&amp;gt; &amp;#39;getEmployeeList&amp;#39;,&lt;br /&gt; &amp;#39;shortHelp&amp;#39; =&amp;gt; &amp;#39;Get a list employees for a dropdown field&amp;#39;,&lt;br /&gt; &amp;#39;longHelp&amp;#39; =&amp;gt; &amp;#39;&amp;#39;,&lt;br /&gt; ),&lt;br /&gt; );&lt;br /&gt; }&lt;/p&gt;&lt;p&gt;public function getEmployeeList($api, $args)&lt;br /&gt; {&lt;br /&gt; $list = array(&amp;#39;&amp;#39; =&amp;gt; $GLOBALS['app_strings']['LBL_NONE']);&lt;br /&gt; $query = new SugarQuery();&lt;br /&gt; $query-&amp;gt;select(array(&amp;#39;id&amp;#39;, &amp;#39;name&amp;#39;));&lt;br /&gt; $query-&amp;gt;from(BeanFactory::getBean(&amp;#39;Employees&amp;#39;));&lt;br /&gt;// $query-&amp;gt;where()-&amp;gt;equals(&amp;#39;active&amp;#39;, &amp;#39;1&amp;#39;);&lt;br /&gt; $query-&amp;gt;orderBy(&amp;#39;sym_reportname_c&amp;#39;, &amp;#39;ASC&amp;#39;);&lt;br /&gt; $results = $query-&amp;gt;execute();&lt;/p&gt;&lt;p&gt;foreach($results as $item) $list[$item['id']] = $item['first_name'] . &amp;#39; &amp;#39; . $item['last_name'];&lt;br /&gt;return $list;&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;&lt;strong&gt;This the the custom module table in SQL showing no data in the field&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="https://community.sugarcrm.com/servlet/JiveServlet/showImage/2-108962-87969/FCQuotas+NULL.png"&gt;&lt;img alt="NULL fields" class="jive-emoji image-1 jive-image j-img-original" height="111" src="https://community.sugarcrm.com/servlet/JiveServlet/downloadImage/2-108962-87969/FCQuotas+NULL.png" width="572" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;This is the field showing in Studio&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="https://community.sugarcrm.com/servlet/JiveServlet/showImage/2-108962-87970/FCQuotas+Studio.png"&gt;&lt;img alt="Field in Studio" class="jive-emoji jive-image image-2 j-img-original" height="409" src="https://community.sugarcrm.com/servlet/JiveServlet/downloadImage/2-108962-87970/FCQuotas+Studio.png" width="370" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relate field to 'Employees' module</title><link>https://sugarclub.sugarcrm.com/thread/7542?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 16:45:36 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:c43e22b8-e8fc-41bc-9b74-1deb6e918bff</guid><dc:creator>Neil Conacher</dc:creator><description>&lt;p&gt;Thanks &lt;a href="https://sugarclub.sugarcrm.com/members/andopes"&gt;Andr&amp;eacute; Lopes&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relate field to 'Employees' module</title><link>https://sugarclub.sugarcrm.com/thread/7541?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 16:27:28 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:4c8a20bf-f529-499c-8510-ba9e1a8d8127</guid><dc:creator>Andr&amp;#233; Lopes</dc:creator><description>&lt;p&gt;Find the &lt;a href="/external-link.jspa?url=http://cheleguanaco.blogspot.com/2011/08/sugarcrm-customization-employees-relate.html" rel="nofollow" target="_blank"&gt;link&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relate field to 'Employees' module</title><link>https://sugarclub.sugarcrm.com/thread/7540?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 17:35:41 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:c271bf29-99cb-4752-b9e6-7402ad5da123</guid><dc:creator>Neil Conacher</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://sugarclub.sugarcrm.com/members/andopes"&gt;Andr&amp;eacute; Lopes&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Thanks for your suggestion. I will have a look and let you know how I get on.&lt;/p&gt;&lt;p&gt;ps. I&amp;#39;m struggling to find the content under &lt;a href="https://sugarclub.sugarcrm.com/members/amagana"&gt;Angel Magana&lt;/a&gt; you refer to.&lt;/p&gt;&lt;p&gt;Thanks&lt;/p&gt;&lt;p&gt;Neil&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relate field to 'Employees' module</title><link>https://sugarclub.sugarcrm.com/thread/7539?ContentTypeID=1</link><pubDate>Fri, 08 May 2020 13:17:52 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:97066da0-40da-487b-b93f-9325eabd4075</guid><dc:creator>Andr&amp;#233; Lopes</dc:creator><description>&lt;p&gt;Employees module is, basically, a view for Users module.&lt;/p&gt;&lt;p&gt;You can follow the tips shared by &lt;a href="https://sugarclub.sugarcrm.com/members/amagana"&gt;Angel Magana&lt;/a&gt;&amp;nbsp;(custom fields to be created on extended vardefs of your custom module).&lt;/p&gt;&lt;p&gt;After that follow these steps:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Save the attached js file into custom/clients/base/fields/enum-api/&lt;/li&gt;&lt;li&gt;Create an endpoint&amp;nbsp;which&amp;nbsp;fetchs list of users, even the inactive ones,&amp;nbsp;take the attached php file as an example&lt;/li&gt;&lt;li&gt;Add, into record view of your custom module, the id field&amp;nbsp;you just created, as per Angels&amp;#39; blog, additionally place these two attributes into field definition:&lt;/li&gt;&lt;/ul&gt;&lt;blockquote class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;p&gt;&amp;#39;type&amp;#39; =&amp;gt; &amp;#39;enum-api&amp;#39;,&lt;br /&gt; &amp;#39;api&amp;#39; =&amp;gt; &amp;#39;Contacts/xportal_role_list/&amp;#39;,&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Replace the value of attribute api by the path of yours.&lt;/p&gt;&lt;p&gt;Run QRR,&amp;nbsp;Rebuild JS Grouping Files and finally&amp;nbsp;Clear Additional Cache. Clear browser cache and enjoy it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Relate field to 'Employees' module</title><link>https://sugarclub.sugarcrm.com/thread/7538?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2020 14:58:42 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:cc46cd77-85a8-41c7-8546-2f7cbf36f188</guid><dc:creator>Neil Conacher</dc:creator><description>&lt;p&gt;Hi Andres Lopez&lt;/p&gt;&lt;p&gt;I&amp;#39;ve not had any response to this question and juts wondered if you had any ideas ?&lt;/p&gt;&lt;p&gt;I know you often have very good ones &lt;span class="emoticon_happy emoticon-inline" style="height:16px;width:16px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Thanks&lt;/p&gt;&lt;p&gt;Neil&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>