<?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>How do I Auto Populate a Custom Relate Field when Creating a Record from a Subpanel?</title><link>https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/1860/how-do-i-auto-populate-a-custom-relate-field-when-creating-a-record-from-a-subpanel</link><description>Hi all, I&amp;#39;m attempting to populate a custom relate field (primary_contact_c) when creating an opportunity from a contact using the subpanel; the relate field in the opportunity should be populated with the contact that it is being created from. I&amp;#39;ve found</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How do I Auto Populate a Custom Relate Field when Creating a Record from a Subpanel?</title><link>https://sugarclub.sugarcrm.com/thread/21790?ContentTypeID=1</link><pubDate>Tue, 15 Dec 2020 18:03:22 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:e3905de0-7491-40ef-81c2-431eaa0aa194</guid><dc:creator>Vincent Amari</dc:creator><description>&lt;p&gt;If instead of standard relate field type you instead use the Flex Relate field type, and create the Opportunity from the Contact subpanel, it will automatically populate the Contact for you.&amp;nbsp;&lt;span class="emoticon" data-url="https://sugarclub.sugarcrm.com/cfs-file/__key/system/emoji/263a.svg" title="Relaxed"&gt;&amp;#x263a;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As an alternative without using any relate fields, the Opportunity created this way already stores the related Contact as you can see if you run a report on Opportunities and add the Contact name to the report layout. &lt;br /&gt;Therefore, there must be a way to &amp;#39;expose&amp;#39; this via code and not resort to &amp;#39;duplicating this info&amp;#39;?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I Auto Populate a Custom Relate Field when Creating a Record from a Subpanel?</title><link>https://sugarclub.sugarcrm.com/thread/16437?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2019 15:45:37 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:d7f7fe46-0e2f-44c8-8c29-233726d85fd5</guid><dc:creator>Ian Trzoska</dc:creator><description>&lt;p&gt;Thanks, Andre and Maryam for your responses.&lt;/p&gt;&lt;p&gt;I&amp;#39;m not sure if this is considered to be basic stuff but I was eventually able to work this out by adding the below code to the vardef found at&amp;nbsp;custom\extension\modules\Opportunities\Ext\Vardefs\sugarfield_primary_contact_c.php&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['name']=&amp;#39;primary_contact_c&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['rname']=&amp;#39;name&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['id_name']=&amp;#39;contact_id_c&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['vname']=&amp;#39;LBL_PRIMARY_CONTACT&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['type']=&amp;#39;relate&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['table']=&amp;#39;contacts&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['join_name']=&amp;#39;contacts&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['isnull']=true;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['module']=&amp;#39;Contacts&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['dbType']=&amp;#39;varchar&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['link']=&amp;#39;contacts&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['len']=&amp;#39;255&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['source']=&amp;#39;non-db&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['unified_search']=true;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['required']=true;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['importable']=&amp;#39;required&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['required']=true;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['related_field']= array(&amp;#39;contact_id_c&amp;#39;);&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['exportable']=true;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['primary_contact_c']['export_link_type']=&amp;#39;one&amp;#39;;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;This&amp;nbsp;pre-populates the relate field in opportunities with the contact name when creating an opportunity from that contact but the link tries to take you to the the opportunity rather than the contact.&lt;/p&gt;&lt;p&gt;With that in mind I also tried to amend an existing vardef in the same folder which was&amp;nbsp;&lt;span&gt;sugarfield_contact_id_c and added in the below code:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['name']=&amp;#39;contact_id_c&amp;#39;;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['vname']=&amp;#39;LBL_CONTACT_ID&amp;#39;;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['id_name']=&amp;#39;contact_id&amp;#39;;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['type']=&amp;#39;relate&amp;#39;;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['link']=&amp;#39;contacts&amp;#39;;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['rname']=&amp;#39;id&amp;#39;;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['source']=&amp;#39;non-db&amp;#39;;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['audited']=true;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['dbType']=&amp;#39;id&amp;#39;;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['module']=&amp;#39;Contacts&amp;#39;;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;$dictionary['Opportunity']['fields']['contact_id_c']['massupdate']=false;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;I&amp;#39;m sure there are improvements that can be made on all of the above but this seems to work and I hope it helps anyone who has the same issues.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I Auto Populate a Custom Relate Field when Creating a Record from a Subpanel?</title><link>https://sugarclub.sugarcrm.com/thread/16436?ContentTypeID=1</link><pubDate>Fri, 25 Oct 2019 05:46:40 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:8d2c4095-8155-438e-9093-ff4d9bd05aee</guid><dc:creator>Maryam Aslam</dc:creator><description>&lt;p&gt;When we create a relationship between 2 modules a related field is automatically generated. The beauty of the &amp;quot;Relate field&amp;quot; which is generated by relationship is that we didn&amp;#39;t need to populate it by own, It will populate automatically.&lt;/p&gt;&lt;p&gt;&lt;a href="https://support.sugarcrm.com/Knowledge_Base/Studio_and_Module_Builder/Introduction_to_Relationships_and_Relate_Fields/" rel="nofollow" target="_blank"&gt;https://support.sugarcrm.com/Knowledge_Base/Studio_and_Module_Builder/Introduction_to_Relationships_and_Relate_Fields/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I Auto Populate a Custom Relate Field when Creating a Record from a Subpanel?</title><link>https://sugarclub.sugarcrm.com/thread/16435?ContentTypeID=1</link><pubDate>Tue, 22 Oct 2019 15:41:42 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:0fadb7b1-94af-4e95-b6b9-999400609303</guid><dc:creator>Andr&amp;#233; Lopes</dc:creator><description>&lt;p&gt;You need to create an &lt;a href="https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.0/Architecture/Extensions/Vardefs/" rel="nofollow" target="_blank"&gt;extended vardefs&lt;/a&gt; for Contacts in order to update&amp;nbsp;accordingly the attribute &amp;#39;populate_list&amp;#39; in the field &amp;#39;opportunities&amp;#39;.&amp;nbsp;You have to add a new pair from -&amp;gt; to in the populate_list with respect to the field to be copied from parent Contact to child Opportunity.&lt;/p&gt;&lt;p&gt;Remember to run Quick Repair and Rebuild after saving the extended vardefs.&lt;/p&gt;&lt;p&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>